org.apache.cayenne.di.spi
Class DefaultScope

java.lang.Object
  extended by org.apache.cayenne.di.spi.DefaultScope
All Implemented Interfaces:
Scope

public class DefaultScope
extends java.lang.Object
implements Scope

An implementation of a DI scopes with support scope events.

Since:
3.1

Field Summary
protected  java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> eventTypes
           
protected  java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Collection<ScopeEventBinding>> listeners
           
 
Constructor Summary
DefaultScope(java.lang.Class<? extends java.lang.annotation.Annotation>... customEventTypes)
           
 
Method Summary
 void addScopeEventListener(java.lang.Object object)
          Registers annotated methods of an arbitrary object for this scope lifecycle events.
 void postScopeEvent(java.lang.Class<? extends java.lang.annotation.Annotation> type, java.lang.Object... eventParameters)
          Posts a scope event to all registered listeners.
 void removeScopeEventListener(java.lang.Object object)
           
<T> Provider<T>
scope(Provider<T> unscoped)
           
 void shutdown()
          Shuts down this scope, posting BeforeScopeEnd and AfterScopeEnd events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventTypes

protected java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> eventTypes

listeners

protected java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Collection<ScopeEventBinding>> listeners
Constructor Detail

DefaultScope

public DefaultScope(java.lang.Class<? extends java.lang.annotation.Annotation>... customEventTypes)
Method Detail

shutdown

public void shutdown()
Shuts down this scope, posting BeforeScopeEnd and AfterScopeEnd events.


addScopeEventListener

public void addScopeEventListener(java.lang.Object object)
Registers annotated methods of an arbitrary object for this scope lifecycle events.


removeScopeEventListener

public void removeScopeEventListener(java.lang.Object object)

postScopeEvent

public void postScopeEvent(java.lang.Class<? extends java.lang.annotation.Annotation> type,
                           java.lang.Object... eventParameters)
Posts a scope event to all registered listeners. There's no predetermined order of event dispatching. An exception thrown by any of the listeners stops further event processing and is rethrown.


scope

public <T> Provider<T> scope(Provider<T> unscoped)
Specified by:
scope in interface Scope


Copyright © 2001-2012 Apache Cayenne. All Rights Reserved.