Class ContextJndiBeanFactoryLocator
- java.lang.Object
- org.springframework.jndi.JndiAccessor
- org.springframework.jndi.JndiLocatorSupport
- org.springframework.context.access.ContextJndiBeanFactoryLocator
- All Implemented Interfaces:
BeanFactoryLocator
public class ContextJndiBeanFactoryLocator extends JndiLocatorSupport implements BeanFactoryLocator
BeanFactoryLocator implementation that creates the BeanFactory from one or more classpath locations specified in a JNDI environment variable.This default implementation creates a
ClassPathXmlApplicationContext. Subclasses may overridecreateBeanFactory(java.lang.String[])for custom instantiation.- Author:
- Colin Sampaleanu, Juergen Hoeller
- See Also:
createBeanFactory(java.lang.String[])
Field Summary
Fields Modifier and Type Field Description static StringBEAN_FACTORY_PATH_DELIMITERSAny number of these characters are considered delimiters between multiple bean factory config paths in a single String value.Fields inherited from class org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIX
Fields inherited from class org.springframework.jndi.JndiAccessor
logger
Constructor Summary
Constructors Constructor Description ContextJndiBeanFactoryLocator()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ApplicationContextcreateApplicationContext(String[] resources)Create the ApplicationContext instance, given an array of class path resource Strings which should be combinedprotected BeanFactoryReferencecreateBeanFactory(String[] resources)Create the BeanFactory instance, given an array of class path resource Strings which should be combined.BeanFactoryReferenceuseBeanFactory(String factoryKey)Load/use a bean factory, as specified by a factory key which is a JNDI address, of the formjava:comp/env/ejb/BeanFactoryPath.Methods inherited from class org.springframework.jndi.JndiLocatorSupport
convertJndiName, isResourceRef, lookup, lookup, setResourceRef
Methods inherited from class org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
Field Detail
BEAN_FACTORY_PATH_DELIMITERS
public static final String BEAN_FACTORY_PATH_DELIMITERS
Any number of these characters are considered delimiters between multiple bean factory config paths in a single String value.- See Also:
- Constant Field Values
Constructor Detail
ContextJndiBeanFactoryLocator
public ContextJndiBeanFactoryLocator()
Method Detail
useBeanFactory
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException
Load/use a bean factory, as specified by a factory key which is a JNDI address, of the formjava:comp/env/ejb/BeanFactoryPath. The contents of this JNDI location must be a string containing one or more classpath resource names (separated by any of the delimiters ',; \t\n' if there is more than one. The resulting BeanFactory (or ApplicationContext) will be created from the combined resources.- Specified by:
useBeanFactoryin interfaceBeanFactoryLocator- Parameters:
factoryKey- a resource name specifying whichBeanFactorytheBeanFactoryLocatormust return for usage. The actual meaning of the resource name is specific to the implementation ofBeanFactoryLocator.- Returns:
- the
BeanFactoryinstance, wrapped as aBeanFactoryReferenceobject - Throws:
BeansException- if there is an error loading or accessing theBeanFactory- See Also:
createBeanFactory(java.lang.String[])
createBeanFactory
protected BeanFactoryReference createBeanFactory(String[] resources) throws BeansException
Create the BeanFactory instance, given an array of class path resource Strings which should be combined. This is split out as a separate method so that subclasses can override the actual BeanFactory implementation class.Delegates to
createApplicationContextby default, wrapping the result in a ContextBeanFactoryReference.- Parameters:
resources- an array of Strings representing classpath resource names- Returns:
- the created BeanFactory, wrapped in a BeanFactoryReference (for example, a ContextBeanFactoryReference wrapping an ApplicationContext)
- Throws:
BeansException- if factory creation failed- See Also:
createApplicationContext(java.lang.String[]),ContextBeanFactoryReference
createApplicationContext
protected ApplicationContext createApplicationContext(String[] resources) throws BeansException
Create the ApplicationContext instance, given an array of class path resource Strings which should be combined- Parameters:
resources- an array of Strings representing classpath resource names- Returns:
- the created ApplicationContext
- Throws:
BeansException- if context creation failed