org.jboss.webbeans.contexts
Class AbstractContext

java.lang.Object
  extended by org.jboss.webbeans.contexts.AbstractContext
All Implemented Interfaces:
Context
Direct Known Subclasses:
ApplicationContext, BasicContext, SessionContext

public abstract class AbstractContext
extends java.lang.Object
implements Context

Base for the Context implementations. Delegates calls to the abstract getBeanMap and getActive to allow for different implementations (storage types and ThreadLocal vs. shared)

Author:
Nicklas Karlsson, Pete Muir
See Also:
org.jboss.webbeans.contexts.SharedContext, BasicContext

Constructor Summary
AbstractContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Constructor
 
Method Summary
 void destroy()
          Destroys the context
<T> T
get(Contextual<T> bean, boolean create)
          Get the bean if it exists in the contexts.
protected  java.lang.Boolean getActive()
          Delegates to a ThreadLocal instance
protected abstract  BeanMap getBeanMap()
          A method that should return the actual bean map implementation
 java.lang.Class<? extends java.lang.annotation.Annotation> getScopeType()
          Get the scope the context is for
 boolean isActive()
          Return true if the context is active
 void setActive(boolean active)
          Set the context active, internal API for WBRI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractContext

public AbstractContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
Constructor

Parameters:
scopeType - The scope type
Method Detail

get

public <T> T get(Contextual<T> bean,
                 boolean create)
Get the bean if it exists in the contexts.

Specified by:
get in interface Context
Parameters:
create - If true, a new instance of the bean will be created if none exists
Returns:
An instance of the bean
Throws:
ContextNotActiveException - if the context is not active
See Also:
javax.webbeans.manager.Context#get(Bean, boolean)

getScopeType

public java.lang.Class<? extends java.lang.annotation.Annotation> getScopeType()
Get the scope the context is for

Specified by:
getScopeType in interface Context
Returns:
The scope type
See Also:
Context.getScopeType()

isActive

public boolean isActive()
Return true if the context is active

Specified by:
isActive in interface Context
Returns:
The active state
See Also:
Context.isActive()

setActive

public void setActive(boolean active)
Set the context active, internal API for WBRI

Parameters:
active - The new state

destroy

public void destroy()
Destroys the context


getBeanMap

protected abstract BeanMap getBeanMap()
A method that should return the actual bean map implementation

Returns:
The actual bean map

getActive

protected java.lang.Boolean getActive()
Delegates to a ThreadLocal instance



Copyright © 2008. All Rights Reserved.