类 JndiPropertySource
- java.lang.Object
- org.springframework.core.env.PropertySource<JndiLocatorDelegate>
- org.springframework.jndi.JndiPropertySource
public class JndiPropertySource extends PropertySource<JndiLocatorDelegate>
PropertySourceimplementation that reads properties from an underlying SpringJndiLocatorDelegate.By default, the underlying
JndiLocatorDelegatewill 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 aJndiLocatorDelegateand 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
StandardServletEnvironmentincludes aJndiPropertySourceby default, and any customization of the underlyingJndiLocatorDelegatemay be performed within anApplicationContextInitializerorWebApplicationInitializer.- 从以下版本开始:
- 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 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ObjectgetProperty(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 newJndiPropertySourcewith the given name and aJndiLocatorDelegateconfigured to prefix any names with "java:comp/env/".
JndiPropertySource
public JndiPropertySource(String name, JndiLocatorDelegate jndiLocator)
Create a newJndiPropertySourcewith the given name and the givenJndiLocatorDelegate.
方法详细资料
getProperty
@Nullable public Object getProperty(String name)
This 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.- 指定者:
getProperty在类中PropertySource<JndiLocatorDelegate>- 参数:
name- the property to find- 另请参阅:
PropertyResolver.getRequiredProperty(String)