org.springframework.osgi.compendium.cm
Class ConfigAdminPropertiesFactoryBean

java.lang.Object
  extended by org.springframework.osgi.compendium.cm.ConfigAdminPropertiesFactoryBean
All Implemented Interfaces:
DisposableBean, FactoryBean<Properties>, InitializingBean, BundleContextAware

public class ConfigAdminPropertiesFactoryBean
extends Object
implements BundleContextAware, InitializingBean, DisposableBean, FactoryBean<Properties>

FactoryBean returning the properties stored under a given persistent id in the ConfigurationAdmin service. Once retrieved, the properties will remain the same, even when the configuration object that it maps, changes. Note: This implementation performs a lazy initialization of the properties to receive the most up to date configuration.

Author:
Costin Leau
See Also:
Configuration, ConfigurationAdmin, PropertiesFactoryBean

Constructor Summary
ConfigAdminPropertiesFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 Properties getObject()
           
 Class<? extends Properties> getObjectType()
           
 String getPersistentId()
          Returns the persistentId.
 boolean isDynamic()
          Indicates whether the returned properties object is dynamic or not.
 boolean isSingleton()
           
 void setBundleContext(BundleContext bundleContext)
          Set the BundleContext that this bean runs in.
 void setDynamic(boolean dynamic)
          Indicates if the returned configuration is dynamic or static.
 void setLocalOverride(boolean localOverride)
          Sets whether local properties override properties from files.
 void setPersistentId(String persistentId)
          Sets the ConfigurationAdmin persistent Id that the bean should read.
 void setProperties(Properties properties)
          Sets the local properties, e.g. via the nested tag in XML bean definitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigAdminPropertiesFactoryBean

public ConfigAdminPropertiesFactoryBean()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

getObject

public Properties getObject()
                     throws Exception
Specified by:
getObject in interface FactoryBean<Properties>
Throws:
Exception

getObjectType

public Class<? extends Properties> getObjectType()
Specified by:
getObjectType in interface FactoryBean<Properties>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean<Properties>

getPersistentId

public String getPersistentId()
Returns the persistentId.

Returns:
Returns the persistentId

setPersistentId

public void setPersistentId(String persistentId)
Sets the ConfigurationAdmin persistent Id that the bean should read.

Parameters:
persistentId - The persistentId to set.

setProperties

public void setProperties(Properties properties)
Sets the local properties, e.g. via the nested tag in XML bean definitions. These can be considered defaults, to be overridden by properties loaded from the Configuration Admin.


setLocalOverride

public void setLocalOverride(boolean localOverride)
Sets whether local properties override properties from files.

Default is "false": Properties from the Configuration Admin override local defaults. Can be switched to "true" to let local properties override the Configuration Admin properties.


setBundleContext

public void setBundleContext(BundleContext bundleContext)
Description copied from interface: BundleContextAware
Set the BundleContext that this bean runs in. Normally this can be used to initialize an object.

Specified by:
setBundleContext in interface BundleContextAware
Parameters:
bundleContext - the BundleContext object to be used by this object

isDynamic

public boolean isDynamic()
Indicates whether the returned properties object is dynamic or not.

Returns:
boolean indicating if the configuration object is dynamic

setDynamic

public void setDynamic(boolean dynamic)
Indicates if the returned configuration is dynamic or static. A static configuration (default) ignores any updates made to the configuration admin entry that it maps. A dynamic configuration on the other hand will reflect the changes in its content. Third parties can be notified through the ServicePropertiesChangeListener contract.

Parameters:
dynamic - whether the returned object reflects the changes in the configuration admin or not.


Copyright © 2006-2009 Spring Framework. All Rights Reserved.