org.directwebremoting.guice.util
Class AbstractMapContextScope<C>

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

public abstract class AbstractMapContextScope<C>
extends AbstractContextScope<C,InstanceMap<?>>

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(InstanceMap<?> 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(InstanceMap<?> 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.
 InstanceMap<?> registryFor(C context)
          Returns the registry object associated with the given context.
<T> boolean
remove(InstanceMap<?> 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.util.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,InstanceMap<?>>

registryFor

public InstanceMap<?> registryFor(C context)
Description copied from interface: ContextRegistry
Returns the registry object associated with the given context.


get

public <T> InstanceProvider<T> get(InstanceMap<?> 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(InstanceMap<?> 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(InstanceMap<?> 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 2008