SourceForge.net Logo

de.mindmatters.faces.spring.factory.context
Class AbstractManagedBeanFactory

java.lang.Object
  extended byorg.springframework.beans.factory.support.AbstractBeanFactory
      extended byorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
          extended byorg.springframework.beans.factory.support.DefaultListableBeanFactory
              extended byde.mindmatters.faces.spring.factory.DefaultConfigurableBeanFactory
                  extended byde.mindmatters.faces.spring.factory.context.AbstractManagedBeanFactory
All Implemented Interfaces:
AutowireCapableBeanFactory, BeanDefinitionRegistry, BeanFactory, ConfigurableBeanFactory, ConfigurableBeanFactory, ConfigurableListableBeanFactory, HierarchicalBeanFactory, ListableBeanFactory, ManagedBeanFactory
Direct Known Subclasses:
FacesDelegatingManagedBeanFactory, SpringManagedBeanFactory

public abstract class AbstractManagedBeanFactory
extends DefaultConfigurableBeanFactory
implements ManagedBeanFactory

ManagedBeanFactory implementation used as internal bean factory for the implementation of the used FacesWebApplicationContext.

Inherits from DefaultConfigurableBeanFactory and overrides the createBean(String, RootBeanDefinition, Object[]) method in such a manner that the creation and faces specific scope-caching of beans declared in a faces configuration file could be done by subclasses of this implementation.

Author:
Andreas Kuhrwahl
See Also:
DefaultListableBeanFactory, ManagedBeanDefinition

Field Summary
 
Fields inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
logger
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Fields inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR
 
Constructor Summary
AbstractManagedBeanFactory(ConfigurableInstantiationStrategy strategy, BeanFactory parentBeanFactory)
          Creates a Factory with the given ConfigurableInstantiationStrategy strategy and the given parent BeanFactory parentBeanFactory.
 
Method Summary
protected  java.lang.Object createBean(java.lang.String beanName, RootBeanDefinition mergedBeanDefinition, java.lang.Object[] args)
          Checks whether the given RootBeanDefinition mergedBeanDefinition is of type ScopedBeanDefinition or not.
protected abstract  java.lang.Object createManagedBean(java.lang.String beanName, ManagedBeanDefinition beanDefinition)
          Creates a managed bean declared in a faces configuration file.
protected  java.lang.Object createNonManagedBean(java.lang.String beanName, RootBeanDefinition mergedBeanDefinition, java.lang.Object[] args)
          Creates and populates a non managed bean (bean defined in a spring beans compliant XML document).
 java.lang.String[] getBeanNamesForType(java.lang.Class type, boolean includePrototypes, boolean includeFactoryBeans)
          
 java.lang.String[] getBeanNamesForType(java.lang.Class type, java.lang.String scope)
          Returns the names of beans matching the given type (including subclasses) and given scope.
 java.util.Map getBeansOfType(java.lang.Class type, java.lang.String scope, boolean createBeanIfNecessary)
          Returns the bean instances that match the given object type (including subclasses) and given scope. If the requested beans are not created yet they will be created if createBeanIfNecessary is true.
protected  RootBeanDefinition getMergedBeanDefinition(java.lang.String beanName, BeanDefinition bd)
          
protected  ScopedBeanStorage getScopedBeanStorage()
           
 void setScopedBeanStorage(ScopedBeanStorage scopedBeanStorage)
          Sets the appropriate storage to use.
 
Methods inherited from class de.mindmatters.faces.spring.factory.DefaultConfigurableBeanFactory
addInstantiationProcessor, doTypeConversionIfNecessary, getConfigurableInstantiationStrategy, setInstantiationStrategy
 
Methods inherited from class org.springframework.beans.factory.support.DefaultListableBeanFactory
containsBeanDefinition, findMatchingBeans, getBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanDefinitionNames, getBeanNamesForType, getBeansOfType, getBeansOfType, preInstantiateSingletons, registerBeanDefinition, setAllowBeanDefinitionOverriding, toString
 
Methods inherited from class org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPostProcessorsBeforeInstantiation, applyBeanPropertyValues, autowire, autowireBeanProperties, autowireByName, autowireByType, autowireConstructor, checkDependencies, getIgnoredDependencyInterfaces, getIgnoredDependencyTypes, getInstantiationStrategy, getTypeForFactoryMethod, ignoreDependencyInterface, ignoreDependencyType, instantiateBean, instantiateUsingFactoryMethod, invokeCustomInitMethod, invokeInitMethods, isExcludedFromDependencyCheck, populateBean, unsatisfiedNonSimpleProperties
 
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
addBeanPostProcessor, addSingleton, checkMergedBeanDefinition, containsBean, containsSingleton, destroyBean, destroySingletons, doTypeConversionIfNecessary, getAliases, getBean, getBean, getBean, getBean, getBeanPostProcessorCount, getBeanPostProcessors, getCustomEditors, getMergedBeanDefinition, getMergedBeanDefinition, getObjectForSharedInstance, getParentBeanFactory, getSingletonCount, getSingletonNames, getType, hasDestructionAwareBeanPostProcessors, initBeanWrapper, invokeCustomDestroyMethod, isFactoryBean, isFactoryDereference, isSingleton, isSingletonCurrentlyInCreation, registerAlias, registerCustomEditor, registerDependentBean, registerDisposableBean, registerDisposableBeanIfNecessary, registerSingleton, removeSingleton, setParentBeanFactory, transformedBeanName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.mindmatters.faces.spring.factory.ConfigurableBeanFactory
addInstantiationProcessor
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
getBeanDefinition, ignoreDependencyInterface, ignoreDependencyType, preInstantiateSingletons
 
Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanDefinitionNames, getBeanNamesForType, getBeansOfType, getBeansOfType
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getType, isSingleton
 
Methods inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBeanProperties
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableBeanFactory
addBeanPostProcessor, containsSingleton, destroySingletons, getBeanPostProcessorCount, registerAlias, registerCustomEditor, registerSingleton, setParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionRegistry
getAliases, registerAlias
 

Constructor Detail

AbstractManagedBeanFactory

public AbstractManagedBeanFactory(ConfigurableInstantiationStrategy strategy,
                                  BeanFactory parentBeanFactory)
Creates a Factory with the given ConfigurableInstantiationStrategy strategy and the given parent BeanFactory parentBeanFactory.

Parameters:
strategy - the InstantiationStrategy to use
parentBeanFactory - the parent factory
Method Detail

createBean

protected final java.lang.Object createBean(java.lang.String beanName,
                                            RootBeanDefinition mergedBeanDefinition,
                                            java.lang.Object[] args)
Checks whether the given RootBeanDefinition mergedBeanDefinition is of type ScopedBeanDefinition or not. If not the default creation process will be started. Otherwise the configured storage is checked for a bean with name beanName and delivered or (if not found in the storage) newly created. This creation process is delegated to appropriate subclasses.

Parameters:
beanName - the name of the requested bean
mergedBeanDefinition - the bean definition for the bean
args - arguments to use if creating a prototype using explicit arguments to a static factory method. This parameter must be null except in this case.
Returns:
a new instance of the bean
Throws:
BeanCreationException - if the bean could not be created

createNonManagedBean

protected final java.lang.Object createNonManagedBean(java.lang.String beanName,
                                                      RootBeanDefinition mergedBeanDefinition,
                                                      java.lang.Object[] args)
Creates and populates a non managed bean (bean defined in a spring beans compliant XML document). Delegates to the createBean(String, RootBeanDefinition, Object[]) method of the superclass.

Parameters:
beanName - the name of the requested bean
mergedBeanDefinition - the bean definition for the bean
args - arguments to use if creating a prototype using explicit arguments to a static factory method. This parameter must be null except in this case.
Returns:
a new instance of the bean
Throws:
BeanCreationException - if the bean could not be created
See Also:
AbstractBeanFactory.createBean(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, java.lang.Object[])

createManagedBean

protected abstract java.lang.Object createManagedBean(java.lang.String beanName,
                                                      ManagedBeanDefinition beanDefinition)
Creates a managed bean declared in a faces configuration file.

Parameters:
beanName - the name of the requested bean
beanDefinition - the bean definition for the bean
Returns:
a new instance of the bean
Throws:
BeanCreationException - if the bean could not be created

getScopedBeanStorage

protected final ScopedBeanStorage getScopedBeanStorage()
Returns:
Returns the ScopedBeanStorage.

setScopedBeanStorage

public final void setScopedBeanStorage(ScopedBeanStorage scopedBeanStorage)
Sets the appropriate storage to use.

Specified by:
setScopedBeanStorage in interface ManagedBeanFactory
Parameters:
scopedBeanStorage - The scopedBeanStorage to set.
See Also:
ScopedBeanStorage

getMergedBeanDefinition

protected final RootBeanDefinition getMergedBeanDefinition(java.lang.String beanName,
                                                           BeanDefinition bd)


getBeanNamesForType

public final java.lang.String[] getBeanNamesForType(java.lang.Class type,
                                                    boolean includePrototypes,
                                                    boolean includeFactoryBeans)

Specified by:
getBeanNamesForType in interface ListableBeanFactory

getBeanNamesForType

public final java.lang.String[] getBeanNamesForType(java.lang.Class type,
                                                    java.lang.String scope)
Returns the names of beans matching the given type (including subclasses) and given scope.

Specified by:
getBeanNamesForType in interface ManagedBeanFactory
Parameters:
type - the class or interface to match, or null for all bean names
scope - the scope to match, or null for all scopes
Returns:
the names of beans matching the given object type (including subclasses) and given scope, or an empty array if none

getBeansOfType

public final java.util.Map getBeansOfType(java.lang.Class type,
                                          java.lang.String scope,
                                          boolean createBeanIfNecessary)
Returns the bean instances that match the given object type (including subclasses) and given scope. If the requested beans are not created yet they will be created if createBeanIfNecessary is true.

Specified by:
getBeansOfType in interface ManagedBeanFactory
Parameters:
type - the class or interface to match, or null for all concrete beans
scope - the scope to match, or null for all scopes
createBeanIfNecessary - whether to create beans not created yet and return them, or not
Returns:
a Map with the matching beans, containing the bean names as keys and the corresponding bean instances as values

SourceForge.net Logo

Copyright © 2002 mindmatters GmbH & Co. KG