JSF-Spring

de.mindmatters.faces.spring.factory
Class ManagedBeanFactory

java.lang.Object
  extended by org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
      extended by org.springframework.beans.factory.support.AbstractBeanFactory
          extended by org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
              extended by org.springframework.beans.factory.support.DefaultListableBeanFactory
                  extended by de.mindmatters.faces.spring.factory.ManagedBeanFactory
All Implemented Interfaces:
BeanFactory, AutowireCapableBeanFactory, ConfigurableBeanFactory, ConfigurableListableBeanFactory, SingletonBeanRegistry, HierarchicalBeanFactory, ListableBeanFactory, BeanDefinitionRegistry

public class ManagedBeanFactory
extends DefaultListableBeanFactory

Default implementation of the ConfigurableBeanFactory interfaces: a full-fledged bean factory based on bean definitions.

This factory based on different types of bean definitions. In addition to the default types of bean definitions this factory is able to handle ManagedBeanDefinitions.

Based on DefaultListableBeanFactory

Author:
Andreas Kuhrwahl

Field Summary
static java.lang.String SCOPE_APPLICATION
          Scope identifier for application scope: "application".
static java.lang.String SCOPE_NONE
          Scope identifier for none scope: "none".
 
Fields inherited from class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
logger
 
Fields inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_NO
 
Fields inherited from interface org.springframework.beans.factory.config.ConfigurableBeanFactory
SCOPE_PROTOTYPE, SCOPE_SINGLETON
 
Constructor Summary
ManagedBeanFactory()
          Creates a new DefaultConfigurableBeanFactory.
ManagedBeanFactory(BeanFactory parentBeanFactory)
          Creates a new DefaultConfigurableBeanFactory with the given parent.
 
Method Summary
protected  void addSingleton(java.lang.String beanName, java.lang.Object sharedBean)
          Add the given singleton object to the singleton cache of this factory.
static RootBeanDefinition createManagedBeanDefinition(java.lang.String beanClassName, java.lang.ClassLoader beanClassLoader)
          Creates a ManagedBeanDefinition based upon a RootBeanDefinition.
static RootBeanDefinition createRootBeanDefinition(RootBeanDefinition beanDefinition)
          Creates a RootBeanDefinition based upon a RootBeanDefinition.
 void destroySingletons()
          Destroy all singleton beans in this factory, including inner beans that have been registered as disposable.
protected  java.lang.Object doTypeConversionIfNecessary(TypeConverter converter, java.lang.Object value, java.lang.Class targetType, MethodParameter methodParam)
          Convert the given value into the specified target type, using the specified BeanWrapper.
protected  RootBeanDefinition getMergedBeanDefinition(java.lang.String beanName, BeanDefinition bd)
          Return a RootBeanDefinition for the given bean name, by merging with the parent if the given original bean definition is a child bean definition.
protected  void removeSingleton(java.lang.String beanName)
          Overridden to clear FactoryBean instance cache as well.
 
Methods inherited from class org.springframework.beans.factory.support.DefaultListableBeanFactory
containsBeanDefinition, copyConfigurationFrom, findMatchingBeans, getBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, preInstantiateSingletons, registerBeanDefinition, setAllowBeanDefinitionOverriding, setAllowEagerClassLoading, toString
 
Methods inherited from class org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPostProcessorsBeforeInstantiation, applyBeanPropertyValues, autowire, autowireBeanProperties, autowireByName, autowireByType, autowireConstructor, checkDependencies, configureBean, createBean, createBean, createBeanInstance, filterPropertyDescriptorsForDependencyCheck, getInstantiationStrategy, getTypeForFactoryBean, getTypeForFactoryMethod, ignoreDependencyInterface, ignoreDependencyType, initializeBean, initializeBean, instantiateBean, instantiateUsingFactoryMethod, invokeCustomInitMethod, invokeInitMethods, isExcludedFromDependencyCheck, populateBean, postProcessObjectFromFactoryBean, setAllowCircularReferences, setAllowRawInjectionDespiteWrapping, setInstantiationStrategy, unsatisfiedNonSimpleProperties
 
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
addBeanPostProcessor, addPropertyEditorRegistrar, checkMergedBeanDefinition, containsBean, containsLocalBean, destroyBean, destroyBean, destroyScopedBean, getAliases, getBean, getBean, getBean, getBean, getBeanClassLoader, getBeanPostProcessorCount, getBeanPostProcessors, getCustomEditors, getMergedBeanDefinition, getMergedBeanDefinition, getObjectForBeanInstance, getParentBeanFactory, getPropertyEditorRegistrars, getRegisteredScope, getRegisteredScopeNames, getType, hasDestructionAwareBeanPostProcessors, initBeanWrapper, isAlias, isBeanNameUsed, isCacheBeanMetadata, isCurrentlyInCreation, isFactoryBean, isPrototypeCurrentlyInCreation, isSingleton, originalBeanName, registerAlias, registerCustomEditor, registerCustomEditors, registerDisposableBeanIfNecessary, registerScope, requiresDestruction, resolveBeanClass, setBeanClassLoader, setCacheBeanMetadata, setParentBeanFactory, transformedBeanName
 
Methods inherited from class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
afterSingletonCreation, beforeSingletonCreation, containsSingleton, destroyBean, destroySingleton, getDependentBeans, getSingleton, getSingleton, getSingletonCount, getSingletonNames, hasDependentBean, isSingletonCurrentlyInCreation, registerDependentBean, registerDisposableBean, registerSingleton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
ignoreDependencyInterface, ignoreDependencyType
 
Methods inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBeanProperties, configureBean, createBean, initializeBean
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableBeanFactory
addBeanPostProcessor, addPropertyEditorRegistrar, destroyBean, destroyScopedBean, getBeanClassLoader, getBeanPostProcessorCount, getRegisteredScope, getRegisteredScopeNames, isCacheBeanMetadata, isCurrentlyInCreation, registerAlias, registerCustomEditor, registerScope, setBeanClassLoader, setCacheBeanMetadata, setParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.config.SingletonBeanRegistry
containsSingleton, getSingleton, getSingletonCount, getSingletonNames, registerSingleton
 
Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionRegistry
getAliases, registerAlias
 

Field Detail

SCOPE_APPLICATION

public static final java.lang.String SCOPE_APPLICATION
Scope identifier for application scope: "application". Similar to standard scope "singleton".

See Also:
Constant Field Values

SCOPE_NONE

public static final java.lang.String SCOPE_NONE
Scope identifier for none scope: "none". Similar to standard scope "prototype".

See Also:
Constant Field Values
Constructor Detail

ManagedBeanFactory

public ManagedBeanFactory()
Creates a new DefaultConfigurableBeanFactory.


ManagedBeanFactory

public ManagedBeanFactory(BeanFactory parentBeanFactory)
Creates a new DefaultConfigurableBeanFactory with the given parent.

Parameters:
parentBeanFactory - the parent
Method Detail

createManagedBeanDefinition

public static final RootBeanDefinition createManagedBeanDefinition(java.lang.String beanClassName,
                                                                   java.lang.ClassLoader beanClassLoader)
                                                            throws java.lang.ClassNotFoundException
Creates a ManagedBeanDefinition based upon a RootBeanDefinition.

Parameters:
beanClassName - the name of the bean class, if any
beanClassLoader - the ClassLoader to use for loading bean classes
Returns:
the bean definition
Throws:
java.lang.ClassNotFoundException - if the bean class could not be loaded
See Also:
ManagedBeanDefinition, RootBeanDefinition

createRootBeanDefinition

public static final RootBeanDefinition createRootBeanDefinition(RootBeanDefinition beanDefinition)
Creates a RootBeanDefinition based upon a RootBeanDefinition. The created bean definition treats faces beans defined in the application scope as singleton beans.

Parameters:
beanDefinition - the original RootBeanDefinition
Returns:
the bean definition

doTypeConversionIfNecessary

protected final java.lang.Object doTypeConversionIfNecessary(TypeConverter converter,
                                                             java.lang.Object value,
                                                             java.lang.Class targetType,
                                                             MethodParameter methodParam)
Convert the given value into the specified target type, using the specified BeanWrapper.

Overrides:
doTypeConversionIfNecessary in class AbstractBeanFactory
Parameters:
converter - the TypeConverter to work on
value - the original value
targetType - the target type
Returns:
the converted value, matching the target type
See Also:
BeanWrapperImpl.convertIfNecessary(Object, Class)

getMergedBeanDefinition

protected final RootBeanDefinition getMergedBeanDefinition(java.lang.String beanName,
                                                           BeanDefinition bd)
Return a RootBeanDefinition for the given bean name, by merging with the parent if the given original bean definition is a child bean definition.

Overrides:
getMergedBeanDefinition in class AbstractBeanFactory
Parameters:
beanName - the name of the bean definition
bd - the original bean definition (Root/ChildBeanDefinition)
Returns:
a (potentially merged) RootBeanDefinition for the given bean

addSingleton

protected final void addSingleton(java.lang.String beanName,
                                  java.lang.Object sharedBean)
Add the given singleton object to the singleton cache of this factory.

To be called for eager registration of singletons, e.g. to be able to resolve circular references.

Overrides:
addSingleton in class DefaultSingletonBeanRegistry
Parameters:
beanName - the name of the bean
sharedBean - the singleton object

removeSingleton

protected final void removeSingleton(java.lang.String beanName)
Overridden to clear FactoryBean instance cache as well.

Overrides:
removeSingleton in class AbstractAutowireCapableBeanFactory
Parameters:
beanName - the name of the bean

destroySingletons

public final void destroySingletons()
Destroy all singleton beans in this factory, including inner beans that have been registered as disposable. To be called on shutdown of a factory.

Any exception that arises during destruction should be caught and logged instead of propagated to the caller of this method.

Specified by:
destroySingletons in interface ConfigurableBeanFactory
Overrides:
destroySingletons in class DefaultSingletonBeanRegistry

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG