Package 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
Jakarta EE 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:
-
DefaultListableBeanFactoryCommonAnnotationBeanPostProcessor
-
Field Summary
Fields inherited from class org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIXFields inherited from class org.springframework.jndi.JndiAccessor
loggerFields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX, FACTORY_BEAN_PREFIX_CHAR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddShareableResource(String shareableResource) Add the name of a shareable JNDI resource, which this factory is allowed to cache once obtained.booleancontainsBean(String name) String[]getAliases(String name) <T> T<T> T<T> T<T> org.springframework.beans.factory.ObjectProvider<T>getBeanProvider(Class<T> requiredType) <T> org.springframework.beans.factory.ObjectProvider<T>getBeanProvider(org.springframework.core.ResolvableType requiredType) Class<?>Class<?>booleanisPrototype(String name) booleanisSingleton(String name) booleanisTypeMatch(String name, Class<?> typeToMatch) booleanisTypeMatch(String name, org.springframework.core.ResolvableType typeToMatch) voidsetShareableResources(String... shareableResources) Set a list of names of shareable JNDI resources, which this factory is allowed to cache once obtained.Methods inherited from class org.springframework.jndi.JndiLocatorSupport
convertJndiName, isResourceRef, lookup, lookup, setResourceRefMethods inherited from class org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
-
Constructor Details
-
SimpleJndiBeanFactory
public SimpleJndiBeanFactory()
-
-
Method Details
-
getBean
- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
public <T> T getBean(String name, Class<T> requiredType) throws org.springframework.beans.BeansException - Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
public Object getBean(String name, @Nullable Object... args) throws org.springframework.beans.BeansException - Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
public <T> T getBean(Class<T> requiredType, @Nullable Object... args) throws org.springframework.beans.BeansException - Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(Class<T> requiredType) - Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.BeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(org.springframework.core.ResolvableType requiredType) - Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.BeanFactory
-
containsBean
- Specified by:
containsBeanin interfaceorg.springframework.beans.factory.BeanFactory
-
isSingleton
public boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isSingletonin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isPrototype
public boolean isPrototype(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isPrototypein interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isTypeMatch
public boolean isTypeMatch(String name, org.springframework.core.ResolvableType typeToMatch) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isTypeMatchin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isTypeMatch
public boolean isTypeMatch(String name, @Nullable Class<?> typeToMatch) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isTypeMatchin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getType
@Nullable public Class<?> getType(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
getTypein interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getType
@Nullable public Class<?> getType(String name, boolean allowFactoryBeanInit) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
getTypein interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getAliases
- Specified by:
getAliasesin interfaceorg.springframework.beans.factory.BeanFactory