cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r952696 - in /cayenne/main/trunk/framework/cayenne-di-unpublished/src: main/java/org/apache/cayenne/di/ main/java/org/apache/cayenne/di/spi/ test/java/org/apache/cayenne/di/mock/ test/java/org/apache/cayenne/di/spi/
Date Tue, 08 Jun 2010 15:35:19 GMT
Author: aadamchik
Date: Tue Jun  8 15:35:18 2010
New Revision: 952696

URL: http://svn.apache.org/viewvc?rev=952696&view=rev
Log:
CAY-1421 CayenneRuntime shutdown functionality

* annotation-based scope events
* Singleton scope support for @OnScopeEnd event

Added:
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/OnScopeEnd.java
      - copied, changed from r952695, cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/EventfulScope.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ScopeEventBinding.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotations.java
      - copied, changed from r952695, cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotationsBase.java
      - copied, changed from r952695, cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
Modified:
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonProvider.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorScopeTest.java

Copied: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/OnScopeEnd.java
(from r952695, cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/OnScopeEnd.java?p2=cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/OnScopeEnd.java&p1=cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java&r1=952695&r2=952696&rev=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/OnScopeEnd.java
Tue Jun  8 15:35:18 2010
@@ -18,13 +18,24 @@
  ****************************************************************/
 package org.apache.cayenne.di;
 
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 /**
- * Defines the scope of the instances created by the DI container. The default scope of a
- * binding results in creation of a new object instance on every call to the Injector.
+ * An annotation used by objects that want to receive scope ending events from the DI
+ * registry.
+ * <p>
+ * Annotated method must be public and have no parameters. Return type is ignored by the
+ * event dispatcher.
  * 
  * @since 3.1
  */
-public interface Scope {
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface OnScopeEnd {
 
-    <T> Provider<T> scope(Provider<T> unscoped);
 }

Modified: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java?rev=952696&r1=952695&r2=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/Scope.java
Tue Jun  8 15:35:18 2010
@@ -19,8 +19,13 @@
 package org.apache.cayenne.di;
 
 /**
- * Defines the scope of the instances created by the DI container. The default scope of a
- * binding results in creation of a new object instance on every call to the Injector.
+ * Defines the scope of the instances created by the DI container. I.e. whether instances
+ * are shared between the callers, and for how longs or whether they are created anew.
+ * Scope object is also used to tie DI-produced instances to the Injector events, such as
+ * shutdown.
+ * <p>
+ * Cayenne defines a few standard scopes in {@link Scopes} class. The default scope of a
+ * binding in Cayenne is {@link Scopes#SINGLETON}.
  * 
  * @since 3.1
  */

Modified: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java?rev=952696&r1=952695&r2=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
Tue Jun  8 15:35:18 2010
@@ -35,7 +35,7 @@ import org.apache.cayenne.di.Scope;
  */
 public class DefaultInjector implements Injector {
 
-    private Scope singletonScope;
+    private SingletonScope singletonScope;
     private Scope noScope;
 
     private Map<Key<?>, Binding<?>> bindings;
@@ -137,11 +137,12 @@ public class DefaultInjector implements 
         provider1.get();
     }
 
-    Scope getSingletonScope() {
+    SingletonScope getSingletonScope() {
         return singletonScope;
     }
 
     Scope getNoScope() {
         return noScope;
     }
+
 }

Added: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/EventfulScope.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/EventfulScope.java?rev=952696&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/EventfulScope.java
(added)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/EventfulScope.java
Tue Jun  8 15:35:18 2010
@@ -0,0 +1,108 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.di.spi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.cayenne.di.Provider;
+import org.apache.cayenne.di.Scope;
+
+/**
+ * A base superclass of DI scopes that send scope events.
+ * 
+ * @since 3.1
+ */
+public abstract class EventfulScope implements Scope {
+
+    protected ConcurrentMap<String, Collection<ScopeEventBinding>> listeners;
+    protected Collection<Class<? extends Annotation>> eventAnnotations;
+
+    public EventfulScope() {
+        this.listeners = new ConcurrentHashMap<String, Collection<ScopeEventBinding>>();
+        this.eventAnnotations = new HashSet<Class<? extends Annotation>>();
+    }
+
+    /**
+     * Adds an annotation type that marks handler methods for a specific event type.
+     * Subclasses of EventfulScope should use this method to configure supported
+     * annotation types. This method should be invoked before any calls to
+     * {@link #addScopeEventListener(Object)}. Often it is invoked form the scope
+     * constructor.
+     */
+    protected void addEventAnnotation(Class<? extends Annotation> annotationType) {
+        eventAnnotations.add(annotationType);
+    }
+
+    /**
+     * Registers annotated methods of an arbitrary object for this scope lifecycle events.
+     */
+    public void addScopeEventListener(Object object) {
+
+        // not caching metadata for now, as all services in SingletonScope are unique...
+        // If we start using RequestScope or similar, may need to figure out per-class
+        // metadata cache.
+
+        // 'getMethods' grabs public method from the class and its superclasses...
+        for (Method method : object.getClass().getMethods()) {
+
+            for (Class<? extends Annotation> annotationType : eventAnnotations) {
+
+                if (method.isAnnotationPresent(annotationType)) {
+                    String typeName = annotationType.getName();
+
+                    Collection<ScopeEventBinding> newListeners = new CopyOnWriteArrayList<ScopeEventBinding>();
+                    Collection<ScopeEventBinding> eventListeners = listeners.putIfAbsent(
+                            typeName,
+                            newListeners);
+                    if (eventListeners == null) {
+                        eventListeners = newListeners;
+                    }
+
+                    eventListeners.add(new ScopeEventBinding(object, method));
+                }
+            }
+        }
+    }
+
+    /**
+     * 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.
+     */
+    protected void postScopeEvent(
+            Class<? extends Annotation> type,
+            Object... eventParameters) {
+
+        Collection<ScopeEventBinding> eventListeners = listeners.get(type.getName());
+
+        if (eventListeners != null) {
+            for (ScopeEventBinding listener : eventListeners) {
+                listener.onScopeEvent(eventParameters);
+            }
+        }
+    }
+
+    public abstract <T> Provider<T> scope(Provider<T> unscoped);
+}

Added: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ScopeEventBinding.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ScopeEventBinding.java?rev=952696&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ScopeEventBinding.java
(added)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ScopeEventBinding.java
Tue Jun  8 15:35:18 2010
@@ -0,0 +1,69 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.di.spi;
+
+import java.lang.reflect.Method;
+
+import org.apache.cayenne.CayenneRuntimeException;
+
+/**
+ * A class that wraps an annotated method call of an object, passing it DI scope events.
+ * 
+ * @since 3.1
+ */
+class ScopeEventBinding {
+
+    private Object object;
+    private Method eventHandlerMethod;
+    private int argWidth;
+
+    ScopeEventBinding(Object object, Method eventHandlerMethod) {
+        this.object = object;
+        this.eventHandlerMethod = eventHandlerMethod;
+        this.argWidth = eventHandlerMethod.getParameterTypes().length;
+    }
+
+    void onScopeEvent(Object... eventArgs) {
+
+        try {
+            eventHandlerMethod.invoke(object, invocationArguments(eventArgs));
+        }
+        catch (Exception e) {
+            throw new CayenneRuntimeException(
+                    "Error invoking event method %s",
+                    e,
+                    eventHandlerMethod.getName());
+        }
+    }
+
+    private Object[] invocationArguments(Object[] eventArgs) {
+
+        int eventArgWidth = (eventArgs == null) ? 0 : eventArgs.length;
+
+        if (argWidth != eventArgWidth) {
+            throw new CayenneRuntimeException(
+                    "Event argument list size (%d) is different "
+                            + "from the handler method argument list size (%d)",
+                    eventArgWidth,
+                    argWidth);
+        }
+
+        return eventArgs;
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonProvider.java?rev=952696&r1=952695&r2=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonProvider.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonProvider.java
Tue Jun  8 15:35:18 2010
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.di.spi;
 
+import org.apache.cayenne.ConfigurationException;
 import org.apache.cayenne.di.Provider;
 
 /**
@@ -26,11 +27,13 @@ import org.apache.cayenne.di.Provider;
 class SingletonProvider<T> implements Provider<T> {
 
     private Provider<T> delegate;
+    private SingletonScope scope;
 
     // presumably "volatile" works in Java 5 and newer to prevent double-checked locking
     private volatile T instance;
 
-    public SingletonProvider(Provider<T> delegate) {
+    public SingletonProvider(SingletonScope scope, Provider<T> delegate) {
+        this.scope = scope;
         this.delegate = delegate;
     }
 
@@ -40,6 +43,14 @@ class SingletonProvider<T> implements Pr
             synchronized (this) {
                 if (instance == null) {
                     instance = delegate.get();
+
+                    if (instance == null) {
+                        throw new ConfigurationException(
+                                "Underlying provider (%s) returned NULL instance",
+                                delegate.getClass().getName());
+                    }
+
+                    scope.addScopeEventListener(instance);
                 }
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java?rev=952696&r1=952695&r2=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
Tue Jun  8 15:35:18 2010
@@ -18,15 +18,20 @@
  ****************************************************************/
 package org.apache.cayenne.di.spi;
 
+import org.apache.cayenne.di.OnScopeEnd;
 import org.apache.cayenne.di.Provider;
-import org.apache.cayenne.di.Scope;
 
 /**
  * @since 3.1
  */
-class SingletonScope implements Scope {
+class SingletonScope extends EventfulScope {
 
+    SingletonScope() {
+        addEventAnnotation(OnScopeEnd.class);
+    }
+
+    @Override
     public <T> Provider<T> scope(Provider<T> unscoped) {
-        return new SingletonProvider<T>(unscoped);
+        return new SingletonProvider<T>(this, unscoped);
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotations.java
(from r952695, cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotations.java?p2=cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotations.java&p1=cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java&r1=952695&r2=952696&rev=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotations.java
Tue Jun  8 15:35:18 2010
@@ -16,17 +16,24 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.di.spi;
+package org.apache.cayenne.di.mock;
 
-import org.apache.cayenne.di.Provider;
-import org.apache.cayenne.di.Scope;
+import org.apache.cayenne.di.OnScopeEnd;
 
-/**
- * @since 3.1
- */
-class SingletonScope implements Scope {
+public class MockImplementation1_EventAnnotations extends
+        MockImplementation1_EventAnnotationsBase implements MockInterface1 {
 
-    public <T> Provider<T> scope(Provider<T> unscoped) {
-        return new SingletonProvider<T>(unscoped);
+    public String getName() {
+        return "XuI";
+    }
+
+    @OnScopeEnd
+    public void onShutdown1() {
+        shutdown1 = true;
+    }
+
+    @OnScopeEnd
+    public void onShutdown2() {
+        shutdown2 = true;
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotationsBase.java
(from r952695, cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotationsBase.java?p2=cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotationsBase.java&p1=cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java&r1=952695&r2=952696&rev=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/SingletonScope.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/mock/MockImplementation1_EventAnnotationsBase.java
Tue Jun  8 15:35:18 2010
@@ -16,17 +16,24 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.di.spi;
+package org.apache.cayenne.di.mock;
 
-import org.apache.cayenne.di.Provider;
-import org.apache.cayenne.di.Scope;
+import org.apache.cayenne.di.OnScopeEnd;
 
-/**
- * @since 3.1
- */
-class SingletonScope implements Scope {
+public class MockImplementation1_EventAnnotationsBase {
 
-    public <T> Provider<T> scope(Provider<T> unscoped) {
-        return new SingletonProvider<T>(unscoped);
+    public static boolean shutdown1;
+    public static boolean shutdown2;
+    public static boolean shutdown3;
+
+    public static void reset() {
+        shutdown1 = false;
+        shutdown2 = false;
+        shutdown3 = false;
+    }
+
+    @OnScopeEnd
+    public void onShutdown3() {
+        shutdown3 = true;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorScopeTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorScopeTest.java?rev=952696&r1=952695&r2=952696&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorScopeTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorScopeTest.java
Tue Jun  8 15:35:18 2010
@@ -22,7 +22,9 @@ import junit.framework.TestCase;
 
 import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.Module;
+import org.apache.cayenne.di.OnScopeEnd;
 import org.apache.cayenne.di.mock.MockImplementation1;
+import org.apache.cayenne.di.mock.MockImplementation1_EventAnnotations;
 import org.apache.cayenne.di.mock.MockInterface1;
 
 public class DefaultInjectorScopeTest extends TestCase {
@@ -103,4 +105,32 @@ public class DefaultInjectorScopeTest ex
         assertSame(instance2, instance3);
     }
 
+    public void testSingletonScope_AnnotatedEvents() {
+
+        MockImplementation1_EventAnnotations.reset();
+
+        Module module = new Module() {
+
+            public void configure(Binder binder) {
+                binder.bind(MockInterface1.class).to(
+                        MockImplementation1_EventAnnotations.class).inSingletonScope();
+            }
+        };
+
+        DefaultInjector injector = new DefaultInjector(module);
+
+        MockInterface1 instance1 = injector.getInstance(MockInterface1.class);
+        assertEquals("XuI", instance1.getName());
+
+        assertFalse(MockImplementation1_EventAnnotations.shutdown1);
+        assertFalse(MockImplementation1_EventAnnotations.shutdown2);
+        assertFalse(MockImplementation1_EventAnnotations.shutdown3);
+
+        injector.getSingletonScope().postScopeEvent(OnScopeEnd.class);
+
+        assertTrue(MockImplementation1_EventAnnotations.shutdown1);
+        assertTrue(MockImplementation1_EventAnnotations.shutdown2);
+        assertTrue(MockImplementation1_EventAnnotations.shutdown3);
+
+    }
 }



Mime
View raw message