james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [03/10] james-project git commit: JAMES-1738 Reformat Onami lifeCycle
Date Fri, 07 Oct 2016 12:11:32 GMT
JAMES-1738 Reformat Onami lifeCycle


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7de2a019
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7de2a019
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7de2a019

Branch: refs/heads/master
Commit: 7de2a019aa29cbdfd9a9db840126a2d66148cc81
Parents: c1f94a4
Author: Benoit Tellier <btellier@linagora.com>
Authored: Wed Oct 5 11:45:00 2016 +0200
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Oct 5 14:57:35 2016 +0200

----------------------------------------------------------------------
 .../onami/lifecycle/AbstractBasicStageable.java |  10 +-
 .../lifecycle/AbstractMethodTypeListener.java   |  49 +++----
 .../onami/lifecycle/AbstractStageable.java      |  23 ++--
 .../james/onami/lifecycle/DefaultStager.java    | 108 ++++++---------
 .../james/onami/lifecycle/DisposingStager.java  |   7 +-
 .../james/onami/lifecycle/LifeCycleModule.java  |  85 +++++-------
 .../onami/lifecycle/LifeCycleStageModule.java   | 131 ++++++++-----------
 .../james/onami/lifecycle/NoOpStageHandler.java |  10 +-
 .../lifecycle/NoOpStageableTypeMapper.java      |   7 +-
 .../james/onami/lifecycle/PreDestroyModule.java |  21 ++-
 .../james/onami/lifecycle/StageHandler.java     |   7 +-
 .../apache/james/onami/lifecycle/Stageable.java |   5 +-
 .../james/onami/lifecycle/StageableMethod.java  |  43 +++---
 .../onami/lifecycle/StageableTypeMapper.java    |   9 +-
 .../apache/james/onami/lifecycle/Stager.java    |   7 +-
 .../onami/lifecycle/DefaultStagerTestCase.java  |  70 ++++------
 .../onami/lifecycle/MultiLifeCycleObject.java   |  41 +++---
 .../onami/lifecycle/MultiLifeCycleTestCase.java | 130 ++++++++----------
 .../james/onami/lifecycle/StageObject1.java     |  16 +--
 .../james/onami/lifecycle/StageObject2.java     |  16 +--
 .../onami/lifecycle/StagingOrderTestCase.java   |  66 +++-------
 .../james/onami/lifecycle/TestAnnotationA.java  |   9 +-
 .../james/onami/lifecycle/TestAnnotationB.java  |  13 +-
 .../james/onami/lifecycle/TestAnnotationC.java  |  13 +-
 24 files changed, 339 insertions(+), 557 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractBasicStageable.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractBasicStageable.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractBasicStageable.java
index a065a55..0d13a2f 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractBasicStageable.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractBasicStageable.java
@@ -24,17 +24,14 @@ package org.apache.james.onami.lifecycle;
  *
  * @author Mikhail Mazursky
  */
-public abstract class AbstractBasicStageable<S>
-    implements Stageable
-{
+public abstract class AbstractBasicStageable<S> implements Stageable {
 
     /**
      * Object to stage.
      */
     protected final S object;
 
-    protected AbstractBasicStageable( S object )
-    {
+    protected AbstractBasicStageable(S object) {
         this.object = object;
     }
 
@@ -42,8 +39,7 @@ public abstract class AbstractBasicStageable<S>
      * {@inheritDoc}
      */
     @Override
-    public final String toString()
-    {
+    public final String toString() {
         return object.toString();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractMethodTypeListener.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractMethodTypeListener.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractMethodTypeListener.java
index 6ae63c5..ddde9e4 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractMethodTypeListener.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractMethodTypeListener.java
@@ -19,20 +19,18 @@
 
 package org.apache.james.onami.lifecycle;
 
-import com.google.inject.TypeLiteral;
-import com.google.inject.spi.TypeEncounter;
-import com.google.inject.spi.TypeListener;
-
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.List;
 
+import com.google.inject.TypeLiteral;
+import com.google.inject.spi.TypeEncounter;
+import com.google.inject.spi.TypeListener;
+
 /**
  * A Guice {@code TypeListener} to hear annotated methods with lifecycle annotations.
  */
-abstract class AbstractMethodTypeListener
-    implements TypeListener
-{
+abstract class AbstractMethodTypeListener implements TypeListener {
 
     /**
      * The {@code java} package constants.
@@ -49,8 +47,7 @@ abstract class AbstractMethodTypeListener
      *
      * @param annotationTypes the lifecycle annotations to search on methods in the order to be searched.
      */
-    public AbstractMethodTypeListener( List<? extends Class<? extends Annotation>> annotationTypes )
-    {
+    public AbstractMethodTypeListener(List<? extends Class<? extends Annotation>> annotationTypes) {
         this.annotationTypes = annotationTypes;
     }
 
@@ -58,9 +55,8 @@ abstract class AbstractMethodTypeListener
      * {@inheritDoc}
      */
     @Override
-    public final <I> void hear( TypeLiteral<I> type, TypeEncounter<I> encounter )
-    {
-        hear( type, type.getRawType(), encounter );
+    public final <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
+        hear(type, type.getRawType(), encounter);
     }
 
     /**
@@ -70,32 +66,26 @@ abstract class AbstractMethodTypeListener
      * @param klass      encountered by Guice.
      * @param encounter  the injection context.
      */
-    private <I> void hear( final TypeLiteral<I> parentType, Class<? super I> klass, TypeEncounter<I> encounter )
-    {
+    private <I> void hear(final TypeLiteral<I> parentType, Class<? super I> klass, TypeEncounter<I> encounter) {
         Package pkg;
-        if ( klass == null || ( ( pkg = klass.getPackage() ) != null && pkg.getName().startsWith( JAVA_PACKAGE ) ) )
-        {
+        if (klass == null || ((pkg = klass.getPackage()) != null && pkg.getName().startsWith(JAVA_PACKAGE))) {
             return;
         }
 
-        for ( Class<? extends Annotation> annotationType : annotationTypes )
-        {
-            for ( Method method : klass.getDeclaredMethods() )
-            {
-                if ( method.isAnnotationPresent( annotationType ) )
-                {
-                    if ( method.getParameterTypes().length != 0 )
-                    {
-                        encounter.addError( "Annotated methods with @%s must not accept any argument, found %s",
-                                            annotationType.getName(), method );
+        for (Class<? extends Annotation> annotationType : annotationTypes) {
+            for (Method method : klass.getDeclaredMethods()) {
+                if (method.isAnnotationPresent(annotationType)) {
+                    if (method.getParameterTypes().length != 0) {
+                        encounter.addError("Annotated methods with @%s must not accept any argument, found %s",
+                            annotationType.getName(), method);
                     }
 
-                    hear( method, parentType, encounter, annotationType );
+                    hear(method, parentType, encounter, annotationType);
                 }
             }
         }
 
-        hear( parentType, klass.getSuperclass(), encounter );
+        hear(parentType, klass.getSuperclass(), encounter);
     }
 
     /**
@@ -106,7 +96,6 @@ abstract class AbstractMethodTypeListener
      * @param encounter      the injection context.
      * @param annotationType the annotation type that was specified.
      */
-    protected abstract <I> void hear( Method method, TypeLiteral<I> parentType, TypeEncounter<I> encounter,
-                                      Class<? extends Annotation> annotationType );
+    protected abstract <I> void hear(Method method, TypeLiteral<I> parentType, TypeEncounter<I> encounter, Class<? extends Annotation> annotationType);
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractStageable.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractStageable.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractStageable.java
index 07cbc84..6725f5d 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractStageable.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/AbstractStageable.java
@@ -24,31 +24,24 @@ package org.apache.james.onami.lifecycle;
  *
  * @author Mikhail Mazursky
  */
-public abstract class AbstractStageable<S>
-    extends AbstractBasicStageable<S>
-{
+public abstract class AbstractStageable<S> extends AbstractBasicStageable<S> {
 
-    protected AbstractStageable( S object )
-    {
-        super( object );
+    protected AbstractStageable(S object) {
+        super(object);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public final void stage( StageHandler stageHandler )
-    {
-        try
-        {
+    public final void stage(StageHandler stageHandler) {
+        try {
             doStage();
-        }
-        catch ( Throwable e )
-        {
-            stageHandler.onError( object, e );
+        } catch (Throwable e) {
+            stageHandler.onError(object, e);
             return;
         }
-        stageHandler.onSuccess( object );
+        stageHandler.onSuccess(object);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DefaultStager.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DefaultStager.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DefaultStager.java
index 96cf2a2..982f767 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DefaultStager.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DefaultStager.java
@@ -30,9 +30,7 @@ import java.util.concurrent.TimeUnit;
 /**
  * Default {@link Stager} implementation.
  */
-public class DefaultStager<A extends Annotation>
-    implements DisposingStager<A>
-{
+public class DefaultStager<A extends Annotation> implements DisposingStager<A> {
     private final Class<A> stage;
 
     /**
@@ -43,37 +41,31 @@ public class DefaultStager<A extends Annotation>
     /**
      * @param stage the annotation that specifies this stage
      */
-    public DefaultStager( Class<A> stage )
-    {
-        this( stage, Order.FIRST_IN_FIRST_OUT );
+    public DefaultStager(Class<A> stage) {
+        this(stage, Order.FIRST_IN_FIRST_OUT);
     }
 
-	/**
+    /**
      * @param stage the annotation that specifies this stage
      * @param mode  execution order
      */
-    public DefaultStager( Class<A> stage, Order mode )
-    {
+    public DefaultStager(Class<A> stage, Order mode) {
         this.stage = stage;
 
         Queue<Stageable> localStageables;
-        switch ( mode )
-        {
-            case FIRST_IN_FIRST_OUT:
-            {
+        switch (mode) {
+            case FIRST_IN_FIRST_OUT: {
                 localStageables = new ArrayDeque<Stageable>();
                 break;
             }
 
-            case FIRST_IN_LAST_OUT:
-            {
-                localStageables = Collections.asLifoQueue( new ArrayDeque<Stageable>() );
+            case FIRST_IN_LAST_OUT: {
+                localStageables = Collections.asLifoQueue(new ArrayDeque<Stageable>());
                 break;
             }
 
-            default:
-            {
-                throw new IllegalArgumentException( "Unknown mode: " + mode );
+            default: {
+                throw new IllegalArgumentException("Unknown mode: " + mode);
             }
         }
         stageables = localStageables;
@@ -83,11 +75,9 @@ public class DefaultStager<A extends Annotation>
      * {@inheritDoc}
      */
     @Override
-    public void register( Stageable stageable )
-    {
-        synchronized ( stageables )
-        {
-            stageables.add( stageable );
+    public void register(Stageable stageable) {
+        synchronized (stageables) {
+            stageables.add(stageable);
         }
     }
 
@@ -95,9 +85,8 @@ public class DefaultStager<A extends Annotation>
      * {@inheritDoc}
      */
     @Override
-    public <T extends ExecutorService> T register( T executorService )
-    {
-        register( new ExecutorServiceStageable( executorService ) );
+    public <T extends ExecutorService> T register(T executorService) {
+        register(new ExecutorServiceStageable(executorService));
         return executorService;
     }
 
@@ -105,9 +94,8 @@ public class DefaultStager<A extends Annotation>
      * {@inheritDoc}
      */
     @Override
-    public <T extends Closeable> T register( T closeable )
-    {
-        register( new CloseableStageable( closeable ) );
+    public <T extends Closeable> T register(T closeable) {
+        register(new CloseableStageable(closeable));
         return closeable;
     }
 
@@ -115,34 +103,28 @@ public class DefaultStager<A extends Annotation>
      * {@inheritDoc}
      */
     @Override
-    public void stage()
-    {
-        stage( null );
+    public void stage() {
+        stage(null);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public void stage( StageHandler stageHandler )
-    {
-        if ( stageHandler == null )
-        {
+    public void stage(StageHandler stageHandler) {
+        if (stageHandler == null) {
             stageHandler = new NoOpStageHandler();
         }
 
-        while ( true )
-        {
+        while (true) {
             Stageable stageable;
-            synchronized ( stageables )
-            {
+            synchronized (stageables) {
                 stageable = stageables.poll();
             }
-            if ( stageable == null )
-            {
+            if (stageable == null) {
                 break;
             }
-            stageable.stage( stageHandler );
+            stageable.stage(stageHandler);
         }
     }
 
@@ -150,16 +132,14 @@ public class DefaultStager<A extends Annotation>
      * {@inheritDoc}
      */
     @Override
-    public Class<A> getStage()
-    {
+    public Class<A> getStage() {
         return stage;
     }
 
     /**
      * specifies ordering for a {@link DefaultStager}
      */
-    public static enum Order
-    {
+    public static enum Order {
         /**
          * FIFO
          */
@@ -171,43 +151,33 @@ public class DefaultStager<A extends Annotation>
         FIRST_IN_LAST_OUT
     }
 
-    private static class CloseableStageable extends AbstractStageable<Closeable>
-    {
+    private static class CloseableStageable extends AbstractStageable<Closeable> {
 
-        public CloseableStageable( Closeable closeable )
-        {
-            super( closeable );
+        public CloseableStageable(Closeable closeable) {
+            super(closeable);
         }
 
         @Override
-        protected void doStage() throws Exception
-        {
+        protected void doStage() throws Exception {
             object.close();
         }
 
     }
 
-    private static class ExecutorServiceStageable extends AbstractStageable<ExecutorService>
-    {
+    private static class ExecutorServiceStageable extends AbstractStageable<ExecutorService> {
 
-        public ExecutorServiceStageable( ExecutorService executor )
-        {
-            super( executor );
+        public ExecutorServiceStageable(ExecutorService executor) {
+            super(executor);
         }
 
         @Override
-        protected void doStage() throws Exception
-        {
+        protected void doStage() throws Exception {
             object.shutdown();
-            try
-            {
-                if ( !object.awaitTermination( 1, TimeUnit.MINUTES ) )
-                {
+            try {
+                if (!object.awaitTermination(1, TimeUnit.MINUTES)) {
                     object.shutdownNow();
                 }
-            }
-            catch ( InterruptedException e )
-            {
+            } catch (InterruptedException e) {
                 object.shutdownNow();
                 Thread.currentThread().interrupt();
             }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DisposingStager.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DisposingStager.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DisposingStager.java
index 87bec80..395d8f1 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DisposingStager.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/DisposingStager.java
@@ -28,8 +28,7 @@ import java.util.concurrent.ExecutorService;
  *
  * @author Mikhail Mazursky
  */
-public interface DisposingStager<A extends Annotation> extends Stager<A>
-{
+public interface DisposingStager<A extends Annotation> extends Stager<A> {
 
     /**
      * Register an {@link java.util.concurrent.ExecutorService} to be staged.
@@ -37,7 +36,7 @@ public interface DisposingStager<A extends Annotation> extends Stager<A>
      * @param executorService object to be staged to dispose resources.
      * @return Staged object
      */
-    <T extends ExecutorService> T register( T executorService );
+    <T extends ExecutorService> T register(T executorService);
 
     /**
      * Register a {@link java.io.Closeable} to be staged.
@@ -45,6 +44,6 @@ public interface DisposingStager<A extends Annotation> extends Stager<A>
      * @param closeable object to be staged to dispose resources.
      * @return Staged object
      */
-    <T extends Closeable> T register( T closeable );
+    <T extends Closeable> T register(T closeable);
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleModule.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleModule.java
index 1827e38..b59b044 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleModule.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleModule.java
@@ -19,37 +19,34 @@
 
 package org.apache.james.onami.lifecycle;
 
-import com.google.inject.AbstractModule;
-import com.google.inject.ProvisionException;
-import com.google.inject.TypeLiteral;
-import com.google.inject.matcher.Matcher;
-import com.google.inject.spi.InjectionListener;
-import com.google.inject.spi.TypeEncounter;
+import static com.google.inject.matcher.Matchers.any;
+import static java.lang.String.format;
+import static java.util.Arrays.asList;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
 
-import static com.google.inject.matcher.Matchers.any;
-import static java.lang.String.format;
-import static java.util.Arrays.asList;
+import com.google.inject.AbstractModule;
+import com.google.inject.ProvisionException;
+import com.google.inject.TypeLiteral;
+import com.google.inject.matcher.Matcher;
+import com.google.inject.spi.InjectionListener;
+import com.google.inject.spi.TypeEncounter;
 
 /**
  * Guice module to register methods to be invoked after injection is complete.
  */
-public abstract class LifeCycleModule
-    extends AbstractModule
-{
+public abstract class LifeCycleModule extends AbstractModule {
 
     /**
      * Binds lifecycle listener.
      *
      * @param annotation the lifecycle annotation to be searched.
      */
-    protected final void bindLifeCycle( Class<? extends Annotation> annotation )
-    {
-        bindLifeCycle( annotation, any() );
+    protected final void bindLifeCycle(Class<? extends Annotation> annotation) {
+        bindLifeCycle(annotation, any());
     }
 
     /**
@@ -58,60 +55,38 @@ public abstract class LifeCycleModule
      * @param annotation  the lifecycle annotation to be searched.
      * @param typeMatcher the filter for injectee types.
      */
-    protected final void bindLifeCycle( Class<? extends Annotation> annotation, Matcher<? super TypeLiteral<?>> typeMatcher )
-    {
-        bindLifeCycle( asList( annotation ), typeMatcher );
+    protected final void bindLifeCycle(Class<? extends Annotation> annotation, Matcher<? super TypeLiteral<?>> typeMatcher) {
+        bindLifeCycle(asList(annotation), typeMatcher);
     }
 
     /**
      * Binds lifecycle listener.
      *
-     * @param annotations  the lifecycle annotations to be searched in the order to be searched.
+     * @param annotations the lifecycle annotations to be searched in the order to be searched.
      * @param typeMatcher the filter for injectee types.
      */
-    protected final void bindLifeCycle( List<? extends Class<? extends Annotation>> annotations, Matcher<? super TypeLiteral<?>> typeMatcher )
-    {
-        bindListener( typeMatcher, new AbstractMethodTypeListener( annotations )
-        {
-
+    protected final void bindLifeCycle(List<? extends Class<? extends Annotation>> annotations, Matcher<? super TypeLiteral<?>> typeMatcher) {
+        bindListener(typeMatcher, new AbstractMethodTypeListener(annotations) {
             @Override
-            protected <I> void hear( final Method method, TypeLiteral<I> parentType, TypeEncounter<I> encounter,
-                                     final Class<? extends Annotation> annotationType )
-            {
-                encounter.register( new InjectionListener<I>()
-                {
-
+            protected <I> void hear(final Method method, TypeLiteral<I> parentType, TypeEncounter<I> encounter, final Class<? extends Annotation> annotationType) {
+                encounter.register(new InjectionListener<I>() {
                     @Override
-                    public void afterInjection( I injectee )
-                    {
-                        try
-                        {
-                            method.invoke( injectee );
-                        }
-                        catch ( IllegalArgumentException e )
-                        {
+                    public void afterInjection(I injectee) {
+                        try {
+                            method.invoke(injectee);
+                        } catch (IllegalArgumentException e) {
                             // should not happen, anyway...
+                            throw new ProvisionException(format("Method @%s %s requires arguments", annotationType.getName(), method), e);
+                        } catch (IllegalAccessException e) {
+                            throw new ProvisionException(format("Impossible to access to @%s %s on %s", annotationType.getName(), method, injectee), e);
+                        } catch (InvocationTargetException e) {
                             throw new ProvisionException(
-                                format( "Method @%s %s requires arguments", annotationType.getName(), method ), e );
-                        }
-                        catch ( IllegalAccessException e )
-                        {
-                            throw new ProvisionException(
-                                format( "Impossible to access to @%s %s on %s", annotationType.getName(), method,
-                                        injectee ), e );
-                        }
-                        catch ( InvocationTargetException e )
-                        {
-                            throw new ProvisionException(
-                                format( "An error occurred while invoking @%s %s on %s", annotationType.getName(),
-                                        method, injectee ), e.getCause() );
+                                format("An error occurred while invoking @%s %s on %s", annotationType.getName(), method, injectee), e.getCause());
                         }
                     }
-
-                } );
+                });
             }
-
-        } );
+        });
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleStageModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleStageModule.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleStageModule.java
index 8698df1..4f54bdf 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleStageModule.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/LifeCycleStageModule.java
@@ -19,12 +19,8 @@
 
 package org.apache.james.onami.lifecycle;
 
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-import com.google.inject.matcher.Matcher;
-import com.google.inject.spi.InjectionListener;
-import com.google.inject.spi.TypeEncounter;
-import com.google.inject.util.Types;
+import static com.google.inject.matcher.Matchers.any;
+import static java.util.Arrays.asList;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
@@ -32,17 +28,19 @@ import java.lang.reflect.ParameterizedType;
 import java.util.ArrayList;
 import java.util.List;
 
-import static com.google.inject.matcher.Matchers.any;
-import static java.util.Arrays.asList;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+import com.google.inject.matcher.Matcher;
+import com.google.inject.spi.InjectionListener;
+import com.google.inject.spi.TypeEncounter;
+import com.google.inject.util.Types;
 
 /**
  * Guice module to register methods to be invoked when {@link Stager#stage()} is invoked.
  * <p/>
  * Module instance have has so it must not be used to construct more than one {@link com.google.inject.Injector}.
  */
-public abstract class LifeCycleStageModule
-    extends LifeCycleModule
-{
+public abstract class LifeCycleStageModule extends LifeCycleModule {
 
     private List<BindingBuilder<?>> bindings;
 
@@ -58,17 +56,15 @@ public abstract class LifeCycleStageModule
      * @param <A>   the Annotation type
      * @return the Guice key to use for accessing the stager for the input stage
      */
-    public static <A extends Annotation> Key<Stager<A>> key( Class<A> stage )
-    {
-        return Key.get( type( stage ) );
+    public static <A extends Annotation> Key<Stager<A>> key(Class<A> stage) {
+        return Key.get(type(stage));
     }
 
-    private static <A extends Annotation> TypeLiteral<Stager<A>> type( Class<A> stage )
-    {
-        ParameterizedType parameterizedType = Types.newParameterizedTypeWithOwner( null, Stager.class, stage );
+    private static <A extends Annotation> TypeLiteral<Stager<A>> type(Class<A> stage) {
+        ParameterizedType parameterizedType = Types.newParameterizedTypeWithOwner(null, Stager.class, stage);
         //noinspection unchecked
-        @SuppressWarnings( "unchecked" ) // TODO
-        TypeLiteral<Stager<A>> stagerType = (TypeLiteral<Stager<A>>) TypeLiteral.get( parameterizedType );
+        @SuppressWarnings("unchecked") // TODO
+            TypeLiteral<Stager<A>> stagerType = (TypeLiteral<Stager<A>>) TypeLiteral.get(parameterizedType);
         return stagerType;
     }
 
@@ -76,92 +72,72 @@ public abstract class LifeCycleStageModule
      * {@inheritDoc}
      */
     @Override
-    protected final void configure()
-    {
-        if ( bindings != null )
-        {
-            throw new IllegalStateException( "Re-entry is not allowed" );
+    protected final void configure() {
+        if (bindings != null) {
+            throw new IllegalStateException("Re-entry is not allowed");
         }
-        bindings = new ArrayList<BindingBuilder<?>>();
-        try
-        {
+        bindings = new ArrayList<>();
+        try {
             configureBindings();
-            for ( BindingBuilder<?> binding : bindings )
-            {
-                bind( binding );
+            for (BindingBuilder<?> binding : bindings) {
+                bind(binding);
             }
-        }
-        finally
-        {
+        } finally {
             bindings = null;
         }
     }
 
-    private <A extends Annotation> void bind( BindingBuilder<A> binding )
-    {
+    private <A extends Annotation> void bind(BindingBuilder<A> binding) {
         final Stager<A> stager = binding.stager;
         final StageableTypeMapper typeMapper = binding.typeMapper;
-        bind( type( stager.getStage() ) ).toInstance( stager );
-
-        bindListener( binding.typeMatcher, new AbstractMethodTypeListener( asList( stager.getStage() ) )
-        {
+        bind(type(stager.getStage())).toInstance(stager);
 
+        bindListener(binding.typeMatcher, new AbstractMethodTypeListener(asList(stager.getStage())) {
             @Override
-            protected <I> void hear( final Method stageMethod, final TypeLiteral<I> parentType,
-                                     final TypeEncounter<I> encounter,
-                                     final Class<? extends Annotation> annotationType )
-            {
-                encounter.register( new InjectionListener<I>()
-                {
-
+            protected <I> void hear(final Method stageMethod, final TypeLiteral<I> parentType,
+                                    final TypeEncounter<I> encounter, final Class<? extends Annotation> annotationType) {
+                encounter.register(new InjectionListener<I>() {
                     @Override
-                    public void afterInjection( I injectee )
-                    {
-                        Stageable stageable = new StageableMethod( stageMethod, injectee );
-                        stager.register( stageable );
-                        typeMapper.registerType( stageable, parentType );
+                    public void afterInjection(I injectee) {
+                        Stageable stageable = new StageableMethod(stageMethod, injectee);
+                        stager.register(stageable);
+                        typeMapper.registerType(stageable, parentType);
                     }
-
-                } );
+                });
             }
-
-        } );
+        });
     }
 
     protected abstract void configureBindings();
 
-    protected final <A extends Annotation> MapperBinding bindStager( Stager<A> stager )
-    {
-        BindingBuilder<A> builder = new BindingBuilder<A>( checkNotNull( stager, "Argument 'stager' must be not null" ) );
-        bindings.add( builder );
+    protected final <A extends Annotation> MapperBinding bindStager(Stager<A> stager) {
+        BindingBuilder<A> builder = new BindingBuilder<>(checkNotNull(stager, "Argument 'stager' must be not null"));
+        bindings.add(builder);
         return builder;
     }
 
-    protected interface MatcherBinding
-    {
+    protected interface MatcherBinding {
         /**
          * Sets the filter for injectee types.
          *
          * @param typeMatcher the filter for injectee types.
          */
-        void matching( Matcher<? super TypeLiteral<?>> typeMatcher );
+        void matching(Matcher<? super TypeLiteral<?>> typeMatcher);
     }
 
-    protected interface MapperBinding extends MatcherBinding
-    {
+    protected interface MapperBinding extends MatcherBinding {
         /**
          * Sets the container to register mappings from {@link Stageable}s to the types that created them.
          *
          * @param typeMapper container to map {@link Stageable}s to types.
          */
-        MatcherBinding mappingWith( StageableTypeMapper typeMapper );
+        MatcherBinding mappingWith(StageableTypeMapper typeMapper);
     }
 
     /**
      * Builder pattern helper.
      */
-    private static class BindingBuilder<A extends Annotation> implements MapperBinding
-    {
+    private static class BindingBuilder<A extends Annotation> implements MapperBinding {
 
         private Matcher<? super TypeLiteral<?>> typeMatcher = any();
 
@@ -169,31 +145,26 @@ public abstract class LifeCycleStageModule
 
         private StageableTypeMapper typeMapper = new NoOpStageableTypeMapper();
 
-        public BindingBuilder( Stager<A> stager )
-        {
+        public BindingBuilder(Stager<A> stager) {
             this.stager = stager;
         }
 
         @Override
-        public MatcherBinding mappingWith( StageableTypeMapper typeMapper )
-        {
-            this.typeMapper = checkNotNull( typeMapper, "Argument 'typeMapper' must be not null." );
+        public MatcherBinding mappingWith(StageableTypeMapper typeMapper) {
+            this.typeMapper = checkNotNull(typeMapper, "Argument 'typeMapper' must be not null.");
             return this;
         }
 
         @Override
-        public void matching( Matcher<? super TypeLiteral<?>> typeMatcher )
-        {
-            this.typeMatcher = checkNotNull( typeMatcher, "Argument 'typeMatcher' must be not null" );
+        public void matching(Matcher<? super TypeLiteral<?>> typeMatcher) {
+            this.typeMatcher = checkNotNull(typeMatcher, "Argument 'typeMatcher' must be not null");
         }
 
     }
 
-    private static <T> T checkNotNull( T object, String message )
-    {
-        if ( object == null )
-        {
-            throw new IllegalArgumentException( message );
+    private static <T> T checkNotNull(T object, String message) {
+        if (object == null) {
+            throw new IllegalArgumentException(message);
         }
         return object;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageHandler.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageHandler.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageHandler.java
index b543857..d643918 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageHandler.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageHandler.java
@@ -22,16 +22,13 @@ package org.apache.james.onami.lifecycle;
 /**
  * NOP {@code StageHandler} implementation.
  */
-public final class NoOpStageHandler
-    implements StageHandler
-{
+public final class NoOpStageHandler implements StageHandler {
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public <I, E extends Throwable> void onError( I injectee, E error )
-    {
+    public <I, E extends Throwable> void onError(I injectee, E error) {
         // do nothing
     }
 
@@ -39,8 +36,7 @@ public final class NoOpStageHandler
      * {@inheritDoc}
      */
     @Override
-    public <I> void onSuccess( I injectee )
-    {
+    public <I> void onSuccess(I injectee) {
         // do nothing
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageableTypeMapper.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageableTypeMapper.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageableTypeMapper.java
index f273b6f..0f3686f 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageableTypeMapper.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/NoOpStageableTypeMapper.java
@@ -21,13 +21,10 @@ package org.apache.james.onami.lifecycle;
 
 import com.google.inject.TypeLiteral;
 
-class NoOpStageableTypeMapper
-    implements StageableTypeMapper
-{
+class NoOpStageableTypeMapper implements StageableTypeMapper {
 
     @Override
-    public <I> void registerType( Stageable stageable, TypeLiteral<I> parentType )
-    {
+    public <I> void registerType(Stageable stageable, TypeLiteral<I> parentType) {
         // NOP
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/PreDestroyModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/PreDestroyModule.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/PreDestroyModule.java
index e28060b..09bcd8d 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/PreDestroyModule.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/PreDestroyModule.java
@@ -19,10 +19,10 @@
 
 package org.apache.james.onami.lifecycle;
 
-import com.google.inject.TypeLiteral;
-
 import javax.annotation.PreDestroy;
 
+import com.google.inject.TypeLiteral;
+
 /**
  * Guice module to register methods to be invoked when {@link org.apache.onami.lifecycle.core.Stager#stage()} is invoked.
  * <p/>
@@ -30,22 +30,17 @@ import javax.annotation.PreDestroy;
  *
  * @author Mikhail Mazursky
  */
-public class PreDestroyModule
-    extends LifeCycleStageModule
-{
+public class PreDestroyModule extends LifeCycleStageModule {
 
-    private final DisposingStager<PreDestroy> stager = new DefaultStager<PreDestroy>(
-        PreDestroy.class, DefaultStager.Order.FIRST_IN_LAST_OUT );
+    private final DisposingStager<PreDestroy> stager = new DefaultStager<PreDestroy>(PreDestroy.class, DefaultStager.Order.FIRST_IN_LAST_OUT);
 
     @Override
-    protected void configureBindings()
-    {
-        bindStager( stager );
-        bind( new TypeLiteral<DisposingStager<PreDestroy>>() {} ).toInstance( stager );
+    protected void configureBindings() {
+        bindStager(stager);
+        bind(new TypeLiteral<DisposingStager<PreDestroy>>() {}).toInstance(stager);
     }
 
-    public DisposingStager<PreDestroy> getStager()
-    {
+    public DisposingStager<PreDestroy> getStager() {
         return stager;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageHandler.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageHandler.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageHandler.java
index fa2a576..45edee2 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageHandler.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageHandler.java
@@ -22,15 +22,14 @@ package org.apache.james.onami.lifecycle;
 /**
  * A {@link StageHandler} instance is used to track staging progresses.
  */
-public interface StageHandler
-{
+public interface StageHandler {
 
     /**
      * Tracks the input injectee successfully staged the resources.
      *
      * @param injectee the injectee to be staged
      */
-    <I> void onSuccess( I injectee );
+    <I> void onSuccess(I injectee);
 
     /**
      * Tracks an error occurred while the input injectee staged the resources.
@@ -38,6 +37,6 @@ public interface StageHandler
      * @param injectee the injectee to be staged
      * @param error    the exception occurred
      */
-    <I, E extends Throwable> void onError( I injectee, E error );
+    <I, E extends Throwable> void onError(I injectee, E error);
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stageable.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stageable.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stageable.java
index 8865cca..9756534 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stageable.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stageable.java
@@ -22,8 +22,7 @@ package org.apache.james.onami.lifecycle;
 /**
  * Object that knows how to stage some resources.
  */
-public interface Stageable
-{
+public interface Stageable {
 
     /**
      * Stage allocated resources, tracking progresses in the
@@ -31,7 +30,7 @@ public interface Stageable
      *
      * @param stageHandler the handler to track progresses.
      */
-    void stage( StageHandler stageHandler );
+    void stage(StageHandler stageHandler);
 
     /**
      * @return Description of a stageable resource.

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableMethod.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableMethod.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableMethod.java
index b10315a..764ba14 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableMethod.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableMethod.java
@@ -28,9 +28,7 @@ import java.security.PrivilegedAction;
  * A {@link StageableMethod} is a reference to a stageable injectee
  * and related method to release resources.
  */
-final class StageableMethod
-    extends AbstractBasicStageable<Object>
-{
+final class StageableMethod extends AbstractBasicStageable<Object> {
 
     /**
      * The method to be invoked to stage resources.
@@ -43,9 +41,8 @@ final class StageableMethod
      * @param stageMethod the method to be invoked to stage resources.
      * @param injectee    the target injectee has to stage the resources.
      */
-    StageableMethod( Method stageMethod, Object injectee )
-    {
-        super( injectee );
+    StageableMethod(Method stageMethod, Object injectee) {
+        super(injectee);
         this.stageMethod = stageMethod;
     }
 
@@ -53,34 +50,24 @@ final class StageableMethod
      * {@inheritDoc}
      */
     @Override
-    public final void stage( StageHandler stageHandler )
-    {
-        try
-        {
-            AccessController.doPrivileged( new PrivilegedAction<Void>()
-            {
-
+    public final void stage(StageHandler stageHandler) {
+        try {
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
                 @Override
-                public Void run()
-                {
-                    stageMethod.setAccessible( true );
+                public Void run() {
+                    stageMethod.setAccessible(true);
                     return null;
                 }
-
-            } );
-            stageMethod.invoke( object );
-        }
-        catch ( InvocationTargetException e )
-        {
-            stageHandler.onError( object, e.getCause() );
+            });
+            stageMethod.invoke(object);
+        } catch (InvocationTargetException e) {
+            stageHandler.onError(object, e.getCause());
             return;
-        }
-        catch ( Throwable e )
-        {
-            stageHandler.onError( object, e );
+        } catch (Throwable e) {
+            stageHandler.onError(object, e);
             return;
         }
-        stageHandler.onSuccess( object );
+        stageHandler.onSuccess(object);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableTypeMapper.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableTypeMapper.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableTypeMapper.java
index e799373..3141d14 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableTypeMapper.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/StageableTypeMapper.java
@@ -25,15 +25,14 @@ import com.google.inject.TypeLiteral;
  * Container for mapping a {@link Stageable} to the parent type
  * that created it. Useful in specialty Stage containers.
  */
-public interface StageableTypeMapper
-{
+public interface StageableTypeMapper {
 
     /**
      * Register a new {@link Stageable} with the type that created it
      *
-     * @param stageable stageable
-     * @param parentType     the owning type being heard
+     * @param stageable  stageable
+     * @param parentType the owning type being heard
      */
-    <I> void registerType( Stageable stageable, TypeLiteral<I> parentType );
+    <I> void registerType(Stageable stageable, TypeLiteral<I> parentType);
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stager.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stager.java b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stager.java
index a6a63c0..4738b26 100644
--- a/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stager.java
+++ b/server/container/guice/onami/src/main/java/org/apache/james/onami/lifecycle/Stager.java
@@ -31,15 +31,14 @@ import java.lang.annotation.Annotation;
  * Implementations must be thread-safe because registration can be done from
  * any thread.
  */
-public interface Stager<A extends Annotation>
-{
+public interface Stager<A extends Annotation> {
 
     /**
      * Register a {@link Stageable} to stage resources.
      *
      * @param stageable object to be invoked to stage resources.
      */
-    void register( Stageable stageable );
+    void register(Stageable stageable);
 
     /**
      * Stages resources invoking {@link Stageable#stage(StageHandler)}.
@@ -52,7 +51,7 @@ public interface Stager<A extends Annotation>
      * @param stageHandler the {@link StageHandler} instance that tracks progresses.
      * @since 0.2.0
      */
-    void stage( StageHandler stageHandler );
+    void stage(StageHandler stageHandler);
 
     /**
      * Returns the annotation that represents this stage.

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java
index 03c9ee6..f80703e 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/DefaultStagerTestCase.java
@@ -24,34 +24,27 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.junit.Assert;
 import org.junit.Test;
 
-public class DefaultStagerTestCase
-{
+public class DefaultStagerTestCase {
 
     @Test
-    public void stagerShouldStageObjectsRegisteredWhileStaging()
-    {
-        final Stager<TestAnnotationA> stager =
-                new DefaultStager<TestAnnotationA>( TestAnnotationA.class );
+    public void stagerShouldStageObjectsRegisteredWhileStaging() {
+        final Stager<TestAnnotationA> stager = new DefaultStager<TestAnnotationA>(TestAnnotationA.class);
         final AtomicBoolean staged = new AtomicBoolean();
-        stager.register( new Stageable()
-        {
+        stager.register(new Stageable() {
             @Override
-            public void stage( StageHandler stageHandler )
-            {
-                stager.register( new Stageable()
-                {
+            public void stage(StageHandler stageHandler) {
+                stager.register(new Stageable() {
                     @Override
-                    public void stage( StageHandler stageHandler )
-                    {
-                        staged.set( true );
+                    public void stage(StageHandler stageHandler) {
+                        staged.set(true);
                     }
-                } );
+                });
             }
-        } );
+        });
 
         stager.stage();
 
-        Assert.assertTrue( staged.get() );
+        Assert.assertTrue(staged.get());
     }
 
     /*
@@ -61,45 +54,34 @@ public class DefaultStagerTestCase
      * 3. the thread blocks on the lock in DefaultStager.register()
      */
     @Test
-    public void stagerShouldNotDeadlockWhileStagingObjectChains()
-    {
+    public void stagerShouldNotDeadlockWhileStagingObjectChains() {
         final AtomicBoolean staged = new AtomicBoolean();
-        final Stager<TestAnnotationA> stager =
-                new DefaultStager<TestAnnotationA>( TestAnnotationA.class );
-        stager.register( new Stageable()
-        {
+        final Stager<TestAnnotationA> stager = new DefaultStager<TestAnnotationA>(TestAnnotationA.class);
+        stager.register(new Stageable() {
             @Override
-            public void stage( StageHandler stageHandler )
-            {
-                Thread thread = new Thread( new Runnable()
-                {
+            public void stage(StageHandler stageHandler) {
+                Thread thread = new Thread(new Runnable() {
                     @Override
-                    public void run()
-                    {
-                        stager.register( new Stageable()
-                        {
+                    public void run() {
+                        stager.register(new Stageable() {
                             @Override
-                            public void stage( StageHandler stageHandler )
-                            {
-                                staged.set( true );
+                            public void stage(StageHandler stageHandler) {
+                                staged.set(true);
                             }
-                        } );
+                        });
                     }
-                } );
+                });
                 thread.start();
-                try
-                {
+                try {
                     thread.join();
-                }
-                catch ( InterruptedException e )
-                {
+                } catch (InterruptedException e) {
                     Thread.currentThread().interrupt();
                 }
             }
-        } );
+        });
 
         stager.stage();
 
-        Assert.assertTrue( staged.get() );
+        Assert.assertTrue(staged.get());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleObject.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleObject.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleObject.java
index 615ad3b..2ef461c 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleObject.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleObject.java
@@ -22,55 +22,46 @@ package org.apache.james.onami.lifecycle;
 import javax.inject.Singleton;
 
 @Singleton
-public class MultiLifeCycleObject
-{
+public class MultiLifeCycleObject {
     private final StringBuilder str = new StringBuilder();
 
     @TestAnnotationC
-    public void foo()
-    {
-        str.append( "c" );
+    public void foo() {
+        str.append("c");
     }
 
     @TestAnnotationA
-    public void aaa()
-    {
-        str.append( "a" );
+    public void aaa() {
+        str.append("a");
     }
 
     @TestAnnotationB
-    public void bbb()
-    {
-        str.append( "b" );
+    public void bbb() {
+        str.append("b");
     }
 
     @TestAnnotationA
-    public void mmm()
-    {
-        str.append( "a" );
+    public void mmm() {
+        str.append("a");
     }
 
     @TestAnnotationB
-    public void nnn()
-    {
-        str.append( "b" );
+    public void nnn() {
+        str.append("b");
     }
 
     @TestAnnotationB
-    public void qqq()
-    {
-        str.append( "b" );
+    public void qqq() {
+        str.append("b");
     }
 
     @TestAnnotationA
-    public void zzz()
-    {
-        str.append( "a" );
+    public void zzz() {
+        str.append("a");
     }
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         return str.toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java
index 0160ac6..5ef8c9d 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/MultiLifeCycleTestCase.java
@@ -22,123 +22,105 @@ package org.apache.james.onami.lifecycle;
 import static com.google.inject.matcher.Matchers.any;
 import static java.util.Arrays.asList;
 
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
+import java.lang.annotation.Annotation;
+import java.util.List;
+
 import javax.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Module;
+
 import org.junit.Assert;
 import org.junit.Test;
 
-import java.lang.annotation.Annotation;
-import java.util.List;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
 
-public class MultiLifeCycleTestCase
-{
+public class MultiLifeCycleTestCase {
     @Test
-    public void testOrdering()
-    {
-        Module lifeCycleModule = new TestLifeCycleModule(
-            asList( TestAnnotationA.class, TestAnnotationB.class, TestAnnotationC.class ) );
-        MultiLifeCycleObject obj = Guice.createInjector( lifeCycleModule ).getInstance( MultiLifeCycleObject.class );
-        Assert.assertEquals( "aaabbbc", obj.toString() );
+    public void testOrdering() {
+        Module lifeCycleModule = new TestLifeCycleModule(asList(TestAnnotationA.class, TestAnnotationB.class, TestAnnotationC.class));
+        MultiLifeCycleObject obj = Guice.createInjector(lifeCycleModule).getInstance(MultiLifeCycleObject.class);
+        Assert.assertEquals("aaabbbc", obj.toString());
     }
 
-    public static class Foo
-    {
+    public static class Foo {
         @Inject
-        public Foo( Stager<TestAnnotationA> stager )
-        {
-            System.out.println( stager.getStage() );
+        public Foo(Stager<TestAnnotationA> stager) {
+            System.out.println(stager.getStage());
         }
     }
 
     @Test
-    public void testStaging()
-    {
-        Module moduleA =
-            new TestLifeCycleStageModule( new DefaultStager<TestAnnotationA>( TestAnnotationA.class ) );
-        Module moduleB =
-            new TestLifeCycleStageModule( new DefaultStager<TestAnnotationB>( TestAnnotationB.class ) );
-        Module moduleC =
-            new TestLifeCycleStageModule( new DefaultStager<TestAnnotationC>( TestAnnotationC.class ) );
-
-        Injector injector = Guice.createInjector( moduleA, moduleB, moduleC );
-        MultiLifeCycleObject obj = injector.getInstance( MultiLifeCycleObject.class );
-
-        Assert.assertEquals( obj.toString(), "" );
-
-        injector.getInstance( LifeCycleStageModule.key( TestAnnotationA.class ) ).stage();
-        Assert.assertEquals( "aaa", obj.toString() );
-        injector.getInstance( LifeCycleStageModule.key( TestAnnotationB.class ) ).stage();
-        Assert.assertEquals( "aaabbb", obj.toString() );
-        injector.getInstance( LifeCycleStageModule.key( TestAnnotationC.class ) ).stage();
-        Assert.assertEquals( "aaabbbc", obj.toString() );
-
-        injector.getInstance( Foo.class );
+    public void testStaging() {
+        Module moduleA = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationA.class));
+        Module moduleB = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationB.class));
+        Module moduleC = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationC.class));
+
+        Injector injector = Guice.createInjector(moduleA, moduleB, moduleC);
+        MultiLifeCycleObject obj = injector.getInstance(MultiLifeCycleObject.class);
+
+        Assert.assertEquals(obj.toString(), "");
+
+        injector.getInstance(LifeCycleStageModule.key(TestAnnotationA.class)).stage();
+        Assert.assertEquals("aaa", obj.toString());
+        injector.getInstance(LifeCycleStageModule.key(TestAnnotationB.class)).stage();
+        Assert.assertEquals("aaabbb", obj.toString());
+        injector.getInstance(LifeCycleStageModule.key(TestAnnotationC.class)).stage();
+        Assert.assertEquals("aaabbbc", obj.toString());
+
+        injector.getInstance(Foo.class);
     }
 
     @Test
-    public void testStagingOrdering()
-    {
-        Module moduleA =
-            new TestLifeCycleStageModule( new DefaultStager<TestAnnotationA>( TestAnnotationA.class, DefaultStager.Order.FIRST_IN_FIRST_OUT ) );
-        Module moduleB =
-            new TestLifeCycleStageModule( new DefaultStager<TestAnnotationB>( TestAnnotationB.class, DefaultStager.Order.FIRST_IN_LAST_OUT ) );
+    public void testStagingOrdering() {
+        Module moduleA = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationA.class, DefaultStager.Order.FIRST_IN_FIRST_OUT));
+        Module moduleB = new TestLifeCycleStageModule(new DefaultStager<>(TestAnnotationB.class, DefaultStager.Order.FIRST_IN_LAST_OUT));
 
         final StringBuilder str = new StringBuilder();
-        Module m = new AbstractModule()
-        {
+        Module m = new AbstractModule() {
             @Override
-            protected void configure()
-            {
-                binder().bind( StringBuilder.class ).toInstance( str );
+            protected void configure() {
+                binder().bind(StringBuilder.class).toInstance(str);
             }
         };
 
-        Injector injector = Guice.createInjector( moduleA, moduleB, m );
-        injector.getInstance( StageObject1.class );
-        injector.getInstance( StageObject2.class );
+        Injector injector = Guice.createInjector(moduleA, moduleB, m);
+        injector.getInstance(StageObject1.class);
+        injector.getInstance(StageObject2.class);
 
-        injector.getInstance( LifeCycleStageModule.key( TestAnnotationA.class ) ).stage();
-        Assert.assertEquals( "1a2a", str.toString() );
-        str.setLength( 0 );
+        injector.getInstance(LifeCycleStageModule.key(TestAnnotationA.class)).stage();
+        Assert.assertEquals("1a2a", str.toString());
+        str.setLength(0);
 
-        injector.getInstance( LifeCycleStageModule.key( TestAnnotationB.class ) ).stage();
-        Assert.assertEquals( "2b1b", str.toString() );
+        injector.getInstance(LifeCycleStageModule.key(TestAnnotationB.class)).stage();
+        Assert.assertEquals("2b1b", str.toString());
     }
 
-    private static class TestLifeCycleModule extends LifeCycleModule
-    {
+    private static class TestLifeCycleModule extends LifeCycleModule {
 
         private final List<? extends Class<? extends Annotation>> annotations;
 
-        public TestLifeCycleModule( List<? extends Class<? extends Annotation>> annotations )
-        {
+        public TestLifeCycleModule(List<? extends Class<? extends Annotation>> annotations) {
             this.annotations = annotations;
         }
 
         @Override
-        protected void configure()
-        {
-            bindLifeCycle( annotations, any() );
+        protected void configure() {
+            bindLifeCycle(annotations, any());
         }
     }
 
-    private static class TestLifeCycleStageModule extends LifeCycleStageModule
-    {
+    private static class TestLifeCycleStageModule extends LifeCycleStageModule {
 
         private final Stager<?> stager;
 
-        public TestLifeCycleStageModule( Stager<?> stager )
-        {
+        public TestLifeCycleStageModule(Stager<?> stager) {
             this.stager = stager;
         }
 
         @Override
-        protected void configureBindings()
-        {
-            bindStager( stager );
+        protected void configureBindings() {
+            bindStager(stager);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject1.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject1.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject1.java
index e5a899b..325b1c1 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject1.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject1.java
@@ -21,25 +21,21 @@ package org.apache.james.onami.lifecycle;
 
 import javax.inject.Inject;
 
-public class StageObject1
-{
+public class StageObject1 {
     private final StringBuilder str;
 
     @Inject
-    public StageObject1( StringBuilder str )
-    {
+    public StageObject1(StringBuilder str) {
         this.str = str;
     }
 
     @TestAnnotationA
-    public void stageA()
-    {
-        str.append( "1a" );
+    public void stageA() {
+        str.append("1a");
     }
 
     @TestAnnotationB
-    public void stageB()
-    {
-        str.append( "1b" );
+    public void stageB() {
+        str.append("1b");
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject2.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject2.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject2.java
index 1929d7c..a390661 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject2.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StageObject2.java
@@ -21,25 +21,21 @@ package org.apache.james.onami.lifecycle;
 
 import javax.inject.Inject;
 
-public class StageObject2
-{
+public class StageObject2 {
     private final StringBuilder str;
 
     @Inject
-    public StageObject2( StringBuilder str )
-    {
+    public StageObject2(StringBuilder str) {
         this.str = str;
     }
 
     @TestAnnotationA
-    public void stageA()
-    {
-        str.append( "2a" );
+    public void stageA() {
+        str.append("2a");
     }
 
     @TestAnnotationB
-    public void stageB()
-    {
-        str.append( "2b" );
+    public void stageB() {
+        str.append("2b");
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java
index 287367c..3f4201d 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/StagingOrderTestCase.java
@@ -19,67 +19,41 @@
 
 package org.apache.james.onami.lifecycle;
 
-import org.junit.Assert;
-import org.junit.Test;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-public class StagingOrderTestCase
-{
+import org.junit.Assert;
+import org.junit.Test;
+
+public class StagingOrderTestCase {
     @Test
-    public void testFifo()
-    {
-        List<Integer> order = new ArrayList<Integer>();
-        DefaultStager<TestAnnotationA> stager = makeStager( order, DefaultStager.Order.FIRST_IN_FIRST_OUT );
+    public void testFifo() {
+        List<Integer> order = new ArrayList<>();
+        DefaultStager<TestAnnotationA> stager = makeStager(order, DefaultStager.Order.FIRST_IN_FIRST_OUT);
         stager.stage();
 
-        Assert.assertEquals( Arrays.asList( 1, 2, 3 ), order );
+        Assert.assertEquals(Arrays.asList(1, 2, 3), order);
     }
 
     @Test
-    public void testFilo()
-    {
-        List<Integer> order = new ArrayList<Integer>();
-        DefaultStager<TestAnnotationA> stager = makeStager( order, DefaultStager.Order.FIRST_IN_LAST_OUT );
+    public void testFilo() {
+        List<Integer> order = new ArrayList<>();
+        DefaultStager<TestAnnotationA> stager = makeStager(order, DefaultStager.Order.FIRST_IN_LAST_OUT);
         stager.stage();
 
-        Assert.assertEquals( Arrays.asList( 3, 2, 1 ), order );
+        Assert.assertEquals(Arrays.asList(3, 2, 1), order);
     }
 
-    private DefaultStager<TestAnnotationA> makeStager( final List<Integer> order, DefaultStager.Order stagingOrder )
-    {
-        Stageable stageable1 = new Stageable()
-        {
-            @Override
-            public void stage( StageHandler stageHandler )
-            {
-                order.add( 1 );
-            }
-        };
-        Stageable stageable2 = new Stageable()
-        {
-            @Override
-            public void stage( StageHandler stageHandler )
-            {
-                order.add( 2 );
-            }
-        };
-        Stageable stageable3 = new Stageable()
-        {
-            @Override
-            public void stage( StageHandler stageHandler )
-            {
-                order.add( 3 );
-            }
-        };
+    private DefaultStager<TestAnnotationA> makeStager(final List<Integer> order, DefaultStager.Order stagingOrder) {
+        Stageable stageable1 = stageHandler -> order.add(1);
+        Stageable stageable2 = stageHandler -> order.add(2);
+        Stageable stageable3 = stageHandler -> order.add(3);
 
-        DefaultStager<TestAnnotationA> stager =
-            new DefaultStager<TestAnnotationA>( TestAnnotationA.class, stagingOrder );
-        stager.register( stageable1 );
-        stager.register( stageable2 );
-        stager.register( stageable3 );
+        DefaultStager<TestAnnotationA> stager = new DefaultStager<TestAnnotationA>(TestAnnotationA.class, stagingOrder);
+        stager.register(stageable1);
+        stager.register(stageable2);
+        stager.register(stageable3);
         return stager;
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationA.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationA.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationA.java
index 1e17c5e..9bc7d63 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationA.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationA.java
@@ -19,15 +19,14 @@
 
 package org.apache.james.onami.lifecycle;
 
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
 @Retention(RUNTIME)
 @Target(METHOD)
-public @interface TestAnnotationA
-{
+public @interface TestAnnotationA {
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationB.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationB.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationB.java
index ec26c62..090ca69 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationB.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationB.java
@@ -19,15 +19,14 @@
 
 package org.apache.james.onami.lifecycle;
 
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
-@Retention( RUNTIME )
-@Target( METHOD )
-public @interface TestAnnotationB
-{
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(METHOD)
+public @interface TestAnnotationB {
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7de2a019/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationC.java
----------------------------------------------------------------------
diff --git a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationC.java b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationC.java
index 1f99d60..1d148ae 100644
--- a/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationC.java
+++ b/server/container/guice/onami/src/test/java/org/apache/james/onami/lifecycle/TestAnnotationC.java
@@ -19,15 +19,14 @@
 
 package org.apache.james.onami.lifecycle;
 
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
-@Retention( RUNTIME )
-@Target( METHOD )
-public @interface TestAnnotationC
-{
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(METHOD)
+public @interface TestAnnotationC {
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message