ch.elca.el4j.core.config
Class JndiPropertyOverrideConfigurer

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.PropertyOverrideConfigurer
              extended by ch.elca.el4j.core.config.JndiPropertyOverrideConfigurer
All Implemented Interfaces:
BeanFactoryPostProcessor, Ordered, PriorityOrdered

public class JndiPropertyOverrideConfigurer
extends PropertyOverrideConfigurer

This class allows overriding of Spring configurations using JNDI to retrieve values to override. The JNDI entries may be marked with a special prefix or a distinct JNDI context is used, which contains only override properties. This class allows configuring web or EJB applications at deploy time.

This class falls back on the PropertyOverrideConfigurer's behaviour, if there are any JNDI-related problems.

Author:
Andreas Bur (ABU)
See Also:
JndiPropertyPlaceholderConfigurer
File-location:
JndiPropertyOverrideConfigurer
Last check-in date:
2009-08-04 15:13:46 +0200 (Di, 04. Aug 2009) by swismer for revision 3879

Field Summary
static String DEFAULT_KEY_PREFIX
          The default key prefix that signals an override property.
 
Fields inherited from class org.springframework.beans.factory.config.PropertyOverrideConfigurer
DEFAULT_BEAN_NAME_SEPARATOR
 
Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
logger, XML_FILE_EXTENSION
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
JndiPropertyOverrideConfigurer()
           
 
Method Summary
protected  Properties createProperties(NamingEnumeration<NameClassPair> enumeration)
          Iterates over all entries of the given JNDI context and extracts valid configuration override properties.
 JndiConfigurationHelper getJndiPropertyConfigurationgHelper()
           
 String getKeyPrefix()
           
protected  String getPropertyName(String name)
          Computes the configuration property's name.
protected  boolean isConfigProperty(String name)
          Checks whether the given name represents a configuration property.
protected  void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
          
 void setJndiPropertyConfigurationgHelper(JndiConfigurationHelper jndiPropertyConfigurationgHelper)
          Sets the JNDI configuration helper.
 void setKeyPrefix(String keyPrefix)
          Sets the prefix of JNDI resources we're interested in.
 
Methods inherited from class org.springframework.beans.factory.config.PropertyOverrideConfigurer
applyPropertyValue, hasPropertyOverridesFor, processKey, setBeanNameSeparator, setIgnoreInvalidKeys
 
Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer
convertProperties, convertProperty, 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

DEFAULT_KEY_PREFIX

public static final String DEFAULT_KEY_PREFIX
The default key prefix that signals an override property.

See Also:
Constant Field Values
Constructor Detail

JndiPropertyOverrideConfigurer

public JndiPropertyOverrideConfigurer()
Method Detail

getKeyPrefix

public String getKeyPrefix()
Returns:
Returns the prefix of JNDI resources we're interested in.

setKeyPrefix

public void setKeyPrefix(String keyPrefix)
Sets the prefix of JNDI resources we're interested in. Default is springConfig..

Parameters:
keyPrefix - The JNDI name prefix.

getJndiPropertyConfigurationgHelper

public JndiConfigurationHelper getJndiPropertyConfigurationgHelper()
Returns:
Returns the JNDI configuration helper. Default is JndiConfigurationHelper.

setJndiPropertyConfigurationgHelper

public void setJndiPropertyConfigurationgHelper(JndiConfigurationHelper jndiPropertyConfigurationgHelper)
Sets the JNDI configuration helper.

Parameters:
jndiPropertyConfigurationgHelper - The JNDI configuration helper.

processProperties

protected void processProperties(ConfigurableListableBeanFactory beanFactory,
                                 Properties props)
                          throws BeansException

Overrides:
processProperties in class PropertyOverrideConfigurer
Throws:
BeansException

createProperties

protected Properties createProperties(NamingEnumeration<NameClassPair> enumeration)
                               throws NamingException
Iterates over all entries of the given JNDI context and extracts valid configuration override properties.

Parameters:
enumeration - The enumeration of all properties of the given JNDI context.
Returns:
Returns Spring configuration override properties.
Throws:
NamingException - If a naming exception is encountered.

isConfigProperty

protected boolean isConfigProperty(String name)
Checks whether the given name represents a configuration property. This is the case if the prefix of JNDI resources we're interested in is empty (i.e. null or consisting of spaces only) or if the name starts with teh given prefix.

Parameters:
name - The name to check.
Returns:
Returns true if it's a configuration property, false otherwise.

getPropertyName

protected String getPropertyName(String name)
Computes the configuration property's name.

Parameters:
name - A JNDI resource name that is a valid configuration property, i.e. that makes the isConfigProperty(String) resulting in true.
Returns:
Returns the name of the property used to override the Spring configuration.


Copyright © 2005-2011 ELCA. All Rights Reserved.