Class JndiPropertySource
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 JndiAccessor.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.
- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.core.env.PropertySourcePropertySource.StubPropertySource
- 
Field SummaryFields inherited from class org.springframework.core.env.PropertySourcelogger, name, source
- 
Constructor SummaryConstructorsConstructorDescriptionJndiPropertySource(String name) Create a newJndiPropertySourcewith the given name and aJndiLocatorDelegateconfigured to prefix any names with "java:comp/env/".JndiPropertySource(String name, JndiLocatorDelegate jndiLocator) Create a newJndiPropertySourcewith the given name and the givenJndiLocatorDelegate.
- 
Method SummaryModifier and TypeMethodDescriptiongetProperty(String name) This implementation looks up and returns the value associated with the given name from the underlyingJndiLocatorDelegate.Methods inherited from class org.springframework.core.env.PropertySourcecontainsProperty, equals, getName, getSource, hashCode, named, toString
- 
Constructor Details- 
JndiPropertySourceCreate a newJndiPropertySourcewith the given name and aJndiLocatorDelegateconfigured to prefix any names with "java:comp/env/".
- 
JndiPropertySourceCreate a newJndiPropertySourcewith the given name and the givenJndiLocatorDelegate.
 
- 
- 
Method Details- 
getPropertyThis implementation looks up and returns the value associated with the given name from the underlyingJndiLocatorDelegate. If aNamingExceptionis thrown during the call toJndiLocatorDelegate.lookup(String), returnsnulland issues a DEBUG-level log statement with the exception message.- Specified by:
- getPropertyin class- PropertySource<JndiLocatorDelegate>
- Parameters:
- name- the property to find
- See Also:
 
 
-