org.directwebremoting.guice
Class AbstractMapContextScope<C>

java.lang.Object
  extended by org.directwebremoting.guice.AbstractContextScope<C,java.util.concurrent.ConcurrentMap>
      extended by org.directwebremoting.guice.AbstractMapContextScope<C>
All Implemented Interfaces:
com.google.inject.Provider<C>, com.google.inject.Scope, ContextRegistry<C,java.util.concurrent.ConcurrentMap>, ContextScope<C>

public abstract class AbstractMapContextScope<C>
extends AbstractContextScope<C,java.util.concurrent.ConcurrentMap>

A specialization of AbstractContextScope using a concurrent map to hold registered instance providers. Concrete implementations must define get() to return the current context, and they must call super(C.class) in constructors.

Author:
Tim Peierls [tim at peierls dot net]

Method Summary
abstract  C get()
          The context identifier used to look up an instance registry.
<T> InstanceProvider<T>
get(java.util.concurrent.ConcurrentMap registry, com.google.inject.Key<T> key, java.lang.String keyString)
          Looks up an InstanceProvider for a key (either directly or using the precalculated key.toString() value) in a registry object, returning null if not found.
<T> InstanceProvider<T>
putIfAbsent(java.util.concurrent.ConcurrentMap registry, com.google.inject.Key<T> key, java.lang.String keyString, InstanceProvider<T> creator)
          Looks up an InstanceProvider for a key (either directly or using the precalculated key.toString() value) in a registry object, returning null if not found, otherwise returning the existing value.
 java.util.concurrent.ConcurrentMap registryFor(C context)
          Returns the registry object associated with the given context.
<T> boolean
remove(java.util.concurrent.ConcurrentMap registry, com.google.inject.Key<T> key, java.lang.String keyString, InstanceProvider<T> creator)
          Removes the registry entry for the given key (either directly or using the precalculated key.toString() value) from a registry object if the registered value is identical to creator.
 
Methods inherited from class org.directwebremoting.guice.AbstractContextScope
close, closeAll, getKeysInScope, getOpenContexts, scope, toString, type
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

get

public abstract C get()
Description copied from interface: ContextScope
The context identifier used to look up an instance registry. The value returned is a function of the current context.

Specified by:
get in interface com.google.inject.Provider<C>
Specified by:
get in interface ContextScope<C>
Specified by:
get in class AbstractContextScope<C,java.util.concurrent.ConcurrentMap>

registryFor

public java.util.concurrent.ConcurrentMap registryFor(C context)
Description copied from interface: ContextRegistry
Returns the registry object associated with the given context.


get

public <T> InstanceProvider<T> get(java.util.concurrent.ConcurrentMap registry,
                                   com.google.inject.Key<T> key,
                                   java.lang.String keyString)
Description copied from interface: ContextRegistry
Looks up an InstanceProvider for a key (either directly or using the precalculated key.toString() value) in a registry object, returning null if not found.


putIfAbsent

public <T> InstanceProvider<T> putIfAbsent(java.util.concurrent.ConcurrentMap registry,
                                           com.google.inject.Key<T> key,
                                           java.lang.String keyString,
                                           InstanceProvider<T> creator)
Description copied from interface: ContextRegistry
Looks up an InstanceProvider for a key (either directly or using the precalculated key.toString() value) in a registry object, returning null if not found, otherwise returning the existing value.


remove

public <T> boolean remove(java.util.concurrent.ConcurrentMap registry,
                          com.google.inject.Key<T> key,
                          java.lang.String keyString,
                          InstanceProvider<T> creator)
Description copied from interface: ContextRegistry
Removes the registry entry for the given key (either directly or using the precalculated key.toString() value) from a registry object if the registered value is identical to creator.

Returns:
whether the value was removed

Copyright ? 2005