org.springframework.jndi
Class JndiPropertySource

java.lang.Object
  extended by org.springframework.core.env.PropertySource<Context>
      extended by org.springframework.jndi.JndiPropertySource

public class JndiPropertySource
extends PropertySource<Context>

PropertySource implementation that reads properties from a JNDI Context.

Since:
3.1
Author:
Chris Beams, Juergen Hoeller
See Also:
Context.lookup(String), DefaultWebEnvironment

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource
PropertySource.StubPropertySource
 
Field Summary
static String JNDI_PROPERTY_SOURCE_ENABLED_FLAG
          Name of property used to determine if a JndiPropertySource should be registered by default: "jndiPropertySourceEnabled"
static String JNDI_PROPERTY_SOURCE_NAME
          JNDI context property source name: "jndiPropertySource"
 
Fields inherited from class org.springframework.core.env.PropertySource
logger, name, source
 
Constructor Summary
JndiPropertySource()
          Create a new JndiPropertySource with the default name "jndiPropertySource" and create a new InitialContext as the source object.
JndiPropertySource(String name)
          Create a new JndiPropertySource with the given name and create a new InitialContext as the source object.
JndiPropertySource(String name, Context source)
          Create a new JndiPropertySource with the given name and JNDI Context.
JndiPropertySource(String name, Properties jndiEnvironment)
          Create a new JndiPropertySource with the given name and use the given jndiEnvironment properties to create a new InitialContext as the source object.
 
Method Summary
 Object getProperty(String name)
          Look up and return the given name from the source JNDI Context.
 
Methods inherited from class org.springframework.core.env.PropertySource
containsProperty, equals, getName, getSource, hashCode, named, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

JNDI_PROPERTY_SOURCE_NAME

public static final String JNDI_PROPERTY_SOURCE_NAME
JNDI context property source name: "jndiPropertySource"

See Also:
Constant Field Values

JNDI_PROPERTY_SOURCE_ENABLED_FLAG

public static final String JNDI_PROPERTY_SOURCE_ENABLED_FLAG
Name of property used to determine if a JndiPropertySource should be registered by default: "jndiPropertySourceEnabled"

See Also:
Constant Field Values
Constructor Detail

JndiPropertySource

public JndiPropertySource()
                   throws JndiLookupFailureException
Create a new JndiPropertySource with the default name "jndiPropertySource" and create a new InitialContext as the source object.

Throws:
JndiLookupFailureException - if a new InitialContext cannot be created.

JndiPropertySource

public JndiPropertySource(String name)
                   throws JndiLookupFailureException
Create a new JndiPropertySource with the given name and create a new InitialContext as the source object.

Throws:
JndiLookupFailureException - if a new InitialContext cannot be created.

JndiPropertySource

public JndiPropertySource(String name,
                          Properties jndiEnvironment)
                   throws JndiLookupFailureException
Create a new JndiPropertySource with the given name and use the given jndiEnvironment properties to create a new InitialContext as the source object.

Throws:
JndiLookupFailureException - if a new InitialContext cannot be created.

JndiPropertySource

public JndiPropertySource(String name,
                          Context source)
Create a new JndiPropertySource with the given name and JNDI Context.

Method Detail

getProperty

public Object getProperty(String name)
                   throws JndiLookupFailureException
Look up and return the given name from the source JNDI Context.

Specified by:
getProperty in class PropertySource<Context>
Parameters:
name - the property key to find
Throws:
JndiLookupFailureException
See Also:
PropertyResolver.getRequiredProperty(String)