org.springframework.jndi.support
Class SimpleJndiBeanFactory
java.lang.Object
org.springframework.jndi.JndiAccessor
org.springframework.jndi.JndiLocatorSupport
org.springframework.jndi.support.SimpleJndiBeanFactory
- All Implemented Interfaces:
- org.springframework.beans.factory.BeanFactory
public class SimpleJndiBeanFactory
- extends JndiLocatorSupport
- implements org.springframework.beans.factory.BeanFactory
Simple JNDI-based implementation of Spring's
BeanFactory
interface.
Does not support enumerating bean definitions, hence doesn't implement
the ListableBeanFactory
interface.
This factory resolves given bean names as JNDI names within the
J2EE application's "java:comp/env/" namespace. It caches the resolved
types for all obtained objects, and optionally also caches shareable
objects (if they are explicitly marked as
shareable resource
.
The main intent of this factory is usage in combination with Spring's
CommonAnnotationBeanPostProcessor
,
configured as "resourceFactory" for resolving @Resource
annotations as JNDI objects without intermediate bean definitions.
It may be used for similar lookup scenarios as well, of course,
in particular if BeanFactory-style type checking is required.
- Since:
- 2.5
- Author:
- Juergen Hoeller
- See Also:
DefaultListableBeanFactory
,
CommonAnnotationBeanPostProcessor
Fields inherited from interface org.springframework.beans.factory.BeanFactory |
FACTORY_BEAN_PREFIX |
Method Summary |
void |
addShareableResource(java.lang.String shareableResource)
Add the name of a shareable JNDI resource,
which this factory is allowed to cache once obtained. |
boolean |
containsBean(java.lang.String name)
|
java.lang.String[] |
getAliases(java.lang.String name)
|
|
getBean(java.lang.Class<T> requiredType)
|
java.lang.Object |
getBean(java.lang.String name)
|
|
getBean(java.lang.String name,
java.lang.Class<T> requiredType)
|
java.lang.Object |
getBean(java.lang.String name,
java.lang.Object... args)
|
java.lang.Class<?> |
getType(java.lang.String name)
|
boolean |
isPrototype(java.lang.String name)
|
boolean |
isSingleton(java.lang.String name)
|
boolean |
isTypeMatch(java.lang.String name,
java.lang.Class targetType)
|
void |
setShareableResources(java.lang.String[] shareableResources)
Set a list of names of shareable JNDI resources,
which this factory is allowed to cache once obtained. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleJndiBeanFactory
public SimpleJndiBeanFactory()
setShareableResources
public void setShareableResources(java.lang.String[] shareableResources)
- Set a list of names of shareable JNDI resources,
which this factory is allowed to cache once obtained.
- Parameters:
shareableResources
- the JNDI names
(typically within the "java:comp/env/" namespace)
addShareableResource
public void addShareableResource(java.lang.String shareableResource)
- Add the name of a shareable JNDI resource,
which this factory is allowed to cache once obtained.
- Parameters:
shareableResource
- the JNDI name
(typically within the "java:comp/env/" namespace)
getBean
public java.lang.Object getBean(java.lang.String name)
throws org.springframework.beans.BeansException
- Specified by:
getBean
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
getBean
public <T> T getBean(java.lang.String name,
java.lang.Class<T> requiredType)
throws org.springframework.beans.BeansException
- Specified by:
getBean
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
getBean
public <T> T getBean(java.lang.Class<T> requiredType)
throws org.springframework.beans.BeansException
- Specified by:
getBean
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
getBean
public java.lang.Object getBean(java.lang.String name,
java.lang.Object... args)
throws org.springframework.beans.BeansException
- Specified by:
getBean
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
containsBean
public boolean containsBean(java.lang.String name)
- Specified by:
containsBean
in interface org.springframework.beans.factory.BeanFactory
isSingleton
public boolean isSingleton(java.lang.String name)
throws org.springframework.beans.factory.NoSuchBeanDefinitionException
- Specified by:
isSingleton
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
isPrototype
public boolean isPrototype(java.lang.String name)
throws org.springframework.beans.factory.NoSuchBeanDefinitionException
- Specified by:
isPrototype
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
isTypeMatch
public boolean isTypeMatch(java.lang.String name,
java.lang.Class targetType)
throws org.springframework.beans.factory.NoSuchBeanDefinitionException
- Specified by:
isTypeMatch
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
getType
public java.lang.Class<?> getType(java.lang.String name)
throws org.springframework.beans.factory.NoSuchBeanDefinitionException
- Specified by:
getType
in interface org.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
getAliases
public java.lang.String[] getAliases(java.lang.String name)
- Specified by:
getAliases
in interface org.springframework.beans.factory.BeanFactory