axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r111811 - in webservices/axis/trunk/java/dev/scratch/prototype2/src: java/org/apache/axis/deployment java/org/apache/axis/deployment/metadata java/org/apache/axis/deployment/metadata/phaserule java/org/apache/axis/phaseresolver test/org/apache/axis/deployment
Date Tue, 14 Dec 2004 11:15:37 GMT
Author: deepal
Date: Tue Dec 14 03:15:34 2004
New Revision: 111811

URL: http://svn.apache.org/viewcvs?view=rev&rev=111811
Log:
moving phase rule to org.apache.axis.phasereolver
Added:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseException.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseMetaData.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseResolver.java
Removed:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/phaserule/
Modified:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentEngine.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentParser.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/ServerMetaData.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/deployment/ServiceTest.java

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentEngine.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentEngine.java?view=diff&rev=111811&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentEngine.java&r1=111810&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentEngine.java&r2=111811
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentEngine.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentEngine.java
Tue Dec 14 03:15:34 2004
@@ -1,8 +1,6 @@
 package org.apache.axis.deployment;
 
 import org.apache.axis.deployment.metadata.ServerMetaData;
-import org.apache.axis.deployment.metadata.phaserule.PhaseException;
-import org.apache.axis.deployment.metadata.phaserule.PhaseResolver;
 import org.apache.axis.deployment.repository.utill.HDFileItem;
 import org.apache.axis.deployment.repository.utill.UnZipJAR;
 import org.apache.axis.deployment.repository.utill.WSInfo;
@@ -15,6 +13,8 @@
 import org.apache.axis.engine.Handler;
 import org.apache.axis.impl.description.SimpleAxisServiceImpl;
 import org.apache.axis.impl.engine.EngineRegistryImpl;
+import org.apache.axis.phaseresolver.PhaseException;
+import org.apache.axis.phaseresolver.PhaseResolver;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -181,8 +181,9 @@
         if(faultFlow != null) {
             addFlowHandlers(faultFlow,classLoader);
         }
-            PhaseResolver reolve = new PhaseResolver(engineRegistry,serviceMetaData);
-            reolve.buildchains();
+        PhaseResolver reolve = new PhaseResolver(engineRegistry,serviceMetaData);
+        reolve.buildchains();
+        engineRegistry.addService(serviceMetaData);
     }
 
 

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentParser.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentParser.java?view=diff&rev=111811&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentParser.java&r1=111810&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentParser.java&r2=111811
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentParser.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/DeploymentParser.java
Tue Dec 14 03:15:34 2004
@@ -9,7 +9,6 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axis.deployment.metadata.ServerMetaData;
-import org.apache.axis.deployment.metadata.phaserule.PhaseException;
 import org.apache.axis.description.AxisModule;
 import org.apache.axis.description.AxisOperation;
 import org.apache.axis.description.AxisService;
@@ -21,6 +20,7 @@
 import org.apache.axis.impl.description.ParameterImpl;
 import org.apache.axis.impl.description.SimpleAxisOperationImpl;
 import org.apache.axis.impl.providers.SimpleJavaProvider;
+import org.apache.axis.phaseresolver.PhaseException;
 
 
 /**

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/ServerMetaData.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/ServerMetaData.java?view=diff&rev=111811&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/ServerMetaData.java&r1=111810&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/ServerMetaData.java&r2=111811
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/ServerMetaData.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/deployment/metadata/ServerMetaData.java
Tue Dec 14 03:15:34 2004
@@ -1,6 +1,6 @@
 package org.apache.axis.deployment.metadata;
 
-import org.apache.axis.deployment.metadata.phaserule.PhaseMetaData;
+import org.apache.axis.phaseresolver.PhaseMetaData;
 import org.apache.axis.description.*;
 import org.apache.axis.description.HandlerMetaData;
 

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseException.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseException.java?view=auto&rev=111811
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseException.java
Tue Dec 14 03:15:34 2004
@@ -0,0 +1,37 @@
+package org.apache.axis.phaseresolver;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Deepal Jayasinghe
+ *         Nov 8, 2004
+ *         2:08:38 PM
+ */
+public class PhaseException extends Exception {
+    public PhaseException() {
+    }
+
+    public PhaseException(String message) {
+        super(message);
+    }
+
+    public PhaseException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public PhaseException(Throwable cause) {
+        super(cause);
+    }
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java?view=auto&rev=111811
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
Tue Dec 14 03:15:34 2004
@@ -0,0 +1,177 @@
+package org.apache.axis.phaseresolver;
+
+import org.apache.axis.deployment.DeploymentConstants;
+import org.apache.axis.deployment.metadata.ServerMetaData;
+import org.apache.axis.description.AxisService;
+import org.apache.axis.description.HandlerMetaData;
+import org.apache.axis.engine.ExecutionChain;
+import org.apache.axis.engine.Phase;
+import org.apache.axis.phaseresolver.PhaseException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Vector;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Deepal Jayasinghe
+ *         Nov 8, 2004
+ *         2:21:17 PM
+ *
+ */
+
+
+/**
+ * This class hold all the phases found in the service.xml and server.xml
+ */
+public class PhaseHolder implements DeploymentConstants {
+
+    private Log log = LogFactory.getLog(getClass());
+    private Vector phaseholder = new Vector();
+
+    /**
+     * Referance to ServerMetaData inorder to get information about phases.
+     */
+    private ServerMetaData serverMetaData;// = new  ServerMetaData();
+    private AxisService service;
+
+
+    public PhaseHolder(ServerMetaData serverMetaDatain,AxisService serviceIN) {
+        this.serverMetaData = serverMetaDatain;
+        this.service = serviceIN;
+    }
+
+    private boolean isPhaseExist(String phaseName) {
+        for (int i = 0; i < phaseholder.size(); i++) {
+            PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+            if (phase.getName().equals(phaseName)) {
+                return true;
+            }
+
+        }
+        return false;
+    }
+
+    public void addHandler(HandlerMetaData handler) throws PhaseException {
+        String phaseName = handler.getRules().getPhaseName();
+
+        if (isPhaseExist(phaseName)) {
+            getPhase(phaseName).addHandler(handler);
+        } else {
+            if (serverMetaData.isPhaseExist(phaseName)) {
+                PhaseMetaData newpPhase = new PhaseMetaData(phaseName);
+                addPhase(newpPhase);
+                newpPhase.addHandler(handler);
+            } else {
+                throw new PhaseException("Invalid Phase ," + phaseName + "for the handler
" + handler.getName()    + " dose not exit in server.xml");
+            }
+
+        }
+    }
+
+    private void addPhase(PhaseMetaData phase) {
+        phaseholder.add(phase);
+    }
+
+    private PhaseMetaData getPhase(String phaseName) {
+        for (int i = 0; i < phaseholder.size(); i++) {
+            PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+            if (phase.getName().equals(phaseName)) {
+                return phase;
+            }
+
+        }
+        return null;
+    }
+
+    private  void OrderdPhases() {
+        //todo complet this using phaseordeer
+        PhaseMetaData[] phase = new PhaseMetaData[phaseholder.size()];
+        for (int i = 0; i < phaseholder.size(); i++) {
+            PhaseMetaData tempphase = (PhaseMetaData) phaseholder.elementAt(i);
+            phase[i] = tempphase;
+        }
+        phase = serverMetaData.getOrderPhases(phase);
+        // remove all items inorder to rearrange them
+        phaseholder.removeAllElements();
+
+        for (int i = 0; i < phase.length; i++) {
+            PhaseMetaData phaseMetaData = phase[i];
+            phaseholder.add(phaseMetaData);
+
+        }
+    }
+
+    /**
+     * cahinType
+     *  1 : inFlowExcChain
+     *  2 : OutFlowExeChain
+     *  3 : FaultFlowExcechain
+     * @param chainType
+     * @throws org.apache.axis.phaseresolver.PhaseException
+     */
+    public  void getOrderdHandlers(int chainType) throws PhaseException {
+        OrderdPhases();
+        Vector tempHander = new Vector();
+        HandlerMetaData[] handlers;
+
+        switch (chainType) {
+            case 1 : {
+                ExecutionChain inChain =  new ExecutionChain();//       service.getExecutableInChain();
+                for (int i = 0; i < phaseholder.size(); i++) {
+                    PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+                    Phase axisPhase = new Phase(phase.getName());
+                    handlers = phase.getOrderedHandlers();
+                    for (int j = 0; j < handlers.length; j++) {
+                        axisPhase.addHandler(handlers[j].getHandler());
+                    }
+                    inChain.addPhase(axisPhase);
+                }
+               service.setExecutableInChain(inChain);
+                break;
+            }
+            case 2 : {
+                ExecutionChain outChain =new ExecutionChain();// service.getExecutableOutChain();
+                for (int i = 0; i < phaseholder.size(); i++) {
+                    PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+                    Phase axisPhase = new Phase(phase.getName());
+                    handlers = phase.getOrderedHandlers();
+                    for (int j = 0; j < handlers.length; j++) {
+                        axisPhase.addHandler(handlers[j].getHandler());
+                    }
+                    outChain.addPhase(axisPhase);
+                }
+                service.setExecutableOutChain(outChain);
+                break;
+            }
+            case 3 : {
+                ExecutionChain faultChain = new ExecutionChain();//service.getExecutableFaultChain();
+                for (int i = 0; i < phaseholder.size(); i++) {
+                    PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+                    Phase axisPhase = new Phase(phase.getName());
+                    handlers = phase.getOrderedHandlers();
+                    for (int j = 0; j < handlers.length; j++) {
+                        axisPhase.addHandler(handlers[j].getHandler());
+                    }
+                    faultChain.addPhase(axisPhase);
+                }
+                service.setExecutableFaultChain(faultChain);
+                break;
+            }
+        }
+    }
+
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseMetaData.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseMetaData.java?view=auto&rev=111811
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseMetaData.java
Tue Dec 14 03:15:34 2004
@@ -0,0 +1,387 @@
+package org.apache.axis.phaseresolver;
+
+import org.apache.axis.description.HandlerMetaData;
+import org.apache.axis.phaseresolver.PhaseException;
+
+import java.util.Vector;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Deepal Jayasinghe
+ *         Nov 8, 2004
+ *         1:57:15 PM
+ */
+public class PhaseMetaData {
+
+
+    private final int BOTH_BEFORE_AFTER = 0;
+    private final int BEORE = 1;
+    private final int AFTER = 2;
+    private final int ANYWHERE = 3;
+
+
+    private String name;
+
+    /**
+     * to keet info about phase first handler
+     */
+    private HandlerMetaData phaseFirst;
+    private boolean phasefirstset;
+
+    /**
+     * to keet info about phase last handler
+     */
+    private HandlerMetaData phaseLast;
+    private boolean phaselastset;
+
+    /**
+     * to store and order the handlers
+     */
+    private Vector orderHanders = new Vector();
+
+    /**
+     * to store HandlerMetaData other than phaseFirst and phseLast
+     */
+    private Vector phaseHandlers = new Vector();
+
+    /**
+     * this is want if the phaseFirst and phaseLst same hanlder
+     * that is for this phase there is only one phase
+     */
+    private boolean isonehanlder;
+
+    public PhaseMetaData(String name) {
+        this.name = name;
+        this.phaseHandlers.removeAllElements();
+        this.phasefirstset = false;
+        this.phaselastset = false;
+        this.isonehanlder = false;
+    }
+
+    public HandlerMetaData getPhaseFirst() {
+        return phaseFirst;
+    }
+
+    public void setPhaseFirst(HandlerMetaData phaseFirst) throws PhaseException {
+        if (phasefirstset) {
+            throw new PhaseException("PhaseFirst alredy has been set, cannot have two phaseFirst
Hander for same phase " + this.name);
+        } else {
+            if (getBefoerAfter(phaseFirst) != ANYWHERE) {
+                throw new PhaseException("Hander with PhaseFirst can not have any before
or after proprty error in " + phaseFirst.getName());
+            } else
+                this.phaseFirst = phaseFirst;
+            phasefirstset = true;
+        }
+    }
+
+    public HandlerMetaData getPhaseLast() {
+        return phaseLast;
+    }
+
+    public void setPhaseLast(HandlerMetaData phaseLast) throws PhaseException {
+        if (phaselastset) {
+            throw new PhaseException("PhaseLast alredy has been set, cannot have two PhaseLast
Hander for same phase " + this.name);
+        } else {
+            if (getBefoerAfter(phaseLast) != ANYWHERE) {
+                throw new PhaseException("Hander with PhaseLast property can not have any
before or after proprty error in " + phaseLast.getName());
+            } else
+                this.phaseLast = phaseLast;
+            phaselastset = true;
+        }
+    }
+
+    public void addHandler(HandlerMetaData handler) throws PhaseException {
+        /**
+         * 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);
+
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getBeforeIndex(String beforeName) {
+        return 0;
+    }
+
+    public int getAfterIndex(String afterName) {
+        return 0;
+    }
+
+    public HandlerMetaData[] getOrderedHandlers() throws PhaseException {
+        int size = 0;
+        /**
+         * order the handlers
+         */
+        orderHandlers();
+
+
+        HandlerMetaData handler [];
+        if (isonehanlder) {
+            size = 1;
+            handler = new HandlerMetaData[size];
+            handler[0] = getPhaseFirst();
+            return handler;
+        }
+        if (phasefirstset) {
+            if (phaseHandlers.size() > 0) {
+                phaseHandlers.add(0, getPhaseFirst());
+            } else
+                phaseHandlers.add(getPhaseFirst());
+        }
+        if (phaselastset) {
+            phaseHandlers.add(getPhaseLast());
+        }
+        size = phaseHandlers.size();
+        handler = new HandlerMetaData[size];
+
+        for (int i = 0; i < phaseHandlers.size(); i++) {
+            handler[i] = (HandlerMetaData) phaseHandlers.elementAt(i);
+        }
+        return handler;
+    }
+
+
+    private void orderHandlers() throws PhaseException {
+        validatebefore();
+        validateafter();
+        arrangeHanders();
+        phaseHandlers.removeAllElements();
+        phaseHandlers = orderHanders;
+    }
+
+    /**
+     * This method is to check whether  user try to add a handler whose before property is
+     * phaseFitsr handler , this cannot allowed , so this will throws an exception
+     * otherewise it will retun
+     *
+     * @throws PhaseException
+     */
+    private void validatebefore() throws PhaseException {
+        if (getPhaseFirst() != null) {
+            String phasFirstname = getPhaseFirst().getName().getLocalPart();
+            for (int i = 0; i < phaseHandlers.size(); i++) {
+                HandlerMetaData handler = (HandlerMetaData) phaseHandlers.elementAt(i);
+                if (handler.getRules().getBefore().equals(phasFirstname)) {
+                    throw new PhaseException("Try to plase a Hander " + handler.getName()
+ " before phaseFirst " + phasFirstname);
+                }
+            }
+        } else
+            return;
+    }
+
+
+    /**
+     * This method is to check user try to add or plase a hander after the phaseLast
+     * that operation dose not allowd  so then this throw a exception
+     *
+     * @throws PhaseException
+     */
+    private void validateafter() throws PhaseException {
+        if (getPhaseLast() != null) {
+            String phaseLastName = getPhaseLast().getName().getLocalPart();
+            for (int i = 0; i < phaseHandlers.size(); i++) {
+                HandlerMetaData handler = (HandlerMetaData) phaseHandlers.elementAt(i);
+                if (handler.getName().equals(phaseLastName)) {
+                    throw new PhaseException("Try to plase a Hander " + handler.getName()
+ " after phaseLast " + phaseLastName);
+                }
+            }
+        } else
+            return;
+    }
+
+    private void arrangeHanders() throws PhaseException {
+        int count = 0;
+        int before_after = 0;
+        boolean status = false;
+        HandlerMetaData handler = null;
+        while (phaseHandlers.size() > 0) {
+            if (status) {
+                handler = (HandlerMetaData) phaseHandlers.firstElement();
+            } else
+                handler = (HandlerMetaData) phaseHandlers.get(count);
+
+            status = false;
+            if (count > phaseHandlers.size()) {
+                throw new PhaseException("Incorrect hander order for " + handler.getName());
+            }
+            before_after = getBefoerAfter(handler);
+            switch (before_after) {
+                case ANYWHERE:
+                    {
+                        orderHanders.add(handler);
+                        phaseHandlers.removeElement(handler);
+                        count = 0;
+                        status = true;
+                        break;
+                    }
+                case BEORE:
+                    {
+                        status = insertBefore(handler);
+                        if (status) {
+                            phaseHandlers.removeElement(handler);
+                            count = 0;
+                        }
+                        break;
+                    }
+                case AFTER:
+                    {
+                        status = insertAfter(handler);
+                        if (status) {
+                            phaseHandlers.removeElement(handler);
+                            count = 0;
+                        }
+                        break;
+                    }
+                case BOTH_BEFORE_AFTER:
+                    {
+                        status = insertBeforeandAfter(handler);
+                        if (status) {
+                            phaseHandlers.removeElement(handler);
+                            count = 0;
+                        }
+                        break;
+                    }
+            }
+            count++;
+        }
+    }
+
+    private int getBefoerAfter(HandlerMetaData handler) throws PhaseException {
+        if ((!handler.getRules().getBefore().equals("")) && (!handler.getRules().getAfter().equals("")))
{
+            if (handler.getRules().getBefore().equals(handler.getRules().getAfter())) {
+                throw new PhaseException("Both before and after cannot be the same for this
handler" + handler.getName());
+            }
+            return BOTH_BEFORE_AFTER;
+        } else if (!handler.getRules().getBefore().equals("")) {
+            return BEORE;
+        } else if (!handler.getRules().getAfter().equals("")) {
+            return AFTER;
+        } else
+            return ANYWHERE;
+    }
+
+    private boolean insertBefore(HandlerMetaData handler) {
+        String beforename = handler.getRules().getBefore();
+        if (getPhaseLast() != null) {
+            if (getPhaseLast().getName().equals(beforename)) {
+                orderHanders.add(handler);
+                return true;
+            }
+        }
+        for (int i = 0; i < orderHanders.size(); i++) {
+            HandlerMetaData temphandler = (HandlerMetaData) orderHanders.elementAt(i);
+            if (temphandler.getName().equals(beforename)) {
+                orderHanders.add(i, handler);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private boolean insertAfter(HandlerMetaData handler) {
+        String afterName = handler.getRules().getAfter();
+        if (getPhaseFirst() != null) {
+            if (getPhaseFirst().getName().equals(afterName)) {
+                orderHanders.add(0, handler);
+                return true;
+            }
+        }
+        for (int i = 0; i < orderHanders.size(); i++) {
+            HandlerMetaData temphandler = (HandlerMetaData) orderHanders.elementAt(i);
+            if (temphandler.getName().equals(afterName)) {
+                if (i == orderHanders.size() - 1) {
+                    orderHanders.add(handler);
+                    return true;
+                } else {
+                    orderHanders.add(i + 1, handler);
+                    return true;
+                }
+            }
+
+        }
+        return false;
+    }
+
+    /**
+     * 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
+     */
+    private boolean insertBeforeandAfter(HandlerMetaData handler) throws PhaseException {
+        int before = -1;
+        int after = -1;
+        /**
+         * if hander.after = PhaseFirts and hnder.before = phaselast then
+         * just add the entery to vector
+         */
+        if ((getPhaseFirst() != null) && (getPhaseLast() != null)) {
+            if ((getPhaseFirst().getName().equals(handler.getRules().getAfter())) &&
+                    (getPhaseLast().getName().equals(handler.getRules().getBefore()))) {
+                orderHanders.add(handler);
+                return true;
+            }
+        }
+
+        for (int i = 0; i < orderHanders.size(); i++) {
+            HandlerMetaData temphandler = (HandlerMetaData) orderHanders.elementAt(i);
+            if (handler.getRules().getAfter().equals(temphandler.getName())) {
+                after = i;
+            } else if (handler.getRules().getBefore().equals(temphandler.getName())) {
+                before = i;
+            }
+            if ((after >= 0) && (before >= 0)) {
+                // 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());
+                } else {
+                    orderHanders.add(after + 1, handler);
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+
+}

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseResolver.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseResolver.java?view=auto&rev=111811
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseResolver.java
Tue Dec 14 03:15:34 2004
@@ -0,0 +1,165 @@
+package org.apache.axis.phaseresolver;
+
+import org.apache.axis.deployment.DeploymentEngine;
+import org.apache.axis.deployment.metadata.ServerMetaData;
+import org.apache.axis.description.AxisModule;
+import org.apache.axis.description.AxisService;
+import org.apache.axis.description.Flow;
+import org.apache.axis.description.HandlerMetaData;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.engine.EngineRegistry;
+import org.apache.axis.phaseresolver.PhaseException;
+import org.apache.axis.phaseresolver.PhaseHolder;
+
+import javax.xml.namespace.QName;
+import java.util.Vector;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Deepal Jayasinghe
+ *         Dec 10, 2004
+ *         5:27:11 PM
+ */
+public class PhaseResolver {
+
+    private EngineRegistry engineRegistry ;
+    private AxisService axisService;
+    private PhaseHolder phaseHolder ;
+
+
+    private ServerMetaData server = DeploymentEngine.getServerMetaData();
+
+    public PhaseResolver(EngineRegistry engineRegistry, AxisService axisService ) {
+        this.engineRegistry = engineRegistry;
+        this.axisService = axisService;
+    }
+
+    public void buildchains() throws PhaseException, AxisFault {
+        for(int i =1 ; i < 4 ; i++) {
+            buildExcutionChains(i);
+
+        }
+
+    }
+
+    /**
+     * this opeartion is used to build all the three cahins ,
+     * so type varible is used to difrenciate them
+     *  type = 1 inflow
+     *  type = 2 out flow
+     *  type = 3 fault flow
+     * @param type
+     * @throws AxisFault
+     */
+    public  void buildExcutionChains(int type) throws AxisFault, PhaseException {
+        int flowtype =  type;
+        Vector allHandlers = new Vector();
+        int count = server.getModuleCount();
+        QName moduleName;
+        AxisModule module;
+        Flow flow = null;
+        //adding server specific handlers  . global
+        for(int intA=0 ; intA < count; intA ++){
+            moduleName = server.getModule(intA);
+            module = engineRegistry.getModule(moduleName);
+            switch (flowtype){
+                case 1 : {
+                    flow = module.getInFlow();
+                    break;
+                }
+                case  2 : {
+                    flow = module.getOutFlow();
+                    break;
+                }
+                case 3 : {
+                    flow = module.getFaultFlow();
+                    break;
+                }
+            }
+            for(int j= 0 ; j < flow.getHandlerCount() ; j++ ){
+                HandlerMetaData metadata = flow.getHandler(j);
+                //todo change this in properway
+                if (metadata.getRules().getPhaseName().equals("")){
+                    metadata.getRules().setPhaseName("global");
+                }
+                allHandlers.add(metadata);
+            }
+        }
+
+        // service module handlers
+        Vector modules = (Vector)axisService.getModules();
+        for (int i = 0; i < modules.size(); i++) {
+            QName moduleref = (QName) modules.elementAt(i);
+            module = engineRegistry.getModule(moduleref);
+            switch (flowtype){
+                case 1 : {
+                    flow = module.getInFlow();
+                    break;
+                }
+                case  2 : {
+                    flow = module.getOutFlow();
+                    break;
+                }
+                case 3 : {
+                    flow = module.getFaultFlow();
+                    break;
+                }
+            }
+            for(int j= 0 ; j < flow.getHandlerCount() ; j++ ){
+                HandlerMetaData metadata = flow.getHandler(j);
+                //todo change this in properway
+                if (metadata.getRules().getPhaseName().equals("") ){
+                    metadata.getRules().setPhaseName("service");
+                }
+                allHandlers.add(metadata);
+            }
+
+        }
+
+        switch (flowtype){
+            case 1 : {
+                flow = axisService.getInFlow();
+                break;
+            }
+            case  2 : {
+                flow = axisService.getOutFlow();
+                break;
+            }
+            case 3 : {
+                flow = axisService.getFaultFlow();
+                break;
+            }
+        }
+        for(int j= 0 ; j < flow.getHandlerCount() ; j++ ){
+            HandlerMetaData metadata = flow.getHandler(j);
+            //todo change this in properway
+            if (metadata.getRules().getPhaseName().equals("")){
+                metadata.getRules().setPhaseName("service");
+            }
+            allHandlers.add(metadata);
+        }
+
+        phaseHolder = new PhaseHolder(server,axisService);
+
+        for (int i = 0; i < allHandlers.size(); i++) {
+            HandlerMetaData handlerMetaData = (HandlerMetaData) allHandlers.elementAt(i);
+            phaseHolder.addHandler(handlerMetaData);
+        }
+        phaseHolder.getOrderdHandlers(type);
+
+    }
+
+}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/deployment/ServiceTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/deployment/ServiceTest.java?view=diff&rev=111811&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/deployment/ServiceTest.java&r1=111810&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/deployment/ServiceTest.java&r2=111811
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/deployment/ServiceTest.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/deployment/ServiceTest.java
Tue Dec 14 03:15:34 2004
@@ -1,12 +1,11 @@
 package org.apache.axis.deployment;
 
-import javax.xml.stream.XMLStreamException;
-
 import junit.framework.TestCase;
-
-import org.apache.axis.deployment.metadata.phaserule.PhaseException;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.engine.EngineRegistry;
+import org.apache.axis.phaseresolver.PhaseException;
+
+import javax.xml.stream.XMLStreamException;
 
 /**
  * Copyright 2001-2004 The Apache Software Foundation.

Mime
View raw message