You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by as...@apache.org on 2014/07/13 15:27:15 UTC

svn commit: r1610192 - in /onami/trunk/lifecycle: ./ jsr250/src/site/ jsr250/src/site/apt/ jsr250/src/test/ jsr250/src/test/java/ jsr250/src/test/java/org/ jsr250/src/test/java/org/apache/ jsr250/src/test/java/org/apache/onami/ jsr250/src/test/java/org...

Author: ash2k
Date: Sun Jul 13 13:27:15 2014
New Revision: 1610192

URL: http://svn.apache.org/r1610192
Log:
ONAMI-113 Remove Lifecycle Standard module

Move site and tests into JSR-250 module

Added:
    onami/trunk/lifecycle/jsr250/src/site/
    onami/trunk/lifecycle/jsr250/src/site/apt/
    onami/trunk/lifecycle/jsr250/src/site/apt/index.apt.vm
    onami/trunk/lifecycle/jsr250/src/site/apt/post-construct.apt
    onami/trunk/lifecycle/jsr250/src/site/apt/pre-destroy.apt
    onami/trunk/lifecycle/jsr250/src/site/site.xml
    onami/trunk/lifecycle/jsr250/src/test/
    onami/trunk/lifecycle/jsr250/src/test/java/
    onami/trunk/lifecycle/jsr250/src/test/java/org/
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/DisposableObject.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PostConstructTestCase.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyModuleTestCase.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyTestCase.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionAfterInjectionMethod.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor2.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionDisposeMethod.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongAfterInjectionMethod.java
    onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongPreDestroyMethod.java
Modified:
    onami/trunk/lifecycle/pom.xml

Added: onami/trunk/lifecycle/jsr250/src/site/apt/index.apt.vm
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/site/apt/index.apt.vm?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/site/apt/index.apt.vm (added)
+++ onami/trunk/lifecycle/jsr250/src/site/apt/index.apt.vm Sun Jul 13 13:27:15 2014
@@ -0,0 +1,56 @@
+                                    ------
+                                    Home
+                                    ------
+                                    The Apache Onami developers team
+                                    ------
+                                     2012
+
+~~
+~~ 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.
+~~
+
+Welcome to ${project.name}!
+
+  People often complained the Google Guice lack of support of EJB3.0 <<<...@PostConstruct>>> and <<<...@PreDestroy>>>
+  annotations to manage the injected objects lifecycle.
+
+  This small library aims to add that support in a lightweight yet dynamic way, allowing users define the annotations
+  type they want to use to mark methods to execute once the injection is performed and when shutting down the
+  application.
+
+Before starting
+
+  ${project.name} is available on the Maven Central repo, you just need to add the dependency below in your <<<pom.xml>>> file:
+
++--------------------------------------+
+<dependencies>
+  ...
+  <dependency>
+    <groupId>${project.groupId}</groupId>
+    <artifactId>${project.artifactId}</artifactId>
+    <version>${project.version}</version>
+  </dependency>
+  ...
+</dependencies>
++--------------------------------------+
+
+Features
+
+ * {{{./post-construct.html}Post-construction support}}
+
+ * {{{./pre-destroy.html}Pre-destruction support}}

Added: onami/trunk/lifecycle/jsr250/src/site/apt/post-construct.apt
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/site/apt/post-construct.apt?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/site/apt/post-construct.apt (added)
+++ onami/trunk/lifecycle/jsr250/src/site/apt/post-construct.apt Sun Jul 13 13:27:15 2014
@@ -0,0 +1,64 @@
+                                    ------
+                                    Home
+                                    ------
+                                    Post-construction callbacks
+                                    ------
+                                     2012
+
+~~
+~~ 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.
+~~
+
+Post-construction callbacks
+
+  Let's start on defining an object type that requires dependency injection and that a callback
+  has to be invoked once injection is complete:
+
++--------------------------------------+
+import javax.annotation.PostConstruct;
+import javax.inject.Singleton;
+
+@Singleton // not necessary, but let's add some spice
+public class MyServiceImpl
+{
+
+    @Inject
+    private Dependency dependency;
+
+    // setter omitted for simplicity
+
+    @PostConstruct
+    public void init()
+    {
+        ...
+    }
+
+}
++--------------------------------------+
+
+  All users have to do, is adding the <<<PostConstructModule>>> when creating the <<<Injector>>>:
+
++--------------------------------------+
+import static com.google.inject.Guice.createInjector;
+
+import org.apache.onami.lifecycle.jsr250.PostConstructModule;
+
+...
+
+Injector injector = createInjector( new PostConstructModule(), ... );
++--------------------------------------+

Added: onami/trunk/lifecycle/jsr250/src/site/apt/pre-destroy.apt
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/site/apt/pre-destroy.apt?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/site/apt/pre-destroy.apt (added)
+++ onami/trunk/lifecycle/jsr250/src/site/apt/pre-destroy.apt Sun Jul 13 13:27:15 2014
@@ -0,0 +1,148 @@
+                                    ------
+                                    Home
+                                    ------
+                                    Pre-destruction callbacks
+                                    ------
+                                     2012
+
+~~
+~~ 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.
+~~
+
+Pre-destruction callbacks
+
+  Let's start on defining an object type that requires dependency injection and that a callback
+  has to be invoked once application will be shutdown:
+
++--------------------------------------+
+import javax.annotation.PreDestroy;
+import javax.inject.Singleton;
+
+@Singleton // not necessary, but let's add some spice
+public class MyServiceImpl
+{
+
+    @Inject
+    private Dependency dependency;
+
+    // setter omitted for simplicity
+
+    @PreDestroy
+    public void tearDown()
+    {
+        ...
+    }
+
+}
++--------------------------------------+
+
+  All users have to do, is adding the <<<PreDestroyModule>>> when creating the <<<Injector>>>:
+
++--------------------------------------+
+import static com.google.inject.Guice.createInjector;
+
+import org.apache.onami.lifecycle.jsr250.PreDestroyModule;
+
+...
+
+Injector injector = createInjector( new PreDestroyModule(), ... );
++--------------------------------------+
+
+  Then, require the <<<org.apache.onami.lifecycle.core.Stager<PreDestroy>>>> injection to shutdown the application:
+
++--------------------------------------+
+import org.apache.onami.lifecycle.core.Stager;
+import com.google.inject.TypeLiteral;
+
+...
+
+Runtime.getRuntime().addShutdownHook( new Thread()
+{
+
+    public void run()
+    {
+        injector.getInstance( new TypeLiteral<Stager<PreDestroy>>() {} ).stage();
+        // or
+        // preDestroyModuleInstance.getStager().stage();
+    }
+
+} );
++--------------------------------------+
+
+  Of course, same concept can be applied to any listener <<<javax.servlet.ServletContextListener>>>:
+
++--------------------------------------+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import org.apache.onami.lifecycle.core.Stager;
+import com.google.inject.TypeLiteral;
+
+public final class ContextListener
+   implements ServletContextListener
+{
+
+    private Injector injector;
+
+    public void contextDestroyed( ServletContextEvent event )
+    {
+        injector.getInstance( new TypeLiteral<Stager<PreDestroy>>() {} ).stage();
+    }
+
+    public void contextInitialized( ServletContextEvent event )
+    {
+        ...
+    }
+
+}
++--------------------------------------+
+
+Dispose Handling
+
+  Users interested on tracking/logging/... objects dispose progresses, can register a
+  <<<org.apache.onami.lifecycle.core.StageHandler>>>, which has the following methods signatures:
+
++--------------------------------------+
+public interface StageHandler
+{
+
+    <I> void onSuccess( I injectee );
+
+    <I, E extends Throwable> void onError( I injectee, E error );
+
+}
++--------------------------------------+
+
+  A <<<StageHandler>>> instance can be passed to <<<Stager#stage()>>> method:
+
++--------------------------------------+
+injector.getInstance( new TypeLiteral<Stager<PreDestroy>>() {} ).stage( new StageHandler()
+{
+
+    public <I> void onSuccess( I injectee )
+    {
+        logger.info( "Object {} successfully released resources", injectee );
+    }
+
+    public <I, E extends Throwable> void onError( I injectee, E error )
+    {
+        logger.error( "Impossible to release resources of " + injectee, error );
+    }
+
+} );
++--------------------------------------+

Added: onami/trunk/lifecycle/jsr250/src/site/site.xml
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/site/site.xml?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/site/site.xml (added)
+++ onami/trunk/lifecycle/jsr250/src/site/site.xml Sun Jul 13 13:27:15 2014
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ | 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.
+-->
+<project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"
+  name="${project.name}">
+
+  <body>
+    <head>
+      <link rel="meta" title="DOAP" href="${project.url}/doap.rdf" type="application/rdf+xml" />
+    </head>
+
+    <menu name="Apache Onami™ Lifecycle Standard">
+      <item name="Home" href="index.html" />
+      <item name="Post-construction" href="post-construct.html" />
+      <item name="Pre-destruction" href="pre-destroy.html" />
+      <item name="Back" href="../index.html" />
+    </menu>
+
+    <menu ref="reports"/>
+
+    <footer>
+      <div class="row span12">
+        Apache Onami, Apache Onami Lifecycle, Apache, the Apache feather logo, and the Apache Onami project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </footer>
+  </body>
+
+</project>

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/DisposableObject.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/DisposableObject.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/DisposableObject.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/DisposableObject.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,35 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import javax.annotation.PreDestroy;
+
+public final class DisposableObject
+{
+
+    boolean disposed = false;
+
+    @PreDestroy
+    public void dispose()
+    {
+        disposed  = true;
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PostConstructTestCase.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PostConstructTestCase.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PostConstructTestCase.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PostConstructTestCase.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,63 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.ProvisionException;
+import org.junit.Test;
+
+import javax.annotation.PostConstruct;
+
+import static com.google.inject.Guice.createInjector;
+import static org.junit.Assert.assertTrue;
+
+public final class PostConstructTestCase
+{
+
+    private boolean afterInjectionInvoked = false;
+
+    @PostConstruct
+    public void init()
+    {
+        afterInjectionInvoked = true;
+    }
+
+    @Test
+    public void afterInjectionAnnotatedMethodInvocation()
+    {
+        createInjector( new PostConstructModule() )
+            .getMembersInjector( PostConstructTestCase.class )
+            .injectMembers( this );
+        assertTrue( afterInjectionInvoked );
+    }
+
+    @Test( expected = ConfigurationException.class )
+    public void afterInjectionAnnotatedMethodRequiresNoArgs()
+    {
+        createInjector( new PostConstructModule() ).getInstance( WrongAfterInjectionMethod.class );
+    }
+
+    @Test( expected = ProvisionException.class )
+    public void afterInjectionAnnotatedMethodThrowsException()
+    {
+        createInjector( new PostConstructModule() ).getInstance( ThrowingExceptionAfterInjectionMethod.class );
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyModuleTestCase.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyModuleTestCase.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyModuleTestCase.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyModuleTestCase.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,137 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import com.google.inject.AbstractModule;
+import com.google.inject.CreationException;
+import com.google.inject.Provides;
+import org.apache.onami.lifecycle.core.DisposingStager;
+import org.apache.onami.lifecycle.core.StageHandler;
+import org.junit.Test;
+
+import javax.annotation.PreDestroy;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static com.google.inject.Guice.createInjector;
+import static org.junit.Assert.*;
+
+public final class PreDestroyModuleTestCase
+{
+
+    @Test
+    public void disposeUsingModuleOnInjectorFailure()
+    {
+        PreDestroyModule preDestroyModule = new PreDestroyModule();
+        try
+        {
+            createInjector( preDestroyModule, new AbstractModule()
+            {
+
+                @Override
+                protected void configure()
+                {
+                    bind( ThrowingExceptionConstructor.class ).asEagerSingleton();
+                }
+
+            } );
+            fail( "Expected exception was not thrown" );
+        }
+        catch( CreationException e )
+        {
+            Throwable cause = e.getCause();
+            assertTrue( cause instanceof IllegalArgumentException );
+            assertEquals( "Expected exception", cause.getMessage() );
+        }
+        finally
+        {
+            preDestroyModule.getStager().stage( new StageHandler()
+            {
+
+                @Override
+                public <I> void onSuccess( I injectee )
+                {
+                    assertTrue( injectee instanceof DisposableObject );
+                    assertTrue( ( (DisposableObject) injectee ).disposed );
+                }
+
+                @Override
+                public <I, E extends Throwable> void onError( I injectee, E error )
+                {
+                    fail( error.toString() );
+                }
+
+            } );
+        }
+    }
+
+    @Test
+    public void disposeUsingModuleWithProvidesMethodOnInjectorFailure()
+    {
+        PreDestroyModule preDestroyModule = new PreDestroyModule();
+        try
+        {
+            createInjector( preDestroyModule, new AbstractModule()
+            {
+
+                @Override
+                protected void configure()
+                {
+                    bind( ThrowingExceptionConstructor2.class ).asEagerSingleton();
+                }
+
+                @Provides
+                public ExecutorService provideExecutorService( DisposingStager<PreDestroy> stager )
+                {
+                    return stager.register( Executors.newCachedThreadPool() );
+                }
+
+            } );
+            fail( "Expected exception was not thrown" );
+        }
+        catch( CreationException e )
+        {
+            Throwable cause = e.getCause();
+            assertTrue( cause instanceof IllegalArgumentException );
+            assertEquals( "Expected exception", cause.getMessage() );
+        }
+        finally
+        {
+            preDestroyModule.getStager().stage( new StageHandler()
+            {
+
+                @Override
+                public <I> void onSuccess( I injectee )
+                {
+                    assertTrue( injectee instanceof ExecutorService );
+                    assertTrue( ( (ExecutorService) injectee ).isShutdown() );
+                }
+
+                @Override
+                public <I, E extends Throwable> void onError( I injectee, E error )
+                {
+                    fail( error.toString() );
+                }
+
+            } );
+        }
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyTestCase.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyTestCase.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyTestCase.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/PreDestroyTestCase.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,109 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import com.google.inject.AbstractModule;
+import com.google.inject.ConfigurationException;
+
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+import org.apache.onami.lifecycle.core.StageHandler;
+import org.apache.onami.lifecycle.core.Stager;
+import org.junit.Before;
+import org.junit.Test;
+
+import static com.google.inject.Guice.createInjector;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public final class PreDestroyTestCase
+{
+
+    @Inject
+    private Stager<PreDestroy> stager;
+
+    private boolean closeInvoked = false;
+
+    public void setStager( Stager<PreDestroy> stager )
+    {
+        this.stager = stager;
+    }
+
+    @PreDestroy
+    public void close()
+    {
+        closeInvoked = true;
+    }
+
+    @Before
+    public void setUp()
+    {
+        createInjector( new PreDestroyModule() )
+            .getMembersInjector( PreDestroyTestCase.class )
+            .injectMembers( this );
+    }
+
+    @Test
+    public void closeMethodInvoked()
+    {
+        stager.stage();
+        assertTrue( closeInvoked );
+    }
+
+    @Test( expected = ConfigurationException.class )
+    public void preDestroyAnnotatedMethodRequiresNoArgs()
+    {
+        createInjector( new PreDestroyModule() ).getInstance( WrongPreDestroyMethod.class );
+    }
+
+    @Test//( expected = ConfigurationException.class )
+    public void disposeAnnotatedMethodThrowsException()
+    {
+        createInjector( new PreDestroyModule(), new AbstractModule()
+        {
+
+            @Override
+            protected void configure()
+            {
+                bind( ThrowingExceptionDisposeMethod.class ).toInstance( new ThrowingExceptionDisposeMethod() );
+            }
+
+        } ).getInstance( Key.get( new TypeLiteral<Stager<PreDestroy>>() {} ) ).stage( new StageHandler()
+        {
+
+            @Override
+            public <I> void onSuccess( I injectee )
+            {
+                fail();
+            }
+
+            @Override
+            public <I, E extends Throwable> void onError( I injectee, E error )
+            {
+                assertTrue( injectee instanceof ThrowingExceptionDisposeMethod );
+                assertTrue( error instanceof IllegalStateException );
+            }
+
+        } );
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionAfterInjectionMethod.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionAfterInjectionMethod.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionAfterInjectionMethod.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionAfterInjectionMethod.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,33 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import javax.annotation.PostConstruct;
+
+public final class ThrowingExceptionAfterInjectionMethod
+{
+
+    @PostConstruct
+    public void init()
+    {
+        throw new IllegalStateException();
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,33 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import javax.inject.Inject;
+
+public final class ThrowingExceptionConstructor
+{
+
+    @Inject
+    public ThrowingExceptionConstructor( DisposableObject disposableObject )
+    {
+        throw new IllegalArgumentException( "Expected exception" );
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor2.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor2.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor2.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionConstructor2.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,34 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import javax.inject.Inject;
+import java.util.concurrent.ExecutorService;
+
+public final class ThrowingExceptionConstructor2
+{
+
+    @Inject
+    public ThrowingExceptionConstructor2( ExecutorService executorService )
+    {
+        throw new IllegalArgumentException( "Expected exception" );
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionDisposeMethod.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionDisposeMethod.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionDisposeMethod.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/ThrowingExceptionDisposeMethod.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,33 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import javax.annotation.PreDestroy;
+
+public final class ThrowingExceptionDisposeMethod
+{
+
+    @PreDestroy
+    public void close()
+    {
+        throw new IllegalStateException();
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongAfterInjectionMethod.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongAfterInjectionMethod.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongAfterInjectionMethod.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongAfterInjectionMethod.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,33 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import javax.annotation.PostConstruct;
+
+public final class WrongAfterInjectionMethod
+{
+
+    @PostConstruct
+    public void init( String misplacedArg )
+    {
+        // do nothing
+    }
+
+}

Added: onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongPreDestroyMethod.java
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongPreDestroyMethod.java?rev=1610192&view=auto
==============================================================================
--- onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongPreDestroyMethod.java (added)
+++ onami/trunk/lifecycle/jsr250/src/test/java/org/apache/onami/lifecycle/jsr250/WrongPreDestroyMethod.java Sun Jul 13 13:27:15 2014
@@ -0,0 +1,33 @@
+package org.apache.onami.lifecycle.jsr250;
+
+/*
+ * 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.
+ */
+
+import javax.annotation.PreDestroy;
+
+public final class WrongPreDestroyMethod
+{
+
+    @PreDestroy
+    public void close( Integer misplacedArg )
+    {
+        // do nothing
+    }
+
+}

Modified: onami/trunk/lifecycle/pom.xml
URL: http://svn.apache.org/viewvc/onami/trunk/lifecycle/pom.xml?rev=1610192&r1=1610191&r2=1610192&view=diff
==============================================================================
--- onami/trunk/lifecycle/pom.xml (original)
+++ onami/trunk/lifecycle/pom.xml Sun Jul 13 13:27:15 2014
@@ -38,7 +38,6 @@
 
   <modules>
     <module>core</module>
-    <module>standard</module>
     <module>jsr250</module>
     <module>warmup</module>
   </modules>