SourceForge.net Logo

de.mindmatters.faces.spring
Class AbstractScope

java.lang.Object
  extended byde.mindmatters.faces.spring.AbstractScope
All Implemented Interfaces:
ApplicationContextAware, BeanNameAware, FactoryBean, InitializingBean
Direct Known Subclasses:
ApplicationScope, RequestScope, SessionScope

public abstract class AbstractScope
extends java.lang.Object
implements ApplicationContextAware, BeanNameAware, FactoryBean, InitializingBean

Wraps and enables JSF specific scope definition and management for a bean declared in any spring context.

AbstractScope can scope beans declared as prototype. If the bean to scope is declared in a parent context, the name of the bean and the name of the scope should be defined identically. If the bean to scope is declared in the same context as the scope, the names of the beans should differ - the property targetBeanName should be set to the name of the bean to scope.

Furthermore it is possible to set the bean to scope directly - the property targetBean should be set with the bean to scope. With jsf-spring's ability to interpret the jsf-ExpressionLanguage, sophisticated bean scoping is possible.

Author:
Andreas Kuhrwahl

Field Summary
protected  org.apache.commons.logging.Log logger
          For logging.
 
Constructor Summary
AbstractScope()
           
 
Method Summary
 void afterPropertiesSet()
          Check the name of this bean and the targetBeanName.
 java.lang.Object getObject()
          Returns the cached or newly created bean which is scoped by this factory.
 java.lang.Class getObjectType()
          
protected abstract  java.util.Map getScopeMap()
          Returns the appropriate scope from the external context of the faces implementation.
protected  void initScope()
          Hook for initialization purposes.
 boolean isSingleton()
          
 void refresh()
          Refreshs this scope, removing the scoped bean from the specific faces scope.
 void setApplicationContext(ApplicationContext applicationContext)
          .
 void setBeanName(java.lang.String beanName)
          .
 void setTargetBean(java.lang.Object targetBean)
          Sets the created bean targetBean to scope.
 void setTargetBeanName(java.lang.String targetBeanName)
          Sets the name of a bean to scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
For logging.

Constructor Detail

AbstractScope

public AbstractScope()
Method Detail

afterPropertiesSet

public final void afterPropertiesSet()
Check the name of this bean and the targetBeanName.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
java.lang.IllegalArgumentException - if properties are not configured properly
See Also:
InitializingBean.afterPropertiesSet()

initScope

protected void initScope()
Hook for initialization purposes.

Throws:
java.lang.IllegalArgumentException - if properties are not configured properly

refresh

public final void refresh()
Refreshs this scope, removing the scoped bean from the specific faces scope.

Throws:
java.lang.IllegalArgumentException - if properties are not configured properly

setApplicationContext

public final void setApplicationContext(ApplicationContext applicationContext)
.

Specified by:
setApplicationContext in interface ApplicationContextAware

setBeanName

public final void setBeanName(java.lang.String beanName)
.

Specified by:
setBeanName in interface BeanNameAware

getScopeMap

protected abstract java.util.Map getScopeMap()
Returns the appropriate scope from the external context of the faces implementation.

Returns:
the scope
Throws:
java.lang.IllegalStateException - if scope could not be created (e.g. the FacesContext is null)

getObject

public final java.lang.Object getObject()
Returns the cached or newly created bean which is scoped by this factory.

Specified by:
getObject in interface FactoryBean
Returns:
the scoped bean
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalStateException
BeanCreationException
See Also:
getScopeMap(), FactoryBean.getObject()

getObjectType

public final java.lang.Class getObjectType()

Specified by:
getObjectType in interface FactoryBean

isSingleton

public final boolean isSingleton()

Specified by:
isSingleton in interface FactoryBean

setTargetBeanName

public final void setTargetBeanName(java.lang.String targetBeanName)
Sets the name of a bean to scope. This name should differ from the name of this factory. targetBean must not be set.

Parameters:
targetBeanName - The targetBeanName to set.

setTargetBean

public final void setTargetBean(java.lang.Object targetBean)
Sets the created bean targetBean to scope. targetBeanName must not be set.

Parameters:
targetBean - The bean to scope.

SourceForge.net Logo

Copyright © 2002 mindmatters GmbH & Co. KG