类 JndiLocatorSupport
- java.lang.Object
- org.springframework.jndi.JndiAccessor
- org.springframework.jndi.JndiLocatorSupport
- 直接已知子类:
ContextJndiBeanFactoryLocator
,JndiDataSourceLookup
,JndiDestinationResolver
,JndiLocatorDelegate
,JndiObjectLocator
,SimpleJndiBeanFactory
,TimerManagerAccessor
,WorkManagerTaskExecutor
,WorkManagerTaskExecutor
public abstract class JndiLocatorSupport extends JndiAccessor
Convenient superclass for classes that can locate any number of JNDI objects. Derives from JndiAccessor to inherit the "jndiTemplate" and "jndiEnvironment" bean properties.JNDI names may or may not include the "java:comp/env/" prefix expected by J2EE applications when accessing a locally mapped (ENC - Environmental Naming Context) resource. If it doesn't, the "java:comp/env/" prefix will be prepended if the "resourceRef" property is true (the default is false) and no other scheme (e.g. "java:") is given.
- 从以下版本开始:
- 1.1
- 作者:
- Juergen Hoeller
- 另请参阅:
JndiAccessor.setJndiTemplate(org.springframework.jndi.JndiTemplate)
,JndiAccessor.setJndiEnvironment(java.util.Properties)
,setResourceRef(boolean)
字段概要
字段 修饰符和类型 字段 说明 static String
CONTAINER_PREFIX
JNDI prefix used in a J2EE container从类继承的字段 org.springframework.jndi.JndiAccessor
logger
构造器概要
构造器 构造器 说明 JndiLocatorSupport()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected String
convertJndiName(String jndiName)
Convert the given JNDI name into the actual JNDI name to use.boolean
isResourceRef()
Return whether the lookup occurs in a J2EE container.protected Object
lookup(String jndiName)
Perform an actual JNDI lookup for the given name via the JndiTemplate.protected <T> T
lookup(String jndiName, Class<T> requiredType)
Perform an actual JNDI lookup for the given name via the JndiTemplate.void
setResourceRef(boolean resourceRef)
Set whether the lookup occurs in a J2EE container, i.e. if the prefix "java:comp/env/" needs to be added if the JNDI name doesn't already contain it.从类继承的方法 org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
字段详细资料
CONTAINER_PREFIX
public static final String CONTAINER_PREFIX
JNDI prefix used in a J2EE container- 另请参阅:
- 常量字段值
构造器详细资料
JndiLocatorSupport
public JndiLocatorSupport()
方法详细资料
setResourceRef
public void setResourceRef(boolean resourceRef)
Set whether the lookup occurs in a J2EE container, i.e. if the prefix "java:comp/env/" needs to be added if the JNDI name doesn't already contain it. Default is "false".Note: Will only get applied if no other scheme (e.g. "java:") is given.
isResourceRef
public boolean isResourceRef()
Return whether the lookup occurs in a J2EE container.
lookup
protected Object lookup(String jndiName) throws NamingException
Perform an actual JNDI lookup for the given name via the JndiTemplate.If the name doesn't begin with "java:comp/env/", this prefix is added if "resourceRef" is set to "true".
- 参数:
jndiName
- the JNDI name to look up- 返回:
- the obtained object
- 抛出:
NamingException
- if the JNDI lookup failed- 另请参阅:
setResourceRef(boolean)
lookup
protected <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException
Perform an actual JNDI lookup for the given name via the JndiTemplate.If the name doesn't begin with "java:comp/env/", this prefix is added if "resourceRef" is set to "true".
- 参数:
jndiName
- the JNDI name to look uprequiredType
- the required type of the object- 返回:
- the obtained object
- 抛出:
NamingException
- if the JNDI lookup failed- 另请参阅:
setResourceRef(boolean)
convertJndiName
protected String convertJndiName(String jndiName)
Convert the given JNDI name into the actual JNDI name to use.The default implementation applies the "java:comp/env/" prefix if "resourceRef" is "true" and no other scheme (e.g. "java:") is given.
- 参数:
jndiName
- the original JNDI name- 返回:
- the JNDI name to use
- 另请参阅:
CONTAINER_PREFIX
,setResourceRef(boolean)