org.apache.cocoon.spring.configurator.impl
Class AbstractSettingsBeanFactoryPostProcessor

java.lang.Object
  extended by org.springframework.core.io.support.PropertiesLoaderSupport
      extended by org.springframework.beans.factory.config.PropertyResourceConfigurer
          extended by org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
              extended by org.apache.cocoon.spring.configurator.impl.AbstractSettingsBeanFactoryPostProcessor
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, BeanFactoryPostProcessor, FactoryBean, ResourceLoaderAware, Ordered, PriorityOrdered, ServletContextAware
Direct Known Subclasses:
ChildSettingsBeanFactoryPostProcessor, SettingsBeanFactoryPostProcessor

public abstract class AbstractSettingsBeanFactoryPostProcessor
extends PropertyPlaceholderConfigurer
implements ServletContextAware, ResourceLoaderAware, FactoryBean

This is a bean factory post processor which handles all the settings stuff for Cocoon. It reads in all properties files and replaces references to them in the spring configuration files. In addition this bean acts as a factory bean providing the settings object.

Since:
1.0
Version:
$Id: AbstractSettingsBeanFactoryPostProcessor.java 677626 2008-07-17 16:06:10Z gkossakowski $
See Also:
SettingsBeanFactoryPostProcessor, ChildSettingsBeanFactoryPostProcessor

Nested Class Summary
protected  class AbstractSettingsBeanFactoryPostProcessor.CocoonSettingsResolvingBeanDefinitionVisitor
           
 
Field Summary
protected  Properties additionalProperties
          Additional properties.
protected  BeanFactory beanFactory
           
protected  List directories
          List of additional property directories.
protected  Log logger
          Logger (we use the same logging mechanism as Spring!)
protected  ResourceFilter resourceFilter
           
protected  ResourceLoader resourceLoader
           
protected  javax.servlet.ServletContext servletContext
           
protected  org.apache.cocoon.configuration.MutableSettings settings
           
 
Fields inherited from class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, SYSTEM_PROPERTIES_MODE_FALLBACK, SYSTEM_PROPERTIES_MODE_NEVER, SYSTEM_PROPERTIES_MODE_OVERRIDE
 
Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
XML_FILE_EXTENSION
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractSettingsBeanFactoryPostProcessor()
           
 
Method Summary
protected  org.apache.cocoon.configuration.MutableSettings createMutableSettingsInstance()
          Create a new settings object.
protected  org.apache.cocoon.configuration.MutableSettings createSettings()
          Create a settings object.
protected  void dumpSettings()
          Dump the settings object
protected  String getNameForPropertyProvider()
           
 Object getObject()
           
 Class getObjectType()
           
protected  org.apache.cocoon.configuration.Settings getParentSettings()
          Return a parent settings object if available.
protected  ResourceLoader getResourceLoader()
           
protected abstract  String getRunningMode()
          Get the running mode.
protected  String getSystemProperty(String key)
           
protected  String getSystemProperty(String key, String defaultValue)
           
 void init()
          Initialize this processor.
 boolean isSingleton()
           
protected  void postInit(org.apache.cocoon.configuration.MutableSettings s, Properties properties)
          This method can be used by subclasses to initialize the settings and/or the properties after createSettings() did it's work.
protected  void preInit(org.apache.cocoon.configuration.MutableSettings s, Properties properties)
          This method can be used by subclasses to initialize the settings and/or the properties before createSettings() does it's work.
protected  void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
           
protected  String resolvePlaceholder(String placeholder, Properties props)
           
 void setAdditionalProperties(Properties props)
           
 void setBeanFactory(BeanFactory factory)
           
 void setDirectories(List directories)
           
 void setResourceFilter(ResourceFilter resourceFilter)
           
 void setResourceLoader(ResourceLoader loader)
           
 void setServletContext(javax.servlet.ServletContext sContext)
           
 
Methods inherited from class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
parseStringValue, resolvePlaceholder, resolveSystemProperty, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setSearchSystemEnvironment, setSystemPropertiesMode, setSystemPropertiesModeName
 
Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer
convertProperties, convertPropertyValue, getOrder, postProcessBeanFactory, setOrder
 
Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger (we use the same logging mechanism as Spring!)


servletContext

protected javax.servlet.ServletContext servletContext

settings

protected org.apache.cocoon.configuration.MutableSettings settings

beanFactory

protected BeanFactory beanFactory

resourceLoader

protected ResourceLoader resourceLoader

resourceFilter

protected ResourceFilter resourceFilter

additionalProperties

protected Properties additionalProperties
Additional properties.


directories

protected List directories
List of additional property directories.

Constructor Detail

AbstractSettingsBeanFactoryPostProcessor

public AbstractSettingsBeanFactoryPostProcessor()
Method Detail

setBeanFactory

public void setBeanFactory(BeanFactory factory)
Specified by:
setBeanFactory in interface BeanFactoryAware
Overrides:
setBeanFactory in class PropertyPlaceholderConfigurer
See Also:
PropertyPlaceholderConfigurer.setBeanFactory(org.springframework.beans.factory.BeanFactory)

setServletContext

public void setServletContext(javax.servlet.ServletContext sContext)
Specified by:
setServletContext in interface ServletContextAware
See Also:
ServletContextAware.setServletContext(javax.servlet.ServletContext)

setResourceLoader

public void setResourceLoader(ResourceLoader loader)
Specified by:
setResourceLoader in interface ResourceLoaderAware
See Also:
ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)

setResourceFilter

public void setResourceFilter(ResourceFilter resourceFilter)

setDirectories

public void setDirectories(List directories)

setAdditionalProperties

public void setAdditionalProperties(Properties props)

init

public void init()
          throws Exception
Initialize this processor. Setup the settings object.

Throws:
Exception

getRunningMode

protected abstract String getRunningMode()
Get the running mode. This method should be implemented by subclasses.


getParentSettings

protected org.apache.cocoon.configuration.Settings getParentSettings()
Return a parent settings object if available.


createMutableSettingsInstance

protected org.apache.cocoon.configuration.MutableSettings createMutableSettingsInstance()
Create a new settings object. If a parent settings object is available a new child settings object is created. Otherwise a new root settings object with the running mode is instantiated.


preInit

protected void preInit(org.apache.cocoon.configuration.MutableSettings s,
                       Properties properties)
This method can be used by subclasses to initialize the settings and/or the properties before createSettings() does it's work.


postInit

protected void postInit(org.apache.cocoon.configuration.MutableSettings s,
                        Properties properties)
This method can be used by subclasses to initialize the settings and/or the properties after createSettings() did it's work.


getNameForPropertyProvider

protected String getNameForPropertyProvider()

createSettings

protected org.apache.cocoon.configuration.MutableSettings createSettings()
Create a settings object. This method creates the settings by executing the following task:
  1. Create a new mutable settings object invoking createMutableSettingsInstance().
  2. Configure the properties and settings object by calling preInit(MutableSettings, Properties).
  3. Invoke a PropertyProvider if configured in the same application context (or its parent)
  4. Add properties from configured directories directories.
  5. Add additional properties configured at additionalProperties
  6. Apply system properties
  7. Configure the properties and settings object by calling postInit(MutableSettings, Properties).
  8. Replace references in properties
  9. Configure the settings object with the properties
  10. Make the settings object read-only.

Returns:
A new Settings object

getResourceLoader

protected ResourceLoader getResourceLoader()

getSystemProperty

protected String getSystemProperty(String key)

getSystemProperty

protected String getSystemProperty(String key,
                                   String defaultValue)

processProperties

protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
                                 Properties props)
                          throws BeansException
Overrides:
processProperties in class PropertyPlaceholderConfigurer
Throws:
BeansException
See Also:
PropertyPlaceholderConfigurer.processProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)

resolvePlaceholder

protected String resolvePlaceholder(String placeholder,
                                    Properties props)
Overrides:
resolvePlaceholder in class PropertyPlaceholderConfigurer
See Also:
PropertyPlaceholderConfigurer.resolvePlaceholder(java.lang.String, java.util.Properties)

dumpSettings

protected void dumpSettings()
Dump the settings object


getObject

public Object getObject()
                 throws Exception
Specified by:
getObject in interface FactoryBean
Throws:
Exception
See Also:
FactoryBean.getObject()

getObjectType

public Class getObjectType()
Specified by:
getObjectType in interface FactoryBean
See Also:
FactoryBean.getObjectType()

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean
See Also:
FactoryBean.isSingleton()


Copyright © 1999-2009 The Apache Software Foundation. All Rights Reserved.