org.jboss.webbeans.context
Class AbstractMapContext

java.lang.Object
  extended by org.jboss.webbeans.context.AbstractContext
      extended by org.jboss.webbeans.context.AbstractMapContext
All Implemented Interfaces:
Context
Direct Known Subclasses:
AbstractThreadLocalMapContext, ApplicationContext

public abstract class AbstractMapContext
extends AbstractContext

Base for the Context implementations. Delegates calls to the abstract getBeanStorage 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, org.jboss.webbeans.context.BasicContext

Constructor Summary
AbstractMapContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Constructor
 
Method Summary
 void destroy()
          Destroys the context
<T> T
get(Contextual<T> contextual)
          Return an existing instance of a contextual type or create a new instance of a contextual type
<T> T
get(Contextual<T> contextual, CreationalContext<T> creationalContext)
          Get the bean if it exists in the contexts.
protected abstract  BeanStore getBeanStore()
          A method that returns the actual bean store implementation
protected abstract  boolean isCreationLockRequired()
          If Context need to inhibit concurrent instance creation then true, else false.
 
Methods inherited from class org.jboss.webbeans.context.AbstractContext
getActive, getScopeType, isActive, setActive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMapContext

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

Parameters:
scopeType - The scope type
Method Detail

get

public <T> T get(Contextual<T> contextual,
                 CreationalContext<T> creationalContext)
Get the bean if it exists in the contexts.

Type Parameters:
T - the type of contextual type
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.context.Context#get(Bean, boolean)

get

public <T> T get(Contextual<T> contextual)
Description copied from interface: Context
Return an existing instance of a contextual type or create a new instance of a contextual type

Type Parameters:
T - the type of the contextual type
Parameters:
contextual - the contextual type
Returns:
the contextual instance, or null if an instance does not exist in the context

destroy

public void destroy()
Destroys the context


getBeanStore

protected abstract BeanStore getBeanStore()
A method that returns the actual bean store implementation

Returns:
The bean store

isCreationLockRequired

protected abstract boolean isCreationLockRequired()
If Context need to inhibit concurrent instance creation then true, else false.

Returns:
need lock


Copyright © 2011. All Rights Reserved.