You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2007/12/31 18:30:54 UTC

svn commit: r607758 - in /webservices/axis2/trunk/java/modules/kernel: src/org/apache/axis2/deployment/ src/org/apache/axis2/engine/ test-resources/deployment/module1/META-INF/ test/org/apache/axis2/deployment/

Author: gdaniels
Date: Mon Dec 31 09:30:40 2007
New Revision: 607758

URL: http://svn.apache.org/viewvc?rev=607758&view=rev
Log:
Little cleanup, JavaDoc improvements, move dynamic phase processing up in ModuleBuilder.  Also add an actual handler to NewPhase in the module1 module; need to finish testing that it works when engaged.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DeployableChain.java
    webservices/axis2/trunk/java/modules/kernel/test-resources/deployment/module1/META-INF/module.xml
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java?rev=607758&r1=607757&r2=607758&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java Mon Dec 31 09:30:40 2007
@@ -132,6 +132,10 @@
                 module.setModuleDescription("module description not found");
             }
 
+            // Processing Dynamic Phase
+            Iterator phaseItr = moduleElement.getChildrenWithName(new QName(TAG_PHASE));
+            processModulePhase(phaseItr);
+            
             // setting the PolicyInclude
 
             // processing <wsp:Policy> .. </..> elements
@@ -209,9 +213,6 @@
                 module.addOperation(operation);
             }
 
-            // Processing Dynamic Phase
-            Iterator phaseItr = moduleElement.getChildrenWithName(new QName(TAG_PHASE));
-            processModulePhase(phaseItr);
         } catch (XMLStreamException e) {
             throw new DeploymentException(e);
         } catch(AxisFault e) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DeployableChain.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DeployableChain.java?rev=607758&r1=607757&r2=607758&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DeployableChain.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DeployableChain.java Mon Dec 31 09:30:40 2007
@@ -28,6 +28,11 @@
 import java.util.HashSet;
 import java.util.Iterator;
 
+/**
+ * A DeployableChain is a container which manages dependencies between Deployables.  You
+ * deploy() them in, then call rebuild() which will set up a chain, correctly ordered according
+ * to the constraints in the Deployables.
+ */
 public class DeployableChain {
     /** The actual things (handlers or phases) */
     List chain = new ArrayList();
@@ -35,10 +40,11 @@
     Deployable first;
     Deployable last;
 
+    /** A Map of name -> List (of Strings).  Each List contains the key's successors */
     Map activeConstraints = new HashMap();
-    private Map deployed = new HashMap();
 
-    Map activePhaseConstraints = new HashMap();
+    /** A Map of name -> Deployable for all deployed items */
+    private Map deployed = new HashMap();
 
     /**
      * Deploy a Deployable into this chain.  Note that this does NOT order yet.  The idea
@@ -51,12 +57,18 @@
      */
     public void deploy(Deployable deployable) throws Exception {
         String name = deployable.getName();
+        Set mySuccessors = deployable.getSuccessors();
+        Set myPredecessors = deployable.getPredecessors();
 
         if (deployable.isFirst()) {
             if (first != null) {
                 throw new Exception("'" + first.getName() + "' is already first, can't deploy '" +
                     name + "' as first also.");
             }
+            if (myPredecessors != null) {
+                throw new Exception("Deploying '" + name +
+                        "' - can't both be first and have predecessors!");
+            }
             first = deployable;
         }
 
@@ -65,37 +77,29 @@
                 throw new Exception("'" + last.getName() + "' is already last, can't deploy '" +
                         name + "' as last also.");
             }
+            if (mySuccessors != null) {
+                throw new Exception("Deploying '" + name +
+                        "' - can't both be last and have successors!");
+            }
             last = deployable;
         }
 
-        // Now check internal consistency
-        Set mySuccessors = deployable.getSuccessors();
-        Set myPredecessors = deployable.getPredecessors();
-
-        if (mySuccessors != null && deployable.isLast()) {
-            throw new Exception("Deploying '" + name +
-                    "' - can't both be last and have successors!");
-        }
-        if (myPredecessors != null && deployable.isFirst()) {
-            throw new Exception("Deploying '" + name +
-                    "' - can't both be first and have predecessors!");
-        }
-
         Deployable previous = (Deployable)deployed.get(name);
         if (previous == null) {
             deployed.put(name, deployable);
         } else {
             // If something by this name already exists, ensure it's compatible
             if (previous.isFirst() != deployable.isFirst()) {
-                throw new Exception();
+                throw new Exception("Can't deploy '" + name + "', values for first don't match!");
             }
             if (previous.isLast() != deployable.isLast()) {
-                throw new Exception();
+                throw new Exception("Can't deploy '" + name + "', values for last don't match!");
             }
             Object target = previous.getTarget();
             if (target != null) {
                 if (deployable.getTarget() != null && !target.equals(deployable.getTarget())) {
-                    throw new Exception();
+                    throw new Exception("Can't deploy '" + name +
+                            "',  targets must either match or be null.");
                 }
             } else {
                 previous.setTarget(deployable.getTarget());
@@ -228,6 +232,12 @@
         }
     }
 
+    /**
+     * Adds a before/after relationship to the active constraints.
+     *
+     * @param before name of the Deployable that must come first
+     * @param after name of the Deployable that must come later
+     */
     public void addRelationship(String before, String after) {
         Set successors = (Set)activeConstraints.get(before);
         if (successors == null) {
@@ -237,7 +247,13 @@
         successors.add(after);
     }
 
+    /**
+     * Get the chain - once rebuild() has been called this will be the chain of target objects.
+     *
+     * @return a List of target objects in the correct order
+     */
     public List getChain() {
+        // todo - should this call rebuild() automatically (if dirty flag is set)?
         return chain;
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/test-resources/deployment/module1/META-INF/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test-resources/deployment/module1/META-INF/module.xml?rev=607758&r1=607757&r2=607758&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test-resources/deployment/module1/META-INF/module.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/test-resources/deployment/module1/META-INF/module.xml Mon Dec 31 09:30:40 2007
@@ -24,6 +24,9 @@
         <handler name="h2" class="org.apache.axis2.registry.Handler3">
             <order phase="OperationInPhase"/>
         </handler>
+        <handler name="h6" class="org.apache.axis2.registry.Handler3">
+            <order phase="NewPhase"/>
+        </handler>
     </InFlow>
 
     <OutFlow>

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java?rev=607758&r1=607757&r2=607758&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java Mon Dec 31 09:30:40 2007
@@ -31,25 +31,24 @@
 import java.util.ArrayList;
 
 public class DeploymentTotalTest extends TestCase {
-    AxisConfiguration er;
-
+    AxisConfiguration axisConfig;
 
     protected void setUp() throws Exception {
         String filename = AbstractTestCase.basedir + "/target/test-resources/deployment";
-        er = ConfigurationContextFactory
+        axisConfig = ConfigurationContextFactory
                 .createConfigurationContextFromFileSystem(filename, filename + "/axis2.xml")
                 .getAxisConfiguration();
          // OK, no exceptions.  Now make sure we read the correct file...
     }
 
     public void testparseService1() throws AxisFault, XMLStreamException {
-        Parameter param = er.getParameter("FavoriteColor");
+        Parameter param = axisConfig.getParameter("FavoriteColor");
         assertNotNull("No FavoriteColor parameter in axis2.xml!", param);
         assertEquals("purple", param.getValue());
     }
 
     public void testDynamicPhase() {
-        ArrayList inFlow = er.getInFlowPhases();
+        ArrayList inFlow = axisConfig.getInFlowPhases();
         int index = 0;
         for (int i = 0; i < inFlow.size(); i++) {
             Phase phase = (Phase) inFlow.get(i);
@@ -59,7 +58,7 @@
         }
         assertEquals("Wrong index for NewPhase!", 3, index);
 
-        inFlow = er.getInFaultFlowPhases();
+        inFlow = axisConfig.getInFaultFlowPhases();
         boolean found = false;
         for (int i = 0; i < inFlow.size(); i++) {
             Phase phase = (Phase) inFlow.get(i);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org