public abstract class AbstractPropertyBackedBean extends Object implements PropertyBackedBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.BeanNameAware
PropertyBackedBean
s. Gets its category from its Spring bean name and automatically
propagates and resolves property defaults on initialization. Automatically destroys itself on server shutdown.
Communicates its creation and destruction and start and stop events to a PropertyBackedBeanRegistry
. Listens
for start and stop events from remote nodes in order to keep the bean in sync with edits made on a remote node. On
receiving a start event from a remote node, the bean is completely reinitialized, allowing it to be resynchronized
with any persisted changes.Modifier and Type | Class and Description |
---|---|
class |
AbstractPropertyBackedBean.DefaultResolver
Uses a Spring
PropertyPlaceholderHelper to resolve placeholders in the property defaults. |
protected static class |
AbstractPropertyBackedBean.RuntimeState
The lifecycle states.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_INSTANCE_NAME
The default final part of an ID.
|
protected ReentrantReadWriteLock |
lock
Lock for concurrent access.
|
protected AbstractPropertyBackedBean.RuntimeState |
runtimeState |
Constructor and Description |
---|
AbstractPropertyBackedBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected void |
applyDefaultOverrides(PropertyBackedBeanState state)
Applies default overrides to the initial state.
|
protected abstract PropertyBackedBeanState |
createInitialState()
Creates the initial state.
|
void |
destroy() |
protected void |
destroy(boolean isPermanent)
Releases any resources held by this component.
|
protected void |
doInit()
Initializes or resets the bean and its state.
|
protected String |
getCategory()
Gets the category.
|
String |
getDescription(String name)
Gets a Human readable description of the property, e.g.
|
protected Properties |
getEncryptedPropertyDefaults() |
List<String> |
getId()
Gets a unique identifier for the bean.
|
protected List<String> |
getInstancePath()
Gets the hierarchical instance path within the category (second part of the ID).
|
protected org.springframework.context.ApplicationContext |
getParent()
Gets the parent application context.
|
String |
getProperty(String name)
Gets a property value.
|
protected Properties |
getPropertyDefaults()
Gets the property defaults provided by the installer or System properties.
|
Set<String> |
getPropertyNames()
Gets the names of all properties.
|
protected PropertyBackedBeanRegistry |
getRegistry()
Gets the registry of all property backed beans.
|
protected PropertyBackedBeanState |
getState(boolean start)
Gets the state.
|
void |
init()
Initializes or resets the bean and its state.
|
boolean |
isUpdateable(String name)
Checks if a property is updateable.
|
void |
onApplicationEvent(org.springframework.context.ApplicationEvent event) |
String |
performEarlyPropertyChecks(Map<String,String> properties)
Check properties for invalid values using
SubsystemEarlyPropertyChecker s |
void |
removeProperties(Collection<String> properties)
Removes properties added by code within the local node.
|
void |
removeProperty(String name)
Removes a property added by code within the local node.
|
protected String |
resolveDefault(String name)
Resolves the default value of a property, if there is one, expanding placholders as necessary.
|
void |
revert()
Reverts this component to its original default start state, removing any previously persisted state changes.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setAutoStart(boolean autoStart)
Indicates whether the bean should be started on startup of the parent application context.
|
void |
setBeanName(String name) |
void |
setCategory(String category)
Sets the category (first part of the ID).
|
void |
setEarlyPropertyCheckers(Map<String,SubsystemEarlyPropertyChecker> earlyPropertyCheckers) |
void |
setEncryptedPropertyDefaults(Properties propertyDefaults) |
void |
setInstancePath(List<String> instancePath)
Sets the hierarchical instance path within the category (second part of the ID)..
|
void |
setProperties(Map<String,String> properties)
Tries setting the given properties on this component.
|
void |
setProperty(String name,
String value)
Sets the value of a property.
|
void |
setPropertyDefaults(Properties propertyDefaults)
Sets the property defaults provided by the installer or System properties.
|
void |
setRegistry(PropertyBackedBeanRegistry registry)
Sets the registry of all property backed beans.
|
void |
setSaveSetProperty(boolean saveSetProperty)
When set to true, calls to setProperties / setProperty are persisted to the MBean if it exists.
|
void |
start()
Starts up the component, using its new property values.
|
protected void |
start(boolean broadcastNow,
boolean broadcastLater)
Starts the bean, optionally broadcasting the event to remote nodes.
|
void |
stop()
Stops the component, so that its property values can be changed.
|
protected void |
stop(boolean broadcast)
Stops the bean, optionally broadcasting the event to remote nodes.
|
protected static final String DEFAULT_INSTANCE_NAME
protected AbstractPropertyBackedBean.RuntimeState runtimeState
protected ReentrantReadWriteLock lock
public void setEarlyPropertyCheckers(Map<String,SubsystemEarlyPropertyChecker> earlyPropertyCheckers)
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public void setRegistry(PropertyBackedBeanRegistry registry)
registry
- the registry of all property backed beansprotected PropertyBackedBeanRegistry getRegistry()
public void setBeanName(String name)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void setCategory(String category)
category
- the categorypublic void setInstancePath(List<String> instancePath)
instancePath
- the instance pathpublic void setAutoStart(boolean autoStart)
autoStart
- true
if the bean should be started on startup of the parent application contextpublic void setPropertyDefaults(Properties propertyDefaults)
propertyDefaults
- the property defaultspublic void setEncryptedPropertyDefaults(Properties propertyDefaults)
protected Properties getPropertyDefaults()
protected Properties getEncryptedPropertyDefaults()
protected String resolveDefault(String name)
name
- the property namenull
if there isn't oneprotected org.springframework.context.ApplicationContext getParent()
protected PropertyBackedBeanState getState(boolean start)
start
- are we making use of the state? I.e. should we start it if it has not been already?public void setSaveSetProperty(boolean saveSetProperty)
public String performEarlyPropertyChecks(Map<String,String> properties)
SubsystemEarlyPropertyChecker
sproperties
- public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public final void init()
protected void doInit()
public final void revert()
revert
in interface PropertyBackedBean
protected abstract PropertyBackedBeanState createInitialState() throws IOException
IOException
- Signals that an I/O exception has occurred.protected void applyDefaultOverrides(PropertyBackedBeanState state) throws IOException
state
- the stateIOException
- Signals that an I/O exception has occurred.public List<String> getId()
getId
in interface PropertyBackedBean
protected String getCategory()
protected List<String> getInstancePath()
public final void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean
protected void destroy(boolean isPermanent)
isPermanent
- is the component being destroyed forever, i.e. should persisted values be removed? On server shutdown,
this value would be false
, whereas on the removal of a dynamically created instance, this
value would be true
.public boolean isUpdateable(String name)
isUpdateable
in interface PropertyBackedBean
name
- the property nametrue
if the property is updateablepublic String getDescription(String name)
getDescription
in interface PropertyBackedBean
name
- the namepublic void onApplicationEvent(org.springframework.context.ApplicationEvent event)
onApplicationEvent
in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
public String getProperty(String name)
getProperty
in interface PropertyBackedBeanState
name
- the namepublic Set<String> getPropertyNames()
getPropertyNames
in interface PropertyBackedBeanState
public void setProperty(String name, String value)
PropertyBackedBeanState.stop()
.
When called from code within the local node the values are saved to the database in the Enterprise edition and will be visible in a JMX client.
setProperty
in interface PropertyBackedBeanState
name
- value
- public void setProperties(Map<String,String> properties)
PropertyBackedBeanState.start()
, presumably after persistence of the new state has been
completed.
When called from code within the local node the values are saved to the database in the Enterprise edition and will be visible in a JMX client.
setProperties
in interface PropertyBackedBean
properties
- to be saved.public void removeProperty(String name)
removeProperty
in interface PropertyBackedBeanState
name
- to be removed.public void removeProperties(Collection<String> properties)
removeProperties
in interface PropertyBackedBean
properties
- to be removed.public final void start()
start
in interface PropertyBackedBeanState
protected void start(boolean broadcastNow, boolean broadcastLater)
broadcastNow
- Should the event be broadcast immediately?broadcastLater
- Should the event be broadcast ever?public final void stop()
stop
in interface PropertyBackedBeanState
protected void stop(boolean broadcast)
broadcast
- Should the event be broadcast?Copyright © 2005–2017 Alfresco Software. All rights reserved.