Package com.hybris.cockpitng.core.impl
Class DefaultCockpitComponentDefinitionService
- java.lang.Object
-
- com.hybris.cockpitng.core.impl.DefaultCockpitComponentDefinitionService
-
- All Implemented Interfaces:
CockpitComponentDefinitionService,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
CockpitModuleComponentDefinitionService
public class DefaultCockpitComponentDefinitionService extends java.lang.Object implements CockpitComponentDefinitionService, org.springframework.context.ApplicationContextAware
This implementation of theCockpitComponentDefinitionServicehas a list ofCockpitComponentLoaders to load widget definitions using them. It provides allWidgetDefinitions from allCockpitComponentLoaders it holds.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_VIEW_ZULstatic java.lang.StringNO_VIEW_ZULstatic java.lang.StringPROPERTY_WIDGET_LIBRARY_BLACKLIST
-
Constructor Summary
Constructors Constructor Description DefaultCockpitComponentDefinitionService()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidbeforeCreateDefinition(CockpitComponentInfo info)Override to do manipulations to component info before creation of definitionprotected booleancheckIfEmpty(WidgetDefinition target, java.util.function.Function<WidgetDefinition,?> override)voidclearDefinitions()Clears components definitions.<T> TcreateAutowiredComponent(AbstractCockpitComponentDefinition root, java.lang.String className, org.springframework.context.ApplicationContext context)Creates autowired component<T> TcreateAutowiredComponent(AbstractCockpitComponentDefinition root, java.lang.String className, org.springframework.context.ApplicationContext context, boolean cachedInstance)Creates autowired componentprotected <T> TcreateClassInstance(org.springframework.context.ApplicationContext context, java.lang.Class clazz)protected java.util.Collection<java.lang.String>fetchWidgetBlacklist()protected voidfillInheritedDefinition(WidgetDefinition definition, WidgetDefinition extension, java.util.function.Predicate<java.util.function.Function<WidgetDefinition,?>> overrideCheck)protected voidfillInheritedFields(WidgetDefinition definition)protected TypedSettingsMapfillInheritedSettings(WidgetDefinition override, WidgetDefinition base)java.util.List<AbstractCockpitComponentDefinition>getAllComponentDefinitions()Provides all component definitions available in the system.protected CockpitApplicationContextgetApplicationContext()org.springframework.context.ApplicationContextgetApplicationContext(AbstractCockpitComponentDefinition definition)java.lang.ClassLoadergetClassLoader(AbstractCockpitComponentDefinition definition)Deprecated, for removal: This API element is subject to removal in a future version.since 1808, please useCockpitApplicationContext.getClassLoader()CockpitPropertiesgetCockpitProperties()AbstractCockpitComponentDefinitiongetComponentDefinitionForCode(java.lang.String code)Looks for a component definition with the given Editor code (example: 'com.hybris.cockpitng.editor.defaulttext')<T extends AbstractCockpitComponentDefinition>
TgetComponentDefinitionForCode(java.lang.String code, java.lang.Class<T> componentType)Looks for a component definition with the given code.<T extends AbstractCockpitComponentDefinition>
java.util.List<T>getComponentDefinitionsByClass(java.lang.Class<T> componentType)Provides all component definitions of given type.java.util.List<CockpitComponentLoader>getDefinitionLoaders()java.util.Collection<AbstractCockpitComponentDefinition>getExtensionsDefinitions()Get components definitions for extensions.protected java.util.Optional<CockpitComponentDefinitionFactory>getFactoryForInfo(CockpitComponentInfo info)java.util.Map<java.lang.String,WidgetDefinition>getStubWidgetDefinitions()Returns all stub widget definitions that were registered for 'non-widget' aware componentsprotected <T> voidinheritFieldValue(WidgetDefinition definition, WidgetDefinition extension, java.util.function.Predicate<java.util.function.Function<WidgetDefinition,?>> overrideCheck, java.util.function.Function<WidgetDefinition,T> getter, java.util.function.Consumer<T> setter)protected booleanisBlacklisted(AbstractCockpitComponentDefinition definition, java.util.Collection<java.lang.String> blacklist)protected booleanisDuplicate(AbstractCockpitComponentDefinition definition)protected java.util.Optional<AbstractCockpitComponentDefinition>loadDefinitionForComponentInfo(CockpitComponentInfo info, java.util.Collection<java.lang.String> widgetBlacklist)protected voidloadDefinitions()protected java.util.Set<CockpitComponentInfo>loadInfos(CockpitComponentLoader loader)protected voidprocessComponentInfo(CockpitComponentInfo info, java.util.Collection<java.lang.String> widgetBlacklist, java.util.function.Predicate<AbstractCockpitComponentDefinition> definitionTest)protected voidprocessExtensions()protected voidprocessInheritanceHierarchy()protected voidregisterWidgetStubDefinitions(AbstractCockpitComponentDefinition definition)voidreloadDefinitions()Reloads all component definitions.voidsetApplicationContext(org.springframework.context.ApplicationContext ctx)voidsetCockpitProperties(CockpitProperties cockpitProperties)voidsetDefinitionFactories(java.util.Map<java.lang.String,CockpitComponentDefinitionFactory> factories)voidsetDefinitionLoaders(java.util.List<CockpitComponentLoader> definitionLoaders)voidsetToResetAfterReload(java.util.List<Resettable> toResetAfterReload)
-
-
-
Field Detail
-
DEFAULT_VIEW_ZUL
public static final java.lang.String DEFAULT_VIEW_ZUL
- See Also:
- Constant Field Values
-
NO_VIEW_ZUL
public static final java.lang.String NO_VIEW_ZUL
- See Also:
- Constant Field Values
-
PROPERTY_WIDGET_LIBRARY_BLACKLIST
public static final java.lang.String PROPERTY_WIDGET_LIBRARY_BLACKLIST
- See Also:
- Constant Field Values
-
-
Method Detail
-
getStubWidgetDefinitions
public java.util.Map<java.lang.String,WidgetDefinition> getStubWidgetDefinitions()
Description copied from interface:CockpitComponentDefinitionServiceReturns all stub widget definitions that were registered for 'non-widget' aware components- Specified by:
getStubWidgetDefinitionsin interfaceCockpitComponentDefinitionService- Returns:
- all stub widget definitions
-
createAutowiredComponent
public <T> T createAutowiredComponent(AbstractCockpitComponentDefinition root, java.lang.String className, org.springframework.context.ApplicationContext context) throws java.lang.ReflectiveOperationException
Description copied from interface:CockpitComponentDefinitionServiceCreates autowired component- Specified by:
createAutowiredComponentin interfaceCockpitComponentDefinitionService- Type Parameters:
T- type of created component- Parameters:
root- component definitionclassName- class of the component to be createdcontext- Spring application context from which the dependencies should be wired; if null the dependencies are not wired only the instance is created- Returns:
- component with wired dependencies
- Throws:
java.lang.ReflectiveOperationException- when it is impossible to create instance of class of given name
-
createAutowiredComponent
public <T> T createAutowiredComponent(AbstractCockpitComponentDefinition root, java.lang.String className, org.springframework.context.ApplicationContext context, boolean cachedInstance) throws java.lang.ReflectiveOperationException
Description copied from interface:CockpitComponentDefinitionServiceCreates autowired component- Specified by:
createAutowiredComponentin interfaceCockpitComponentDefinitionService- Type Parameters:
T- type of created component- Parameters:
root- component definitionclassName- class of the component to be createdcontext- Spring application context from which the dependencies should be wired; if null the dependencies are not wired only the instance is createdcachedInstance- if true the created object will be cached; for stateful objects the parameter should be false- Returns:
- component with wired dependencies
- Throws:
java.lang.ReflectiveOperationException- when it is impossible to create instance of class of given name
-
createClassInstance
protected <T> T createClassInstance(org.springframework.context.ApplicationContext context, java.lang.Class clazz) throws java.lang.InstantiationException, java.lang.IllegalAccessException- Throws:
java.lang.InstantiationExceptionjava.lang.IllegalAccessException
-
getAllComponentDefinitions
public java.util.List<AbstractCockpitComponentDefinition> getAllComponentDefinitions()
Description copied from interface:CockpitComponentDefinitionServiceProvides all component definitions available in the system.- Specified by:
getAllComponentDefinitionsin interfaceCockpitComponentDefinitionService- Returns:
- all component definitions available in the system
-
getComponentDefinitionsByClass
public <T extends AbstractCockpitComponentDefinition> java.util.List<T> getComponentDefinitionsByClass(java.lang.Class<T> componentType)
Description copied from interface:CockpitComponentDefinitionServiceProvides all component definitions of given type.- Specified by:
getComponentDefinitionsByClassin interfaceCockpitComponentDefinitionService- Parameters:
componentType- class of component- Returns:
- all component definitions available in the system
-
getComponentDefinitionForCode
public AbstractCockpitComponentDefinition getComponentDefinitionForCode(java.lang.String code)
Description copied from interface:CockpitComponentDefinitionServiceLooks for a component definition with the given Editor code (example: 'com.hybris.cockpitng.editor.defaulttext')- Specified by:
getComponentDefinitionForCodein interfaceCockpitComponentDefinitionService- Parameters:
code- the code of the component definition to be found- Returns:
- the component definition with the given code
-
getComponentDefinitionForCode
public <T extends AbstractCockpitComponentDefinition> T getComponentDefinitionForCode(java.lang.String code, java.lang.Class<T> componentType)
Description copied from interface:CockpitComponentDefinitionServiceLooks for a component definition with the given code.- Specified by:
getComponentDefinitionForCodein interfaceCockpitComponentDefinitionService- Parameters:
code- the code of the component definition to be foundcomponentType- the expected class of the definition- Returns:
- the component definition with the given code
-
getExtensionsDefinitions
public java.util.Collection<AbstractCockpitComponentDefinition> getExtensionsDefinitions()
Description copied from interface:CockpitComponentDefinitionServiceGet components definitions for extensions.- Specified by:
getExtensionsDefinitionsin interfaceCockpitComponentDefinitionService
-
setDefinitionFactories
public void setDefinitionFactories(java.util.Map<java.lang.String,CockpitComponentDefinitionFactory> factories)
-
reloadDefinitions
public void reloadDefinitions()
Description copied from interface:CockpitComponentDefinitionServiceReloads all component definitions.- Specified by:
reloadDefinitionsin interfaceCockpitComponentDefinitionService
-
loadDefinitions
protected void loadDefinitions()
-
processComponentInfo
protected void processComponentInfo(CockpitComponentInfo info, java.util.Collection<java.lang.String> widgetBlacklist, java.util.function.Predicate<AbstractCockpitComponentDefinition> definitionTest)
-
loadDefinitionForComponentInfo
protected java.util.Optional<AbstractCockpitComponentDefinition> loadDefinitionForComponentInfo(CockpitComponentInfo info, java.util.Collection<java.lang.String> widgetBlacklist)
-
isBlacklisted
protected boolean isBlacklisted(AbstractCockpitComponentDefinition definition, java.util.Collection<java.lang.String> blacklist)
-
fetchWidgetBlacklist
protected java.util.Collection<java.lang.String> fetchWidgetBlacklist()
-
isDuplicate
protected boolean isDuplicate(AbstractCockpitComponentDefinition definition)
-
clearDefinitions
public void clearDefinitions()
Description copied from interface:CockpitComponentDefinitionServiceClears components definitions.- Specified by:
clearDefinitionsin interfaceCockpitComponentDefinitionService
-
registerWidgetStubDefinitions
protected void registerWidgetStubDefinitions(AbstractCockpitComponentDefinition definition)
-
beforeCreateDefinition
protected void beforeCreateDefinition(CockpitComponentInfo info)
Override to do manipulations to component info before creation of definition- Parameters:
info-
-
loadInfos
protected java.util.Set<CockpitComponentInfo> loadInfos(CockpitComponentLoader loader)
-
processInheritanceHierarchy
protected void processInheritanceHierarchy()
-
fillInheritedFields
protected void fillInheritedFields(WidgetDefinition definition)
-
processExtensions
protected void processExtensions()
-
fillInheritedDefinition
protected void fillInheritedDefinition(WidgetDefinition definition, WidgetDefinition extension, java.util.function.Predicate<java.util.function.Function<WidgetDefinition,?>> overrideCheck)
-
fillInheritedSettings
protected TypedSettingsMap fillInheritedSettings(WidgetDefinition override, WidgetDefinition base)
-
inheritFieldValue
protected <T> void inheritFieldValue(WidgetDefinition definition, WidgetDefinition extension, java.util.function.Predicate<java.util.function.Function<WidgetDefinition,?>> overrideCheck, java.util.function.Function<WidgetDefinition,T> getter, java.util.function.Consumer<T> setter)
-
checkIfEmpty
protected boolean checkIfEmpty(WidgetDefinition target, java.util.function.Function<WidgetDefinition,?> override)
-
getFactoryForInfo
protected java.util.Optional<CockpitComponentDefinitionFactory> getFactoryForInfo(CockpitComponentInfo info)
-
getClassLoader
@Deprecated(since="1808", forRemoval=true) public java.lang.ClassLoader getClassLoader(AbstractCockpitComponentDefinition definition)Deprecated, for removal: This API element is subject to removal in a future version.since 1808, please useCockpitApplicationContext.getClassLoader()- Specified by:
getClassLoaderin interfaceCockpitComponentDefinitionService- See Also:
CockpitApplicationContext.getCockpitApplicationContext(ApplicationContext)
-
getDefinitionLoaders
public java.util.List<CockpitComponentLoader> getDefinitionLoaders()
- Returns:
- the definitionLoaders
-
setDefinitionLoaders
public void setDefinitionLoaders(java.util.List<CockpitComponentLoader> definitionLoaders)
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext(AbstractCockpitComponentDefinition definition)
- Specified by:
getApplicationContextin interfaceCockpitComponentDefinitionService- See Also:
CockpitApplicationContext.getCockpitApplicationContext(ApplicationContext)
-
getApplicationContext
protected CockpitApplicationContext getApplicationContext()
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext ctx)
- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
getCockpitProperties
public CockpitProperties getCockpitProperties()
-
setCockpitProperties
public void setCockpitProperties(CockpitProperties cockpitProperties)
-
setToResetAfterReload
public void setToResetAfterReload(java.util.List<Resettable> toResetAfterReload)
-
-