Top Description Fields Constructors Methods
org.springframework.jndi

public Class JndiPropertySource

extends PropertySource<JndiLocatorDelegate>
Class Inheritance
Imports
javax.naming.NamingException, org.springframework.core.env.PropertySource, org.springframework.lang.Nullable

PropertySource implementation that reads properties from an underlying Spring JndiLocatorDelegate.

By default, the underlying JndiLocatorDelegate will be configured with its "resourceRef" property set to true, meaning that names looked up will automatically be prefixed with "java:comp/env/" in alignment with published JNDI naming conventions. To override this setting or to change the prefix, manually configure a JndiLocatorDelegate and provide it to one of the constructors here that accepts it. The same applies when providing custom JNDI properties. These should be specified using JndiLocatorDelegate#setJndiEnvironment(java.util.Properties) prior to construction of the JndiPropertySource.

Note that StandardServletEnvironment includes a JndiPropertySource by default, and any customization of the underlying JndiLocatorDelegate may be performed within an ApplicationContextInitializer or WebApplicationInitializer.

Authors
Chris Beams, Juergen Hoeller
Since
3.1
See Also
JndiLocatorDelegate, org.springframework.context.ApplicationContextInitializer, org.springframework.web.WebApplicationInitializer, org.springframework.web.context.support.StandardServletEnvironment

Field Summary

Inherited from org.springframework.core.env.PropertySource:
loggernamesource

Constructor Summary

AccessConstructor and Description
public
JndiPropertySource(String name)

Create a new JndiPropertySource with the given name and a JndiLocatorDelegate configured to prefix any names with "java:comp/env/".

public
JndiPropertySource(String name, JndiLocatorDelegate jndiLocator)

Create a new JndiPropertySource with the given name and the given JndiLocatorDelegate.

Method Summary

Modifier and TypeMethod and Description
public Object
getProperty(String
the property to find
name
)

Implements abstract org.springframework.core.env.PropertySource.getProperty.

This implementation looks up and returns the value associated with the given name from the underlying JndiLocatorDelegate.

Inherited from org.springframework.core.env.PropertySource:
containsPropertyequalsgetNamegetSourcehashCodenamedtoString

Constructor Detail

JndiPropertySourceback to summary
public JndiPropertySource(String name)

Create a new JndiPropertySource with the given name and a JndiLocatorDelegate configured to prefix any names with "java:comp/env/".

JndiPropertySourceback to summary
public JndiPropertySource(String name, JndiLocatorDelegate jndiLocator)

Create a new JndiPropertySource with the given name and the given JndiLocatorDelegate.

Method Detail

getPropertyback to summary
public Object getProperty(String name)

Implements abstract org.springframework.core.env.PropertySource.getProperty.

This implementation looks up and returns the value associated with the given name from the underlying JndiLocatorDelegate. If a NamingException is thrown during the call to JndiLocatorDelegate#lookup(String), returns null and issues a DEBUG-level log statement with the exception message.

Parameters
name:String

Doc from org.springframework.core.env.PropertySource.getProperty.

the property to find

Annotations
@Override
@Nullable