类 JndiPropertySource
- java.lang.Object
- org.springframework.core.env.PropertySource<JndiLocatorDelegate>
- org.springframework.jndi.JndiPropertySource
public class JndiPropertySource extends PropertySource<JndiLocatorDelegate>
PropertySource
implementation that reads properties from an underlying SpringJndiLocatorDelegate
.By default, the underlying
JndiLocatorDelegate
will be configured with its"resourceRef"
property set totrue
, 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 aJndiLocatorDelegate
and provide it to one of the constructors here that accepts it. The same applies when providing custom JNDI properties. These should be specified usingJndiAccessor.setJndiEnvironment(java.util.Properties)
prior to construction of theJndiPropertySource
.Note that
StandardServletEnvironment
includes aJndiPropertySource
by default, and any customization of the underlyingJndiLocatorDelegate
may be performed within anApplicationContextInitializer
orWebApplicationInitializer
.- 从以下版本开始:
- 3.1
- 作者:
- Chris Beams, Juergen Hoeller
- 另请参阅:
JndiLocatorDelegate
,ApplicationContextInitializer
,WebApplicationInitializer
,StandardServletEnvironment
嵌套类概要
从类继承的嵌套类/接口 org.springframework.core.env.PropertySource
PropertySource.StubPropertySource
字段概要
从类继承的字段 org.springframework.core.env.PropertySource
logger, name, source
构造器概要
构造器 构造器 说明 JndiPropertySource(String name)
Create a newJndiPropertySource
with the given name and aJndiLocatorDelegate
configured to prefix any names with "java:comp/env/".JndiPropertySource(String name, JndiLocatorDelegate jndiLocator)
Create a newJndiPropertySource
with the given name and the givenJndiLocatorDelegate
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Object
getProperty(String name)
This implementation looks up and returns the value associated with the given name from the underlyingJndiLocatorDelegate
.从类继承的方法 org.springframework.core.env.PropertySource
containsProperty, equals, getName, getSource, hashCode, named, toString
构造器详细资料
JndiPropertySource
public JndiPropertySource(String name)
Create a newJndiPropertySource
with the given name and aJndiLocatorDelegate
configured to prefix any names with "java:comp/env/".
JndiPropertySource
public JndiPropertySource(String name, JndiLocatorDelegate jndiLocator)
Create a newJndiPropertySource
with the given name and the givenJndiLocatorDelegate
.
方法详细资料
getProperty
public Object getProperty(String name)
This implementation looks up and returns the value associated with the given name from the underlyingJndiLocatorDelegate
. If aNamingException
is thrown during the call toJndiLocatorDelegate.lookup(String)
, returnsnull
and issues a DEBUG-level log statement with the exception message.- 指定者:
getProperty
在类中PropertySource<JndiLocatorDelegate>
- 参数:
name
- the property to find- 另请参阅:
PropertyResolver.getRequiredProperty(String)