public class SimpleJndiBeanFactory extends JndiLocatorSupport implements org.springframework.beans.factory.BeanFactory
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.
DefaultListableBeanFactory,
CommonAnnotationBeanPostProcessorCONTAINER_PREFIXlogger| Constructor and Description |
|---|
SimpleJndiBeanFactory() |
| Modifier and Type | Method and Description |
|---|---|
void |
addShareableResource(String shareableResource)
Add the name of a shareable JNDI resource,
which this factory is allowed to cache once obtained.
|
boolean |
containsBean(String name) |
String[] |
getAliases(String name) |
<T> T |
getBean(Class<T> requiredType) |
<T> T |
getBean(Class<T> requiredType,
Object... args) |
Object |
getBean(String name) |
<T> T |
getBean(String name,
Class<T> requiredType) |
Object |
getBean(String name,
Object... args) |
Class<?> |
getType(String name) |
boolean |
isPrototype(String name) |
boolean |
isSingleton(String name) |
boolean |
isTypeMatch(String name,
Class<?> typeToMatch) |
boolean |
isTypeMatch(String name,
org.springframework.core.ResolvableType typeToMatch) |
void |
setShareableResources(String... shareableResources)
Set a list of names of shareable JNDI resources,
which this factory is allowed to cache once obtained.
|
convertJndiName, isResourceRef, lookup, lookup, setResourceRefgetJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplatepublic void addShareableResource(String shareableResource)
shareableResource - the JNDI name
(typically within the "java:comp/env/" namespace)public void setShareableResources(String... shareableResources)
shareableResources - the JNDI names
(typically within the "java:comp/env/" namespace)public Object getBean(String name) throws org.springframework.beans.BeansException
getBean in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.BeansExceptionpublic <T> T getBean(String name, Class<T> requiredType) throws org.springframework.beans.BeansException
getBean in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.BeansExceptionpublic <T> T getBean(Class<T> requiredType) throws org.springframework.beans.BeansException
getBean in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.BeansExceptionpublic Object getBean(String name, Object... args) throws org.springframework.beans.BeansException
getBean in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.BeansExceptionpublic <T> T getBean(Class<T> requiredType, Object... args) throws org.springframework.beans.BeansException
getBean in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.BeansExceptionpublic boolean containsBean(String name)
containsBean in interface org.springframework.beans.factory.BeanFactorypublic boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isSingleton in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic boolean isPrototype(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isPrototype in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic boolean isTypeMatch(String name, org.springframework.core.ResolvableType typeToMatch) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isTypeMatch in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic boolean isTypeMatch(String name, Class<?> typeToMatch) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isTypeMatch in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic Class<?> getType(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
getType in interface org.springframework.beans.factory.BeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionException