You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by ra...@apache.org on 2013/03/09 19:17:36 UTC

svn commit: r1454753 - in /incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core: LifeCycleStageModule.java NoOpStageableTypeMapper.java StageableTypeMapper.java Stager.java

Author: randgalt
Date: Sat Mar  9 18:17:35 2013
New Revision: 1454753

URL: http://svn.apache.org/r1454753
Log:
Introduce new concept of StageableTypeMapper. This is needed by WarmUp

Added:
    incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java   (with props)
    incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java   (with props)
Modified:
    incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/LifeCycleStageModule.java
    incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/Stager.java

Modified: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/LifeCycleStageModule.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/LifeCycleStageModule.java?rev=1454753&r1=1454752&r2=1454753&view=diff
==============================================================================
--- incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/LifeCycleStageModule.java (original)
+++ incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/LifeCycleStageModule.java Sat Mar  9 18:17:35 2013
@@ -42,6 +42,8 @@ public final class LifeCycleStageModule<
 
     private final Stager<A> stager;
 
+    private final StageableTypeMapper<A> typeMapper;
+
     /**
      * Creates a new module which register methods annotated with input annotation on methods in any type.
      *
@@ -63,6 +65,7 @@ public final class LifeCycleStageModule<
     {
         super( stager.getStage(), typeMatcher );
         this.stager = stager;
+        typeMapper = new NoOpStageableTypeMapper<A>();
     }
 
     /**
@@ -74,6 +77,7 @@ public final class LifeCycleStageModule<
     {
         super( builder.stager.getStage(), builder.typeMatcher );
         this.stager = builder.stager;
+        this.typeMapper = builder.typeMapper;
     }
 
     /**
@@ -135,6 +139,7 @@ public final class LifeCycleStageModule<
                     {
                         Stageable stageable = new StageableMethod( stageMethod, injectee );
                         stager.register( stageable );
+                        typeMapper.registerType( stageable, parentType );
                     }
 
                 } );
@@ -153,6 +158,8 @@ public final class LifeCycleStageModule<
 
         private Stager<A> stager;
 
+        private StageableTypeMapper<A> typeMapper = new NoOpStageableTypeMapper<A>();
+
         Builder( Class<A> annotationClass )
         {
             stager = new DefaultStager<A>( annotationClass, DefaultStager.Order.FIRST_IN_FIRST_OUT );
@@ -201,6 +208,18 @@ public final class LifeCycleStageModule<
             return this;
         }
 
+        /**
+         * 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
+         * @return self
+         */
+        public Builder<A> withTypeMapper( StageableTypeMapper<A> typeMapper )
+        {
+            this.typeMapper = checkNotNull( typeMapper, "Argument 'typeMapper' must be not null." );
+            return this;
+        }
+
     }
 
 }

Added: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java?rev=1454753&view=auto
==============================================================================
--- incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java (added)
+++ incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java Sat Mar  9 18:17:35 2013
@@ -0,0 +1,13 @@
+package org.apache.onami.lifecycle.core;
+
+import com.google.inject.TypeLiteral;
+
+import java.lang.annotation.Annotation;
+
+class NoOpStageableTypeMapper<A extends Annotation> implements StageableTypeMapper<A>
+{
+    public <I> void registerType( Stageable stageable, TypeLiteral<I> parentType )
+    {
+        // NOP
+    }
+}

Propchange: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/NoOpStageableTypeMapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java?rev=1454753&view=auto
==============================================================================
--- incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java (added)
+++ incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java Sat Mar  9 18:17:35 2013
@@ -0,0 +1,39 @@
+package org.apache.onami.lifecycle.core;
+
+/*
+ * 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.TypeLiteral;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Container for mapping a {@link Stageable} to the parent type
+ * that created it. Useful in specialty Stage containers.
+ */
+public interface StageableTypeMapper<A extends Annotation>
+{
+    /**
+     * Register a new {@link Stageable} with the type that created it
+     *
+     * @param stageable stageable
+     * @param parentType     the owning type being heard
+     */
+    public <I> void registerType( Stageable stageable, TypeLiteral<I> parentType );
+}

Propchange: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/StageableTypeMapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/Stager.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/Stager.java?rev=1454753&r1=1454752&r2=1454753&view=diff
==============================================================================
--- incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/Stager.java (original)
+++ incubator/onami/trunk/lifecycle/core/main/java/org/apache/onami/lifecycle/core/Stager.java Sat Mar  9 18:17:35 2013
@@ -26,7 +26,7 @@ import java.lang.annotation.Annotation;
  * invoking {@link Stageable#stage(StageHandler)}.
  * <p/>
  * Order of disposal is specified by the concrete implementation of this
- * interface via {@link org.apache.onami.lifecycle.DefaultStager.Order}.
+ * interface via {@link org.apache.onami.lifecycle.core.DefaultStager.Order}.
  * <p/>
  * Implementations must be thread-safe because registration can be done from
  * any thread.