org.directwebremoting.guice.util
Class AbstractContextScope<C,R>

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

public abstract class AbstractContextScope<C,R>
extends java.lang.Object
implements ContextScope<C>, ContextRegistry<C,R>

Partial implementation of ContextScope. Concrete implementations must pass the context identifier type to the super constructor and define get() to return the current context identifier (and to return null or throw an exception if there is no current context). They must also implement the ContextRegistry interface.

Author:
Tim Peierls [tim at peierls dot net]

Method Summary
 void close(C context, ContextCloseHandler<?>... closeHandlers)
          Closes the given context.
 void closeAll(ContextCloseHandler<?>... closeHandlers)
          Closes all open contexts.
abstract  C get()
          The context identifier used to look up an instance registry.
 java.util.List<com.google.inject.Key<?>> getKeysInScope()
          The keys bound in this scope.
 java.util.Collection<C> getOpenContexts()
          The context identifiers of all open contexts that this scope knows about.
<T> com.google.inject.Provider<T>
scope(com.google.inject.Key<T> key, com.google.inject.Provider<T> creator)
          Returns a provider that finds the instance registry corresponding to the current context and returns the object registered with the given key, creating it if it doesn't exist in the registry.
 java.lang.String toString()
           
 java.lang.Class<C> type()
          The type of object used as a context identifier.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.directwebremoting.guice.util.ContextRegistry
get, putIfAbsent, registryFor, remove
 

Method Detail

toString

public java.lang.String toString()
Specified by:
toString in interface com.google.inject.Scope
Overrides:
toString in class java.lang.Object

getKeysInScope

public java.util.List<com.google.inject.Key<?>> getKeysInScope()
Description copied from interface: ContextScope
The keys bound in this scope.

Specified by:
getKeysInScope in interface ContextScope<C>

scope

public <T> com.google.inject.Provider<T> scope(com.google.inject.Key<T> key,
                                               com.google.inject.Provider<T> creator)
Description copied from interface: ContextScope
Returns a provider that finds the instance registry corresponding to the current context and returns the object registered with the given key, creating it if it doesn't exist in the registry.

Specified by:
scope in interface com.google.inject.Scope
Specified by:
scope in interface ContextScope<C>

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>

type

public java.lang.Class<C> type()
Description copied from interface: ContextScope
The type of object used as a context identifier.

Specified by:
type in interface ContextScope<C>

getOpenContexts

public java.util.Collection<C> getOpenContexts()
Description copied from interface: ContextScope
The context identifiers of all open contexts that this scope knows about.

Specified by:
getOpenContexts in interface ContextScope<C>

close

public void close(C context,
                  ContextCloseHandler<?>... closeHandlers)
Description copied from interface: ContextScope
Closes the given context.

Specified by:
close in interface ContextScope<C>

closeAll

public void closeAll(ContextCloseHandler<?>... closeHandlers)
Description copied from interface: ContextScope
Closes all open contexts.

Specified by:
closeAll in interface ContextScope<C>

Copyright 2008