You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2005/03/07 06:08:36 UTC

svn commit: r156392 - in webservices/axis/trunk/java/modules: core/src/java/org/apache/axis/phaseresolver/ deployment/src/java/org/apache/axis/deployment/ deployment/src/samples/deployment/module1/META-INF/ deployment/src/samples/deployment/module2/META-INF/ deployment/src/samples/deployment/service2/META-INF/ deployment/src/test/org/apache/axis/deployment/

Author: deepal
Date: Sun Mar  6 21:08:33 2005
New Revision: 156392

URL: http://svn.apache.org/viewcvs?view=rev&rev=156392
Log:
Implemented to support full phase rule capability. 
Validate phasefist , pahselast , and pahse properties of order tag inside a handler element

Modified:
    webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
    webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseMetadata.java
    webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis/deployment/DeploymentEngine.java
    webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module1/META-INF/module.xml
    webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module2/META-INF/module.xml
    webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service2/META-INF/service.xml
    webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/BuildERWithDeploymentTest.java
    webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/DeploymentotalTest.java

Modified: webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseHolder.java?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseHolder.java (original)
+++ webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseHolder.java Sun Mar  6 21:08:33 2005
@@ -1,18 +1,18 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.
+*/
 package org.apache.axis.phaseresolver;
 
 import org.apache.axis.description.AxisGlobal;
@@ -113,9 +113,9 @@
                 newpPhase.addHandler(handler);
             } else {
                 throw new PhaseException("Invalid Phase ," + phaseName
-                                + "for the handler "
-                                + handler.getName()
-                                + " dose not exit in server.xml");
+                        + "for the handler "
+                        + handler.getName()
+                        + " dose not exit in server.xml");
             }
         }
     }
@@ -188,6 +188,23 @@
         return tempphase;
     }
 
+    public ArrayList getOrderHandler() throws PhaseException {
+        ArrayList handlerList = new ArrayList();
+        OrderThePhases();
+        HandlerMetadata[] handlers;
+        for (int i = 0; i < phaseholder.size(); i++) {
+            PhaseMetadata phase =
+                    (PhaseMetadata) phaseholder.get(i);
+            handlers = phase.getOrderedHandlers();
+            for (int j = 0; j < handlers.length; j++) {
+                handlerList.add(handlers[j]);
+            }
+
+        }
+        return  handlerList;
+    }
+
+
     /**
      * chainType
      * 1 : inFlowExcChain
@@ -289,7 +306,7 @@
                                             handlers[j].getClassName(), true,
                                             Thread.currentThread().getContextClassLoader());
                                     handler =
-                                    (Handler) handlerClass.newInstance();
+                                            (Handler) handlerClass.newInstance();
                                     handler.init(handlers[j]);
                                     handlers[j].setHandler(handler);
                                     axisPhase.addHandler(handlers[j].getHandler());
@@ -320,7 +337,7 @@
                                             handlers[j].getClassName(), true,
                                             Thread.currentThread().getContextClassLoader());
                                     handler =
-                                    (Handler) handlerClass.newInstance();
+                                            (Handler) handlerClass.newInstance();
                                     handler.init(handlers[j]);
                                     handlers[j].setHandler(handler);
                                     axisPhase.addHandler(handlers[j].getHandler());
@@ -351,7 +368,7 @@
                                             handlers[j].getClassName(), true,
                                             Thread.currentThread().getContextClassLoader());
                                     handler =
-                                    (Handler) handlerClass.newInstance();
+                                            (Handler) handlerClass.newInstance();
                                     handler.init(handlers[j]);
                                     handlers[j].setHandler(handler);
                                     axisPhase.addHandler(handlers[j].getHandler());

Modified: webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseMetadata.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseMetadata.java?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseMetadata.java (original)
+++ webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/phaseresolver/PhaseMetadata.java Sun Mar  6 21:08:33 2005
@@ -1,18 +1,18 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.
+*/
 package org.apache.axis.phaseresolver;
 
 import org.apache.axis.description.HandlerMetadata;
@@ -29,9 +29,9 @@
     private static final int BOTH_BEFORE_AFTER = 0;
 
     /**
-     * Field BEORE
+     * Field BEFORE
      */
-    private static final int BEORE = 1;
+    private static final int BEFORE = 1;
 
     /**
      * Field AFTER
@@ -116,13 +116,13 @@
             throws PhaseException {
         if (phasefirstset) {
             throw new PhaseException(
-                    "PhaseFirst alredy has been set, cannot have two phaseFirst Hander for same phase "
-                            + this.name);
+                    "PhaseFirst alredy has been set, cannot have two phaseFirst Handler for same phase "
+                    + this.name);
         } else {
             if (getBeforeAfter(phaseFirst) != ANYWHERE) {
                 throw new PhaseException(
-                        "Hander with PhaseFirst can not have any before or after proprty error in "
-                                + phaseFirst.getName());
+                        "Handler with PhaseFirst can not have any before or after proprty error in "
+                        + phaseFirst.getName());
             } else {
                 this.phaseFirst = phaseFirst;
             }
@@ -148,13 +148,13 @@
     public void setPhaseLast(HandlerMetadata phaseLast) throws PhaseException {
         if (phaselastset) {
             throw new PhaseException(
-                    "PhaseLast already has been set, cannot have two PhaseLast Hander for same phase "
-                            + this.name);
+                    "PhaseLast already has been set, cannot have two PhaseLast Handler for same phase "
+                    + this.name);
         } else {
             if (getBeforeAfter(phaseLast) != ANYWHERE) {
                 throw new PhaseException(
                         "Handler with PhaseLast property can not have any before or after property error in "
-                                + phaseLast.getName());
+                        + phaseLast.getName());
             } else {
                 this.phaseLast = phaseLast;
             }
@@ -169,35 +169,29 @@
      * @throws PhaseException
      */
     public void addHandler(HandlerMetadata handler) throws PhaseException {
+        if (isonehanlder) {
+            throw new PhaseException(this.getName() + "can only have one handler, since there is a " +
+                    "handler with both phaseFirst and PhaseLast true ");
+        } else {
+            if (handler.getRules().isPhaseFirst() && handler.getRules().isPhaseLast()) {
+                if (phaseHandlers.size() > 0) {
+                    throw new PhaseException(this.getName() + " can not have more than one handler "
+                            + handler.getName() + " is invalid or incorrect phase rules");
+                } else {
+                    setPhaseFirst(handler);
+                    setPhaseLast(handler);
+                    isonehanlder = true;
+                }
+            } else if (handler.getRules().isPhaseFirst()) {
+                setPhaseFirst(handler);
+            } else if (handler.getRules().isPhaseLast()) {
+                setPhaseLast(handler);
+            } else
+                phaseHandlers.add(handler);
 
-        /**
-         * for the M1 we are not going to care about phaseFirst , PhaseLast only thinh u can do it
-         * insert it to a pahse.
-         * todo if you uncomment this will work fine for phase Conditions :)
-         */
+        }
 
-        /*
-         * if (isonehanlder) {
-         *   throw new PhaseException(this.getName() + "can only have one handler, since there is a handler with both phaseFirst and PhaseLast true ");
-         * } else {
-         *   if (handler.getRules().isPhaseFirst() && handler.getRules().isPhaseLast()) {
-         *       if (phaseHandlers.size() > 0) {
-         *           throw new PhaseException(this.getName() + " PhaseMetaData already added a hander so this operation not allowed  cannot add the handler " + handler.getName());
-         *       } else {
-         *           setPhaseFirst(handler);
-         *           setPhaseLast(handler);
-         *           isonehanlder = true;
-         *       }
-         *   } else if (handler.getRules().isPhaseFirst()) {
-         *       setPhaseFirst(handler);
-         *   } else if (handler.getRules().isPhaseLast()) {
-         *       setPhaseLast(handler);
-         *   } else
-         *       phaseHandlers.add(handler);
-         *
-         * }
-         */
-        phaseHandlers.add(handler);
+        //phaseHandlers.add(handler);
     }
 
     /**
@@ -208,27 +202,6 @@
     public String getName() {
         return name;
     }
-
-    /**
-     * Method getBeforeIndex
-     *
-     * @param beforeName
-     * @return
-     */
-    public int getBeforeIndex(String beforeName) {
-        return 0;
-    }
-
-    /**
-     * Method getAfterIndex
-     *
-     * @param afterName
-     * @return
-     */
-    public int getAfterIndex(String afterName) {
-        return 0;
-    }
-
     /**
      * Method getOrderedHandlers
      *
@@ -294,10 +267,10 @@
                 HandlerMetadata handler =
                         (HandlerMetadata) phaseHandlers.get(i);
                 if (handler.getRules().getBefore().equals(phasFirstname)) {
-                    throw new PhaseException("Try to plase a Hander "
-                                    + handler.getName()
-                                    + " before phaseFirst "
-                                    + phasFirstname);
+                    throw new PhaseException("Try to insert  a Handler "
+                            + handler.getName()
+                            + " before phaseFirst "
+                            + phasFirstname);
                 }
             }
         } else {
@@ -318,10 +291,10 @@
                 HandlerMetadata handler =
                         (HandlerMetadata) phaseHandlers.get(i);
                 if (handler.getName().equals(phaseLastName)) {
-                    throw new PhaseException("Try to plase a Hander "
-                                    + handler.getName()
-                                    + " after phaseLast "
-                                    + phaseLastName);
+                    throw new PhaseException("Try to insert a Handler "
+                            + handler.getName()
+                            + " after phaseLast "
+                            + phaseLastName);
                 }
             }
         }
@@ -345,8 +318,7 @@
             }
             status = false;
             if (count > phaseHandlers.size()) {
-                throw new PhaseException("Incorrect hander order for "
-                                + handler.getName());
+                throw new PhaseException("Invalid pahse rule for "  + handler.getName());
             }
             before_after = getBeforeAfter(handler);
             switch (before_after) {
@@ -358,7 +330,7 @@
                         status = true;
                         break;
                     }
-                case BEORE:
+                case BEFORE:
                     {
                         status = insertBefore(handler);
                         if (status) {
@@ -386,7 +358,9 @@
                         break;
                     }
             }
-            count++;
+            if(! status){
+                count++;
+            }
         }
     }
 
@@ -404,11 +378,11 @@
                     handler.getRules().getAfter())) {
                 throw new PhaseException(
                         "Both before and after cannot be the same for this handler"
-                                + handler.getName());
+                        + handler.getName());
             }
             return BOTH_BEFORE_AFTER;
         } else if (!handler.getRules().getBefore().equals("")) {
-            return BEORE;
+            return BEFORE;
         } else if (!handler.getRules().getAfter().equals("")) {
             return AFTER;
         } else {
@@ -425,14 +399,14 @@
     private boolean insertBefore(HandlerMetadata handler) {
         String beforename = handler.getRules().getBefore();
         if (getPhaseLast() != null) {
-            if (getPhaseLast().getName().equals(beforename)) {
+            if (getPhaseLast().getName().getLocalPart().equals(beforename)) {
                 orderHanders.add(handler);
                 return true;
             }
         }
         for (int i = 0; i < orderHanders.size(); i++) {
             HandlerMetadata temphandler = (HandlerMetadata) orderHanders.get(i);
-            if (temphandler.getName().equals(beforename)) {
+            if (temphandler.getName().getLocalPart().equals(beforename)) {
                 orderHanders.add(i, handler);
                 return true;
             }
@@ -449,14 +423,14 @@
     private boolean insertAfter(HandlerMetadata handler) {
         String afterName = handler.getRules().getAfter();
         if (getPhaseFirst() != null) {
-            if (getPhaseFirst().getName().equals(afterName)) {
+            if (getPhaseFirst().getName().getLocalPart().equals(afterName)) {
                 orderHanders.add(0, handler);
                 return true;
             }
         }
         for (int i = 0; i < orderHanders.size(); i++) {
             HandlerMetadata temphandler = (HandlerMetadata) orderHanders.get(i);
-            if (temphandler.getName().equals(afterName)) {
+            if (temphandler.getName().getLocalPart().equals(afterName)) {
                 if (i == orderHanders.size() - 1) {
                     orderHanders.add(handler);
                     return true;
@@ -470,13 +444,13 @@
     }
 
     /**
-         * This method assume that both the before and after cant be a same hander
-         * that dose not check inside this , it should check befor calling this method
-         *
-         * @param handler
-         * @return
-         * @throws PhaseException
-         */
+     * This method assume that both the before and after cant be a same hander
+     * that dose not check inside this , it should check befor calling this method
+     *
+     * @param handler
+     * @return
+     * @throws PhaseException
+     */
     private boolean insertBeforeandAfter(HandlerMetadata handler)
             throws PhaseException {
         int before = -1;
@@ -487,17 +461,27 @@
          * just add the entery to vector
          */
         if ((getPhaseFirst() != null) && (getPhaseLast() != null)) {
-            if ((getPhaseFirst().getName().equals(
-                        handler.getRules().getAfter()))
-                    && (getPhaseLast().getName().equals(
-                               handler.getRules().getBefore()))) {
+            if ((getPhaseFirst().getName().getLocalPart().equals(
+                    handler.getRules().getAfter()))
+                    && (getPhaseLast().getName().getLocalPart().equals(
+                            handler.getRules().getBefore()))) {
                 orderHanders.add(handler);
                 return true;
             }
         }
+
+        if(getPhaseFirst() != null &&
+                (getPhaseFirst().getName().getLocalPart().equals(handler.getRules().getAfter()))){
+            after = 0;
+        }
+        if(getPhaseLast() != null &&
+                (getPhaseLast().getName().getLocalPart().equals(handler.getRules().getBefore()))){
+            before = orderHanders.size();
+        }
+
         for (int i = 0; i < orderHanders.size(); i++) {
             HandlerMetadata temphandler = (HandlerMetadata) orderHanders.get(i);
-            if (handler.getRules().getAfter().equals(temphandler.getName())) {
+            if (handler.getRules().getAfter().equals(temphandler.getName().getLocalPart())) {
                 after = i;
             } else if (handler.getRules().getBefore().equals(
                     temphandler.getName())) {
@@ -507,9 +491,12 @@
                 // no point of continue since both the before and after index has found
                 if (after > before) {
                     throw new PhaseException("incorrect handler order for "
-                                    + handler.getName());
+                            + handler.getName());
                 } else {
-                    orderHanders.add(after + 1, handler);
+                    if(after + 1 <= orderHanders.size()){
+                        orderHanders.add(after + 1, handler);
+                    } else
+                        orderHanders.add(after, handler);
                     return true;
                 }
             }

Modified: webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis/deployment/DeploymentEngine.java?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis/deployment/DeploymentEngine.java (original)
+++ webservices/axis/trunk/java/modules/deployment/src/java/org/apache/axis/deployment/DeploymentEngine.java Sun Mar  6 21:08:33 2005
@@ -425,12 +425,15 @@
                         } catch (DeploymentException de) {
                             log.info("Invalid service" + currentFileItem.getName() );
                             log.info("DeploymentException  " + de);
+                            de.printStackTrace();
                         } catch (AxisFault axisFault) {
                             log.info("Invalid service" + currentFileItem.getName() );
                             log.info("AxisFault  " + axisFault);
+                            axisFault.printStackTrace();
                         } catch (Exception e) {
                             log.info("Invalid service" + currentFileItem.getName() );
                             log.info("Exception  " + e);
+                            e.printStackTrace();
                         } finally {
                             currentFileItem = null;
                         }

Modified: webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module1/META-INF/module.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module1/META-INF/module.xml?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module1/META-INF/module.xml (original)
+++ webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module1/META-INF/module.xml Sun Mar  6 21:08:33 2005
@@ -1,7 +1,7 @@
 <module name="module1" class="module1.java">
     <inflow>
         <handler name="h1" class="org.apache.axis.registry.Handler3">
-            <order phase="global" phaseFirst="true"/>
+            <order phase="global" />
         </handler>
         <handler name="h2" class="org.apache.axis.registry.Handler3"/>
     </inflow>

Modified: webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module2/META-INF/module.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module2/META-INF/module.xml?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module2/META-INF/module.xml (original)
+++ webservices/axis/trunk/java/modules/deployment/src/samples/deployment/module2/META-INF/module.xml Sun Mar  6 21:08:33 2005
@@ -1,7 +1,7 @@
 <module name="module2" class="module1.java">
     <inflow>
         <handler name="h1" class="org.apache.axis.registry.Handler4">
-            <order phase="global" phaseFirst="true"/>
+            <order phase="global" />
         </handler>
         <handler name="h2" class="org.apache.axis.registry.Handler4"/>
     </inflow>

Modified: webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service2/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service2/META-INF/service.xml?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service2/META-INF/service.xml (original)
+++ webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service2/META-INF/service.xml Sun Mar  6 21:08:33 2005
@@ -38,7 +38,7 @@
         </handler>
 
         <handler name="h6" class="Handler2">
-            <order phase="service" phaseFirst="true" phaseLast="false"/>
+            <order phase="service" phaseLast="false"/>
         </handler>
     </faultflow>
     <operation name="opname"/>

Modified: webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/BuildERWithDeploymentTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/BuildERWithDeploymentTest.java?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/BuildERWithDeploymentTest.java (original)
+++ webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/BuildERWithDeploymentTest.java Sun Mar  6 21:08:33 2005
@@ -50,7 +50,7 @@
         Class.forName("Echo2", true, cl);
         assertNotNull(service.getName());
         assertEquals(service.getStyle(),"rpc");
-        
+
         Flow flow = service.getFaultFlow();
         assertTrue(flow.getHandlerCount() > 0);
         flow = service.getInFlow();

Modified: webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/DeploymentotalTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/DeploymentotalTest.java?view=diff&r1=156391&r2=156392
==============================================================================
--- webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/DeploymentotalTest.java (original)
+++ webservices/axis/trunk/java/modules/deployment/src/test/org/apache/axis/deployment/DeploymentotalTest.java Sun Mar  6 21:08:33 2005
@@ -27,7 +27,7 @@
     EngineRegistry er;
 
     public void testparseService1() throws PhaseException, DeploymentException, AxisFault, XMLStreamException {
-        String filename = "./target/test-resources/deployment";
+        String filename = "./modules/deployment/target/test-resources/deployment";
         DeploymentEngine deploymentEngine = new DeploymentEngine(filename);
         er = deploymentEngine.start();
     }