[jboss-cvs] JBossAS SVN: r90603 - in projects/jboss-deployers/trunk: deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 25 18:34:31 EDT 2009


Author: alesj
Date: 2009-06-25 18:34:31 -0400 (Thu, 25 Jun 2009)
New Revision: 90603

Modified:
   projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStage.java
   projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java
   projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
Log:
Revert Opalka's invalid changes.

Modified: projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStage.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStage.java	2009-06-25 19:06:38 UTC (rev 90602)
+++ projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStage.java	2009-06-25 22:34:31 UTC (rev 90603)
@@ -24,202 +24,155 @@
 import java.io.Serializable;
 
 /**
- * Comparable deployment stage.
+ * DeploymentStage.
  * 
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
  * @version $Revision: 1.1 $
  */
-public final class DeploymentStage implements Comparable< DeploymentStage >, Serializable
+public class DeploymentStage implements Serializable
 {
-
-   // TODO: Do I have to provide read/writeObject() methods as well?
    /** The serialVersionUID */
-   private static final long serialVersionUID = 3302613286025012192L;
+   private static final long serialVersionUID = 3302613286025012191L;
 
    /** Our stage */
-   private final String name;
+   private String name;
    
-   /** The previous stage */
-   private DeploymentStage after;
+   /** The previous state */
+   private String after;
    
-   /** The next stage */
-   private DeploymentStage before;
-   
-   /** Stage index. */
-   private int index;
-   
-   /** Computed hashCode(). */
-   private int hashCode;
-   
-   /** Computed toString(). */
-   private String toString;
-   
-   /** Initialization flag. */
-   private boolean initialized;
+   /** The next state */
+   private String before;
 
    /**
-    * Create a new DeploymentStage.
+    * Safely get the name of stage
     * 
-    * @param name the name of the stage
+    * @param stage the stage
+    * @param context the context for an error
+    * @return the stage name
     */
-   public DeploymentStage( final String name )
+   private static String getStageName(DeploymentStage stage, String context)
    {
-      if ( name == null )
-      {
-         throw new NullPointerException( "Null name" );
-      }
-      
-      this.name = name;
+      if (stage == null)
+         throw new IllegalArgumentException("Null " + context);
+      return stage.getName();
    }
    
    /**
-    * Initializes this deployment stage and makes it immutable.
+    * Create a new DeploymentStage.
     * 
-    * @param after the deployment stage preceding this one
-    * @param before the deployment stage following this one
-    * @param index deployment stage index
+    * @param name the name of the stage
+    * @throws IllegalArgumentException for a null name
     */
-   public synchronized void initialize( final DeploymentStage after, final DeploymentStage before, final int index )
+   public DeploymentStage(String name)
    {
-      if ( false == this.initialized )
-      {
-         this.after = after;
-         this.before = before;
-         this.index = index;
-         this.hashCode = computeHashCode();
-         this.toString = computeToString();
-         this.initialized = true;
-      }
+      this(name, (String) null);
    }
 
    /**
-    * Get the name.
+    * Create a new DeploymentStage.
     * 
-    * @return the name.
+    * @param name the name of the stage
+    * @param after the name of the stage before our stage
+    * @throws IllegalArgumentException for a null name
     */
-   public String getName()
+   public DeploymentStage(String name, String after)
    {
-      return name;
+      this(name, after, null);
    }
 
    /**
-    * Get the after stage.
+    * Create a new DeploymentStage.
     * 
-    * @return the after stage.
+    * @param name the name of the stage
+    * @param after the stage before our stage
+    * @throws IllegalArgumentException for a null parameter
     */
-   public DeploymentStage getAfter()
+   public DeploymentStage(String name, DeploymentStage after)
    {
-      return after;
+      this(name, getStageName(after, "after"), null);
    }
 
    /**
-    * Get the before stage.
+    * Create a new DeploymentStage.
     * 
-    * @return the before stage.
+    * @param name the name of the stage
+    * @param after he stage before our stage
+    * @param before the stage after our stage
+    * @throws IllegalArgumentException for a null parameter
     */
-   public DeploymentStage getBefore()
+   public DeploymentStage(String name, DeploymentStage after, DeploymentStage before)
    {
-      return before;
+      this(name, getStageName(after, "after"), getStageName(before, "before"));
    }
 
    /**
-    * See {@link java.lang.Object#equals(Object)}
+    * Create a new DeploymentStage.
+    * 
+    * @param name the name of the stage
+    * @param after the name of the stage before our stage
+    * @param before the name of the stage after our stage
+    * @throws IllegalArgumentException for a null name
     */
-   @Override
-   public boolean equals( final Object obj )
+   public DeploymentStage(String name, String after, String before)
    {
-      if ( obj == this )
-      {
-         return true;
-      }
-      if ( obj == null || false == ( obj instanceof DeploymentStage ) )
-      {
-         return false;
-      }
-      
-      final DeploymentStage other = ( DeploymentStage ) obj;
-
-      if ( false == this.getName().equals( other.getName() ) )
-      {
-         return false;
-      }
-      if ( false == ( this.index == other.index ) )
-      {
-         return false;
-      }
-      if ( false == this.getAfter().equals( other.getAfter() ) )
-      {
-         return false;
-      }
-      if ( false == this.getBefore().equals( other.getBefore() ) )
-      {
-         return false;
-      }
-      
-      return true;
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      this.name = name;
+      this.after = after;
+      this.before = before;
    }
 
    /**
-    * See {@link java.lang.Object#hashCode()}
+    * Get the name.
+    * 
+    * @return the name.
     */
-   @Override
-   public int hashCode()
+   public String getName()
    {
-      return this.hashCode;
+      return name;
    }
-   
-   /**
-    * See {@link java.lang.Object#toString()}
-    */
-   @Override
-   public String toString()
-   {
-      return this.toString;
-   }
-   
-   /**
-    * See {@link java.lang.Comparable#compareTo(Object)}
-    */
-   public int compareTo( final DeploymentStage other )
-   {
-      return this.index - other.index;
-   }
 
-
    /**
-    * Computes hashCode - performance optimization.
+    * Get the after.
     * 
-    * @return computed hashCode value
+    * @return the after.
     */
-   private int computeHashCode()
+   public String getAfter()
    {
-      int result = 17;
-      
-      result = 37 * result + this.name.hashCode();
-      result = 37 * result + this.index;
-      result = 37 * result + ( this.after == null ? 0 : this.after.hashCode() );
-      result = 37 * result + ( this.before == null ? 0 : this.before.hashCode() );
-      
-      return result;
+      return after;
    }
 
    /**
-    * Computes toString - performance optimization.
+    * Get the before.
     * 
-    * @return computed toString value
+    * @return the before.
     */
-   private String computeToString()
+   public String getBefore()
    {
-      final StringBuilder sb = new StringBuilder();
-
-      sb.append( this.getName() ).append( "[after=" );
-      sb.append( ( this.after != null ) ? this.after.getName() : null );
-      sb.append( ",before=" );
-      sb.append( ( this.before != null ) ? this.before.getName() : null );
-      sb.append( "]" );
+      return before;
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+         return true;
+      if (obj == null || obj instanceof DeploymentStage == false)
+         return false;
       
-      return sb.toString();
+      DeploymentStage other = (DeploymentStage) obj;
+      return getName().equals(other.getName());
    }
 
+   @Override
+   public int hashCode()
+   {
+      return getName().hashCode();
+   }
+   
+   @Override
+   public String toString()
+   {
+      return getName();
+   }
 }

Modified: projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java	2009-06-25 19:06:38 UTC (rev 90602)
+++ projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java	2009-06-25 22:34:31 UTC (rev 90603)
@@ -22,98 +22,40 @@
 package org.jboss.deployers.spi.deployer;
 
 /**
- * The standard deployment stages.
+ * The Standard DeploymentStages.
  * 
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
  * @version $Revision: 1.1 $
  */
-public final class DeploymentStages
+public interface DeploymentStages
 {
-   
-   /**
-    * Forbidden constructor.
-    */
-   private DeploymentStages()
-   {
-      super();
-   }
-
    /** The not installed stage - nothing is done here */
-   public static final DeploymentStage NOT_INSTALLED = new DeploymentStage("Not Installed");
+   DeploymentStage NOT_INSTALLED = new DeploymentStage("Not Installed");
 
    /** The parse stage - where metadata is read */
-   public static final DeploymentStage PARSE = new DeploymentStage("Parse");
+   DeploymentStage PARSE = new DeploymentStage("Parse", NOT_INSTALLED);
 
    /** The post parse stage - where metadata can be fixed up */
-   public static final DeploymentStage POST_PARSE = new DeploymentStage("PostParse");
+   DeploymentStage POST_PARSE = new DeploymentStage("PostParse", PARSE);
 
    /** The pre describe stage - where default dependencies metadata can be created */
-   public static final DeploymentStage PRE_DESCRIBE = new DeploymentStage("PreDescribe");
+   DeploymentStage PRE_DESCRIBE = new DeploymentStage("PreDescribe", POST_PARSE);
 
    /** The describe stage - where dependencies are established */
-   public static final DeploymentStage DESCRIBE = new DeploymentStage("Describe");
+   DeploymentStage DESCRIBE = new DeploymentStage("Describe", PRE_DESCRIBE);
 
    /** The classloader stage - where classloaders are created */
-   public static final DeploymentStage CLASSLOADER = new DeploymentStage("ClassLoader");
+   DeploymentStage CLASSLOADER = new DeploymentStage("ClassLoader", DESCRIBE);
 
    /** The post classloader stage - e.g. aop */
-   public static final DeploymentStage POST_CLASSLOADER = new DeploymentStage("PostClassLoader");
+   DeploymentStage POST_CLASSLOADER = new DeploymentStage("PostClassLoader", CLASSLOADER);
 
    /** The pre real stage - where before real deployments are done */
-   public static final DeploymentStage PRE_REAL = new DeploymentStage("PreReal");
+   DeploymentStage PRE_REAL = new DeploymentStage("PreReal", POST_CLASSLOADER);
 
    /** The real stage - where real deployment processing is done */
-   public static final DeploymentStage REAL = new DeploymentStage("Real");
+   DeploymentStage REAL = new DeploymentStage("Real", PRE_REAL);
 
    /** The installed stage - could be used to provide valve in future? */
-   public static final DeploymentStage INSTALLED = new DeploymentStage("Installed");
-
-   /**
-    * Turn deployment stages into immutable objects.
-    */
-   static
-   {
-      int index = 1;
-      DeploymentStages.NOT_INSTALLED.initialize( null, PARSE, index++ );
-      DeploymentStages.PARSE.initialize( NOT_INSTALLED, POST_PARSE, index++ );
-      DeploymentStages.POST_PARSE.initialize( PARSE, PRE_DESCRIBE, index++ );
-      DeploymentStages.PRE_DESCRIBE.initialize( POST_PARSE, DESCRIBE, index++ );
-      DeploymentStages.DESCRIBE.initialize( PRE_DESCRIBE, CLASSLOADER, index++ );
-      DeploymentStages.CLASSLOADER.initialize( DESCRIBE, POST_CLASSLOADER, index++ );
-      DeploymentStages.POST_CLASSLOADER.initialize( CLASSLOADER, PRE_REAL, index++ );
-      DeploymentStages.PRE_REAL.initialize( POST_CLASSLOADER, REAL, index++ );
-      DeploymentStages.REAL.initialize( PRE_REAL, INSTALLED, index++ );
-      DeploymentStages.INSTALLED.initialize( REAL, null, index++ );
-   }
-
-   /**
-    * Returns DeploymentStage instance associated with <b>stageAsString</b> stage name.
-    * 
-    * @param stageAsString name of the stage
-    * @return associated DeploymentStage
-    */
-   public static final DeploymentStage valueOf( final String stageAsString )
-   {
-      if ( null == stageAsString )
-      {
-         throw new NullPointerException( "stage" );
-      }
-      
-      DeploymentStage currentStage = DeploymentStages.NOT_INSTALLED;
-      while ( currentStage != null )
-      {
-         if ( currentStage.getName().equals( stageAsString ) )
-         {
-            return currentStage;
-         }
-         else
-         {
-            currentStage = currentStage.getBefore();
-         }
-      }
-
-      throw new IllegalArgumentException( "Uknown stage: " + stageAsString );
-   }
-   
+   DeploymentStage INSTALLED = new DeploymentStage("Installed", REAL);
 }

Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2009-06-25 19:06:38 UTC (rev 90602)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2009-06-25 22:34:31 UTC (rev 90603)
@@ -330,8 +330,8 @@
          return;
 
       ControllerState preceeds = null;
-      String before = stage.getBefore() != null ? stage.getBefore().getName() : null;
-      String after = stage.getAfter() != null ? stage.getAfter().getName() : null;
+      String before = stage.getBefore();
+      String after = stage.getAfter();
       if (before != null || after != null)
       {
          // Determine where to put the stage
@@ -610,22 +610,13 @@
    
    public DeploymentStage getDeploymentStage(DeploymentContext context) throws DeploymentException
    {
-      DeploymentControllerContext deploymentControllerContext = 
-         context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
-      
+      DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
       if (deploymentControllerContext == null)
-      {
          return null;
-      }
       ControllerState state = deploymentControllerContext.getState();
       if (ControllerState.ERROR.equals(state))
-      {
          return DeploymentStages.NOT_INSTALLED;
-      }
-      else
-      {
-         return DeploymentStages.valueOf( state.getStateString() );
-      }
+      return new DeploymentStage(state.getStateString());
    }
 
    public void change(DeploymentContext context, DeploymentStage stage) throws DeploymentException




More information about the jboss-cvs-commits mailing list