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

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

public abstract class AbstractSimpleContextScope<C>
extends AbstractContextScope<C,C>

A specialization of AbstractContextScope for the case when the context identifier itself can serve as a string-keyed instance registry using synchronization on the context to provide atomic put-if-absent and remove-specific-value behavior.

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(C 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.
abstract  java.lang.Object get(C registry, java.lang.String keyString)
           
<T> void
put(C registry, com.google.inject.Key<T> key, java.lang.String keyString, InstanceProvider<T> creator)
           
abstract  void put(C registry, java.lang.String keyString, java.lang.Object creator)
           
<T> InstanceProvider<T>
putIfAbsent(C 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.
 C registryFor(C context)
          Returns the registry object associated with the given context.
<T> boolean
remove(C 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,C>

get

public abstract java.lang.Object get(C registry,
                                     java.lang.String keyString)

put

public abstract void put(C registry,
                         java.lang.String keyString,
                         java.lang.Object creator)

registryFor

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


get

public <T> InstanceProvider<T> get(C 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.


put

public <T> void put(C registry,
                    com.google.inject.Key<T> key,
                    java.lang.String keyString,
                    InstanceProvider<T> creator)

putIfAbsent

public <T> InstanceProvider<T> putIfAbsent(C 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(C 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