Class ChildApplicationContextFactory
- java.lang.Object
-
- org.alfresco.repo.management.subsystems.AbstractPropertyBackedBean
-
- org.alfresco.repo.management.subsystems.ChildApplicationContextFactory
-
- All Implemented Interfaces:
java.util.EventListener,ApplicationContextFactory,PropertyBackedBean,PropertyBackedBeanState,PropertyBackedBeanWithMonitor,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
- Direct Known Subclasses:
LuceneChildApplicationContextFactory,NoIndexChildApplicationContextFactory,SolrChildApplicationContextFactory
public class ChildApplicationContextFactory extends AbstractPropertyBackedBean implements ApplicationContextFactory, PropertyBackedBeanWithMonitor
A factory allowing initialization of an entire 'subsystem' in a child application context. As with otherPropertyBackedBeans, can be stopped, reconfigured, started and tested. Each instance possesses atypeNameproperty, that determines where the factory will look for default configuration for the application context. In addition, itsidproperty will determine where the factory will look for override configuration in the extension classpath.The factory will search for a Spring application context in the classpath using the following patterns in order:
- alfresco/subsystems/<category>/<typeName>/*-context.xml
- alfresco/extension/subsystems/<category>/<typeName>/<id>/*-context.xml
${}placeholders, and will be configured with aPropertyPlaceholderConfigurerinitialized with properties files found in classpath matching the following patterns in order:- alfresco/subsystems/<category>/<typeName>/*.properties
- alfresco/extension/subsystems/<category>/<typeName>/<id>/*.properties
For advanced purposes, the class also allows management of 'composite' properties, that is properties that can be populated with a sequence of zero or more objects, themselves registered as property-backed beans. Using the
compositePropertyTypesproperty you can register a Map of property names to Java Bean classes. Each property named in this map will then be materialized as a 'composite' property.Composite property settings are best controlled either through a JMX console (Enterprise edition only) or /alfresco-global.properties in the classpath (the replacement to /alfresco/extension/custom-repository.properties). For example, suppose "imap.server.mountPoints" was registered as a composite property of type
RepositoryPathConfigBean. You can then use the property to configure a list ofRepositoryPathConfigBeans. First you specify in the property's value a list of zero or more 'instance names'. Each name must be unique within the property.imap.server.mountPoints=Repository_virtual,Repository_archiveThen, by magic you have two separate instances of
RepositoryPathConfigBeanwhose properties you can address through an extended set of properties prefixed by "imap.server.mountPoints".To set a property on one of the instances, you append ".value.<instance name>.<bean property name>" to the parent property name. For example:
imap.server.mountPoints.value.Repository_virtual.store=${spaces.store}
imap.server.mountPoints.value.Repository_virtual.path=/${spaces.company_home.childname}To specify a default value for a property on all instances of the bean, you append ".default.<bean property name>" to the parent property name. For example:
imap.server.mountPoints.default.store=${spaces.store}
imap.server.mountPoints.default.path=/${spaces.company_home.childname}Note that it's perfectly valid to use placeholders in property values that will be resolved from other global properties.
In order to actually utilize this configurable list of beans in your child application context, you simply need to declare a
ListFactoryBeanwhose ID is the same name as the property. For example:<bean id="imap.server.mountPoints" class="org.springframework.beans.factory.config.ListFactoryBean"> <property name="sourceList"> <!-- Whatever you declare in here will get replaced by the property value list --> <!-- This property is not actually required at all --> </property> </bean>
Then, when the application context is started and before that bean is initialized, it will be given the current configured list of values for the composite property. Magic! This all sounds like a complex, yet primitive replacement for Spring, but it means you can do powerful things to reconfigure the system through an admin UI rather than editing XML.- Author:
- dward
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classChildApplicationContextFactory.ApplicationContextStateThe Class ApplicationContextState.-
Nested classes/interfaces inherited from class org.alfresco.repo.management.subsystems.AbstractPropertyBackedBean
AbstractPropertyBackedBean.DefaultResolver, AbstractPropertyBackedBean.RuntimeState
-
-
Field Summary
-
Fields inherited from class org.alfresco.repo.management.subsystems.AbstractPropertyBackedBean
DEFAULT_INSTANCE_NAME, lock, runtimeState
-
-
Constructor Summary
Constructors Constructor Description ChildApplicationContextFactory()Default constructor for container construction.ChildApplicationContextFactory(org.springframework.context.ApplicationContext parent, PropertyBackedBeanRegistry registry, java.util.Properties propertyDefaults, java.util.Properties encryptedPropertyDefaults, java.lang.String category, java.lang.String typeName, java.util.List<java.lang.String> instancePath)Constructor for dynamically created instances, e.g.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected voidapplyDefaultOverrides(PropertyBackedBeanState state)Applies default overrides to the initial state.protected PropertyBackedBeanStatecreateInitialState()Creates the initial state.protected voiddestroy(boolean permanent)Releases any resources held by this component.org.springframework.context.ApplicationContextgetApplicationContext()Gets the application context, configured according to the properties of the factory.java.lang.StringgetDescription(java.lang.String name)Gets a Human readable description of the property, e.g.java.lang.ObjectgetMonitorObject()Get the monitor object.org.springframework.util.PropertiesPersistergetPersister()org.springframework.context.ApplicationContextgetReadOnlyApplicationContext()Gets the application context.java.lang.StringgetTypeName()Gets the type name.booleanisUpdateable(java.lang.String name)Checks if a property is updateable.voidsetCompositePropertyTypes(java.util.Map<java.lang.String,java.lang.Class<?>> compositePropertyTypes)Registers a set of composite propertes and their types.voidsetPersister(org.springframework.util.PropertiesPersister persister)voidsetTypeName(java.lang.String typeName)Sets the type name.-
Methods inherited from class org.alfresco.repo.management.subsystems.AbstractPropertyBackedBean
destroy, doInit, getCategory, getEncryptedPropertyDefaults, getId, getInstancePath, getParent, getProperty, getPropertyDefaults, getPropertyNames, getRegistry, getState, init, onApplicationEvent, performEarlyPropertyChecks, removeProperties, removeProperty, resolveDefault, revert, setApplicationContext, setAutoStart, setBeanName, setCategory, setEarlyPropertyCheckers, setEncryptedPropertyDefaults, setInstancePath, setProperties, setProperty, setPropertyDefaults, setRegistry, setSaveSetProperty, start, start, stop, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.alfresco.repo.management.subsystems.PropertyBackedBean
getId, removeProperties, revert, setProperties
-
Methods inherited from interface org.alfresco.repo.management.subsystems.PropertyBackedBeanState
getProperty, getPropertyNames, removeProperty, setProperty, start, stop
-
-
-
-
Constructor Detail
-
ChildApplicationContextFactory
public ChildApplicationContextFactory()
Default constructor for container construction.
-
ChildApplicationContextFactory
public ChildApplicationContextFactory(org.springframework.context.ApplicationContext parent, PropertyBackedBeanRegistry registry, java.util.Properties propertyDefaults, java.util.Properties encryptedPropertyDefaults, java.lang.String category, java.lang.String typeName, java.util.List<java.lang.String> instancePath) throws java.io.IOExceptionConstructor for dynamically created instances, e.g. throughDefaultChildApplicationContextManager.- Parameters:
parent- the parent application contextregistry- the registry of property backed beanspropertyDefaults- property defaults provided by the installer or System propertiesencryptedPropertyDefaults- encrypted property defaults provided by the installer or System propertiescategory- the categorytypeName- the type nameinstancePath- the instance path within the category- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
-
Method Detail
-
setTypeName
public void setTypeName(java.lang.String typeName)
Sets the type name.- Parameters:
typeName- the typeName to set
-
getTypeName
public java.lang.String getTypeName()
Gets the type name.- Returns:
- the type name
-
setCompositePropertyTypes
public void setCompositePropertyTypes(java.util.Map<java.lang.String,java.lang.Class<?>> compositePropertyTypes)
Registers a set of composite propertes and their types.- Parameters:
compositePropertyTypes- a map of property names to Java classes. The classes should follow standard Java Bean conventions. If the class implementsBeanNameAwarethe instance name will be propagated to thebeanNameproperty automatically.
-
getPersister
public org.springframework.util.PropertiesPersister getPersister()
- Returns:
- the persister
-
setPersister
public void setPersister(org.springframework.util.PropertiesPersister persister)
- Parameters:
persister- the persister to set
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.ExceptionDescription copied from class:AbstractPropertyBackedBean- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Overrides:
afterPropertiesSetin classAbstractPropertyBackedBean- Throws:
java.lang.Exception
-
createInitialState
protected PropertyBackedBeanState createInitialState() throws java.io.IOException
Description copied from class:AbstractPropertyBackedBeanCreates the initial state.- Specified by:
createInitialStatein classAbstractPropertyBackedBean- Returns:
- the property backed bean state
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
applyDefaultOverrides
protected void applyDefaultOverrides(PropertyBackedBeanState state) throws java.io.IOException
Description copied from class:AbstractPropertyBackedBeanApplies default overrides to the initial state.- Overrides:
applyDefaultOverridesin classAbstractPropertyBackedBean- Parameters:
state- the state- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
isUpdateable
public boolean isUpdateable(java.lang.String name)
Description copied from class:AbstractPropertyBackedBeanChecks if a property is updateable.- Specified by:
isUpdateablein interfacePropertyBackedBean- Overrides:
isUpdateablein classAbstractPropertyBackedBean- Parameters:
name- the property name- Returns:
trueif the property is updateable
-
getDescription
public java.lang.String getDescription(java.lang.String name)
Description copied from class:AbstractPropertyBackedBeanGets a Human readable description of the property, e.g. to provide via JMX.- Specified by:
getDescriptionin interfacePropertyBackedBean- Overrides:
getDescriptionin classAbstractPropertyBackedBean- Parameters:
name- the name- Returns:
- the description
-
destroy
protected void destroy(boolean permanent)
Description copied from class:AbstractPropertyBackedBeanReleases any resources held by this component.- Overrides:
destroyin classAbstractPropertyBackedBean- Parameters:
permanent- is the component being destroyed forever, i.e. should persisted values be removed? On server shutdown, this value would befalse, whereas on the removal of a dynamically created instance, this value would betrue.
-
getReadOnlyApplicationContext
public org.springframework.context.ApplicationContext getReadOnlyApplicationContext()
Gets the application context. Will not start a subsystem.- Returns:
- the application context or null
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()
Description copied from interface:ApplicationContextFactoryGets the application context, configured according to the properties of the factory.- Specified by:
getApplicationContextin interfaceApplicationContextFactory- Returns:
- the application context
-
getMonitorObject
public java.lang.Object getMonitorObject()
Description copied from interface:PropertyBackedBeanWithMonitorGet the monitor object.- Specified by:
getMonitorObjectin interfacePropertyBackedBeanWithMonitor- Returns:
- the monitor object or null if there is no monitor
-
-