axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r386280 - in /webservices/axis2/trunk/java/modules/core: src/org/apache/axis2/context/ src/org/apache/axis2/deployment/ src/org/apache/axis2/engine/ src/org/apache/axis2/phaseresolver/ src/org/apache/axis2/transport/http/ test/org/apache/ax...
Date Thu, 16 Mar 2006 07:58:32 GMT
Author: deepal
Date: Wed Mar 15 23:58:30 2006
New Revision: 386280

URL: http://svn.apache.org/viewcvs?rev=386280&view=rev
Log:
- adding handler into each phases in a given flow
- so if the phase name of a handler is "*" then the handler will be added to all the phases
in the flow
- and it should not that it will ignore before after , and will support phase first , phase
last.

Added:
    webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/phaseresolver/PhaseHolder.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
    webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/PhaseRuleTest.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java?rev=386280&r1=386279&r2=386280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
Wed Mar 15 23:58:30 2006
@@ -37,15 +37,48 @@
     }
 
     /**
-     * Builds the configuration.
+     * To get a ConfigurationContext for  given data , and underline implementation
+     * is Axis2 default impl which is file system based deployment model to create
+     * an AxisConfiguration.
+     * <p/>
+     * Here either or both parameter can be null. So that boil down to following
+     * scanarios and it should note that parameter value should be pull path ,
+     * you are not allowed to give one relative to other. And these two can be located
+     * in completely different locations.
+     * <ul>
+     * <li>If none of them are null , then AxisConfiguration will be based on the
+     * value of axis2xml , and the repositoy will be the value specified by the
+     * path paramter and there will not be any assumptions.</li>
+     * <li>If axis2xml is null , then the repository will be the value specfied by
+     * path parameter and , system will try to find axis2.xml from sub directory
+     * called "conf" inside the repository, so if system find
+     * repository/conf/axis2/xml then AxisConfiguration will be created using that
+     * else AxisConfiguration will be created using default_axis2.xml</li>
+     * <li>If path parameter is null , then AxisConfiguration will be created using
+     * that axis2.xml. And after creatig AxisConfiguration system will try to
+     * find user has specified repository parameter in axis2.xml
+     * (&lt;parameter name="repository"&gt;locationo of the repo&lt;/parameter&gt;)
, if it
+     * find that then repository will be the value specified by that parameter.</li>
+     * <li>If both are null , then it is simple , AixsConfiguration will be created
+     * using default_axis2.xml and thats it.</li>
+     * </ul>
+     * <p/>
+     * Note : rather than passing any paremeters you can give them as System
+     * properties. Simple you can add following system properties before
+     * you call this.
+     * <ul>
+     * <li>axis2.repo : same as path paramter</li>
+     * <li>axis2.xml  : same as axis2xml</li>
+     * </ul>
      *
      * @param path     : location of the repository
      * @param axis2xml : location of the axis2.xml (configuration) file
      * @return Returns the built ConfigurationContext.
      * @throws DeploymentException
      */
-    public static ConfigurationContext createConfigurationContextFromFileSystem(String path,
-                                                                                String axis2xml)
throws AxisFault {
+    public static ConfigurationContext createConfigurationContextFromFileSystem(
+            String path,
+            String axis2xml) throws AxisFault {
         return createConfigurationContext(new FileSystemConfigurator(path, axis2xml));
     }
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=386280&r1=386279&r2=386280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java
Wed Mar 15 23:58:30 2006
@@ -43,6 +43,8 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
 
 public class DeploymentEngine implements DeploymentConstants {
 
@@ -87,7 +89,7 @@
     public DeploymentEngine(String repositoryName, String xmlFile)
             throws DeploymentException {
         if ((repositoryName == null || "".equals(repositoryName.trim())) &&
-            (xmlFile == null || "".equals(xmlFile.trim()))) {
+                (xmlFile == null || "".equals(xmlFile.trim()))) {
             String axis2_home = System.getProperty(Constants.AXIS2_HOME);
             if (axis2_home != null && !"".equals("")) {
                 useDefault = false;
@@ -233,8 +235,50 @@
             }
             contolops.clear();
         }
-
         axisConfig.addServiceGroup(serviceGroup);
+//        addAsWebResources(currentArchiveFile.getFile(),
+//                serviceGroup.getServiceGroupName());
+    }
+
+    private void addAsWebResources(File in, String serviceFileName) {
+        try {
+            String webLocationStr = System.getProperty("web.location");
+            if (webLocationStr == null) {
+                return;
+            }
+            if (in.isDirectory()) {
+                return;
+            }
+            File webLocation = new File(webLocationStr);
+            File out = new File(webLocation, serviceFileName);
+            int BUFFER = 1024;
+            byte data[] = new byte[BUFFER];
+            ZipInputStream zin = new ZipInputStream(
+                    new FileInputStream(in));
+            ZipEntry entry;
+            while ((entry = zin.getNextEntry()) != null) {
+                ZipEntry zip = new ZipEntry(entry);
+                if (zip.getName().toUpperCase().startsWith("WWW")) {
+                    String fileName = zip.getName();
+                    fileName = fileName.substring("WWW/".length(),
+                            fileName.length());
+                    if (zip.isDirectory()) {
+                        new File(out, fileName).mkdirs();
+                    } else {
+                        FileOutputStream tempOut = new FileOutputStream(new File(out, fileName));
+                        int count;
+                        while ((count = zin.read(data, 0, BUFFER)) != -1) {
+                            tempOut.write(data, 0, count);
+                        }
+                        tempOut.close();
+                        tempOut.flush();
+                    }
+                }
+            }
+            zin.close();
+        } catch (IOException e) {
+            log.info(e.getMessage());
+        }
     }
 
     /**
@@ -271,7 +315,7 @@
             currentArchiveFile.setClassLoader(false, config.getModuleClassLoader());
             axismodule.setModuleClassLoader(currentArchiveFile.getClassLoader());
             archiveReader.readModuleArchive(currentArchiveFile.getAbsolutePath(), this, axismodule,
-                                            false, axisConfig);
+                    false, axisConfig);
             ClassLoader moduleClassLoader = axismodule.getModuleClassLoader();
             Flow inflow = axismodule.getInFlow();
 
@@ -334,7 +378,7 @@
             currentArchiveFile.setClassLoader(classLoader);
 
             ServiceBuilder builder = new ServiceBuilder(serviceInputStream, axisConfig,
-                                                        axisService);
+                    axisService);
 
             builder.populateService(builder.buildOM());
         } catch (AxisFault axisFault) {
@@ -358,12 +402,12 @@
                     switch (type) {
                         case TYPE_SERVICE :
                             currentArchiveFile.setClassLoader(explodedDir,
-                                                              axisConfig.getServiceClassLoader());
+                                    axisConfig.getServiceClassLoader());
                             archiveReader = new ArchiveReader();
                             String serviceStatus = "";
                             try {
                                 HashMap wsdlservice = archiveReader.processWSDLs(currentArchiveFile,
-                                                                                 this);
+                                        this);
                                 AxisServiceGroup sericeGroup = new AxisServiceGroup(axisConfig);
                                 sericeGroup.setServiceGroupClassLoader(
                                         currentArchiveFile.getClassLoader());
@@ -373,39 +417,39 @@
                                         axisConfig);
                                 addServiceGroup(sericeGroup, serviceList);
                                 log.debug(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS,
-                                                              currentArchiveFile.getName()));
+                                        currentArchiveFile.getName()));
                             } catch (DeploymentException de) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
-                                                             currentArchiveFile.getName(),
-                                                             de.getMessage()));
+                                        currentArchiveFile.getName(),
+                                        de.getMessage()));
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
                                 de.printStackTrace(error_ptintWriter);
                                 serviceStatus = "Error:\n" + errorWriter.toString();
                             } catch (AxisFault axisFault) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
-                                                             currentArchiveFile.getName(),
-                                                             axisFault.getMessage()));
+                                        currentArchiveFile.getName(),
+                                        axisFault.getMessage()));
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
                                 axisFault.printStackTrace(error_ptintWriter);
                                 serviceStatus = "Error:\n" + errorWriter.toString();
                             } catch (Exception e) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
-                                                             currentArchiveFile.getName(),
-                                                             e.getMessage()));
+                                        currentArchiveFile.getName(),
+                                        e.getMessage()));
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
                                 e.printStackTrace(error_ptintWriter);
                                 serviceStatus = "Error:\n" + errorWriter.toString();
                             } finally {
                                 if (serviceStatus.startsWith("Error:")) {
                                     axisConfig.getFaultyServices().put(currentArchiveFile.getFile().getAbsolutePath(),
-                                                                       serviceStatus);
+                                            serviceStatus);
                                 }
                                 currentArchiveFile = null;
                             }
                             break;
                         case TYPE_MODULE :
                             currentArchiveFile.setClassLoader(explodedDir,
-                                                              axisConfig.getModuleClassLoader());
+                                    axisConfig.getModuleClassLoader());
                             archiveReader = new ArchiveReader();
                             String moduleStatus = "";
                             try {
@@ -413,23 +457,23 @@
                                 metaData.setModuleClassLoader(currentArchiveFile.getClassLoader());
                                 metaData.setParent(axisConfig);
                                 archiveReader.readModuleArchive(currentArchiveFile.getAbsolutePath(),
-                                                                this, metaData, explodedDir,
-                                                                axisConfig);
+                                        this, metaData, explodedDir,
+                                        axisConfig);
                                 metaData.setFileName(currentArchiveFile.getAbsolutePath());
                                 addNewModule(metaData);
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_MODULE,
-                                                             metaData.getName().getLocalPart()));
+                                        metaData.getName().getLocalPart()));
                             } catch (DeploymentException e) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_MODULE,
-                                                             currentArchiveFile.getName(),
-                                                             e.getMessage()));
+                                        currentArchiveFile.getName(),
+                                        e.getMessage()));
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
                                 e.printStackTrace(error_ptintWriter);
                                 moduleStatus = "Error:\n" + errorWriter.toString();
                             } catch (AxisFault axisFault) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_MODULE,
-                                                             currentArchiveFile.getName(),
-                                                             axisFault.getMessage()));
+                                        currentArchiveFile.getName(),
+                                        axisFault.getMessage()));
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
                                 axisFault.printStackTrace(error_ptintWriter);
                                 moduleStatus = "Error:\n" + errorWriter.toString();
@@ -444,7 +488,7 @@
                     }
                 } catch (AxisFault axisFault) {
                     log.info(Messages.getMessage(DeploymentErrorMsgs.ERROR_SETTING_CLIENT_HOME,
-                                                 axisFault.getMessage()));
+                            axisFault.getMessage()));
                 }
             }
         }
@@ -467,12 +511,11 @@
         if (useDefault && axis2repository == null) {
             ClassLoader cl = Thread.currentThread().getContextClassLoader();
             InputStream in = cl.getResourceAsStream(AXIS2_CONFIGURATION_RESOURCE);
-            AxisConfigBuilder builder = new AxisConfigBuilder(in, this, axisConfig);
-            builder.populateConfig();
-            axisConfig.setPhasesinfo(phasesinfo);
+            populateAxisConfiguration(in);
             //To load modules from the class path
             new RepositoryListener(this);
-            org.apache.axis2.util.Utils.calculateDefaultModuleVersion(axisConfig.getModules(),
axisConfig);
+            org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
+                    axisConfig.getModules(), axisConfig);
             return axisConfig;
         } else if (axis2repository != null) {
             InputStream in;
@@ -486,10 +529,7 @@
                     throw new DeploymentException(e);
                 }
             }
-            AxisConfigBuilder builder = new AxisConfigBuilder(in, this, axisConfig);
-
-            builder.populateConfig();
-            axisConfig.setPhasesinfo(phasesinfo);
+            populateAxisConfiguration(in);
 
             // setting the CLs
             setClassLoaders(axis2repository);
@@ -504,7 +544,7 @@
                 }
             } catch (AxisFault axisFault) {
                 log.info(Messages.getMessage(DeploymentErrorMsgs.MODULE_VALIDATION_FAILED,
-                                             axisFault.getMessage()));
+                        axisFault.getMessage()));
                 throw new DeploymentException(axisFault);
             }
             repoListener.checkServices();
@@ -519,42 +559,91 @@
             } catch (FileNotFoundException e) {
                 throw new DeploymentException(e);
             }
-            AxisConfigBuilder builder = new AxisConfigBuilder(in, this, axisConfig);
-            builder.populateConfig();
-            axisConfig.setPhasesinfo(phasesinfo);
-            Parameter axis2repoPara = axisConfig.getParameter(AXIS2_REPO);
-            if (axis2repoPara != null) {
-                axis2repository = (String) axis2repoPara.getValue();
-                setClassLoaders(axis2repository);
-                setDeploymentFeatures();
-                RepositoryListener repoListener = new RepositoryListener(axis2repository,
this);
-                org.apache.axis2.util.Utils.calculateDefaultModuleVersion(axisConfig.getModules(),
axisConfig);
-                try {
-                    axisConfig.setRepository(axis2repository);
-                    validateSystemPredefinedPhases();
-                    engageModules();
-                } catch (AxisFault axisFault) {
-                    log.info(Messages.getMessage(DeploymentErrorMsgs.MODULE_VALIDATION_FAILED,
-                                                 axisFault.getMessage()));
-                    throw new DeploymentException(axisFault);
-                }
-                repoListener.checkServices();
-                if (hotDeployment) {
-                    startSearch(repoListener);
-                }
-                return axisConfig;
-            } else {
-                log.info(Messages.getMessage("norepofoundinaxis2"));
-                new RepositoryListener(this);
-                org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
-                        axisConfig.getModules(), axisConfig);
+            populateAxisConfiguration(in);
+            return findRepositoryFromAxisConfiguration();
+        }
+    }
+
+    /**
+     * If the axis2.xml has paramter with "repository" then , a repository listener
+     * will be created by using that parameter.HotDeployment and hotupdate will
+     * work as same as given repository seperate scanrio
+     */
+    private AxisConfiguration findRepositoryFromAxisConfiguration()
+            throws DeploymentException {
+        Parameter axis2repoPara = axisConfig.getParameter(AXIS2_REPO);
+        if (axis2repoPara != null) {
+            axis2repository = (String) axis2repoPara.getValue();
+            setClassLoaders(axis2repository);
+            setDeploymentFeatures();
+            RepositoryListener repoListener = new RepositoryListener(
+                    axis2repository, this);
+            org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
+                    axisConfig.getModules(), axisConfig);
+            try {
+                axisConfig.setRepository(axis2repository);
                 validateSystemPredefinedPhases();
-                return axisConfig;
+                engageModules();
+            } catch (AxisFault axisFault) {
+                log.info(Messages.getMessage(
+                        DeploymentErrorMsgs.MODULE_VALIDATION_FAILED,
+                        axisFault.getMessage()));
+                throw new DeploymentException(axisFault);
+            }
+            repoListener.checkServices();
+            if (hotDeployment) {
+                startSearch(repoListener);
             }
+            return axisConfig;
+        } else {
+            log.info(Messages.getMessage("norepofoundinaxis2"));
+            new RepositoryListener(this);
+            org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
+                    axisConfig.getModules(), axisConfig);
+            validateSystemPredefinedPhases();
+            return axisConfig;
         }
     }
 
     /**
+     * To build AxisConfiguration for a given inputStream
+     *
+     * @param in
+     * @throws DeploymentException
+     */
+    private void populateAxisConfiguration(InputStream in) throws DeploymentException {
+        AxisConfigBuilder builder = new AxisConfigBuilder(in, this, axisConfig);
+        builder.populateConfig();
+        axisConfig.setPhasesinfo(phasesinfo);
+    }
+
+
+    /**
+     * To get AxisConfiguration for a given inputStream this method can be used.
+     * The inputstream should be a valid axis2.xml , else you will be getting
+     * DeploymentExceptions.
+     * <p/>
+     * First creat a AxisConfiguration using given inputSream , and then it will
+     * try to find the repository location parameter from AxisConfiguration, so
+     * if user has add a parameter with the name "repository" , then the value
+     * specified by that parameter will be the repositiry and system will try to
+     * load modules and services from that repository location if it a valid
+     * location. hot deployment and hot update will work as usual in this case.
+     * <p/>
+     * You will be getting AxisConfiguration corresponding to given inputstream
+     * if it is valid , if something goes wrong you will be getting
+     * DeploymentExeption
+     *
+     * @param in
+     * @return
+     * @throws DeploymentException
+     */
+    public AxisConfiguration load(InputStream in) throws DeploymentException {
+        populateAxisConfiguration(in);
+        return findRepositoryFromAxisConfiguration();
+    }
+
+    /**
      * Starts the Deployment engine to perform Hot deployment and so on..
      */
     private void startSearch(RepositoryListener listener) {
@@ -573,7 +662,7 @@
                         fileName = getAxisServiceName(wsInfo.getFileName());
                         axisConfig.removeServiceGroup(fileName);
                         log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED,
-                                                     wsInfo.getFileName()));
+                                wsInfo.getFileName()));
                     }
                 }
             }
@@ -598,8 +687,8 @@
             String phase3 = ((Phase) inPhases.get(2)).getPhaseName();
 
             if (!(phase1.equals(PhaseMetadata.PHASE_TRANSPORTIN)
-                  && phases.equals(PhaseMetadata.PHASE_PRE_DISPATCH)
-                  && phase3.equals(PhaseMetadata.PHASE_DISPATCH))) {
+                    && phases.equals(PhaseMetadata.PHASE_PRE_DISPATCH)
+                    && phase3.equals(PhaseMetadata.PHASE_DISPATCH))) {
                 throw new DeploymentException(
                         Messages.getMessage(DeploymentErrorMsgs.INVALID_PHASE));
             }
@@ -698,7 +787,7 @@
 
         if (modules.exists()) {
             axisConfig.setModuleClassLoader(Utils.getClassLoader(axisConfig.getSystemClassLoader(),
-                                                                 modules));
+                    modules));
         } else {
             axisConfig.setModuleClassLoader(axisConfig.getSystemClassLoader());
         }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java?rev=386280&r1=386279&r2=386280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java Wed Mar
15 23:58:30 2006
@@ -37,6 +37,8 @@
 
     private static final long serialVersionUID = -3352439587370050957L;
 
+    public static final String ALL_PHASES = "*";
+
     /**
      * Field BOTH_BEFORE_AFTER
      */
@@ -331,25 +333,18 @@
         switch (type) {
             case BOTH_BEFORE_AFTER : {
                 insertBeforeandAfter(handler);
-
                 break;
             }
-
             case BEFORE : {
                 insertBefore(handler);
-
                 break;
             }
-
             case AFTER : {
                 insertAfter(handler);
-
                 break;
             }
-
             case ANYWHERE : {
                 addHandler(handler);
-
                 break;
             }
         }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/phaseresolver/PhaseHolder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/phaseresolver/PhaseHolder.java?rev=386280&r1=386279&r2=386280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/phaseresolver/PhaseHolder.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/phaseresolver/PhaseHolder.java
Wed Mar 15 23:58:30 2006
@@ -19,7 +19,6 @@
 
 import org.apache.axis2.deployment.DeploymentErrorMsgs;
 import org.apache.axis2.description.HandlerDescription;
-import org.apache.axis2.engine.Handler;
 import org.apache.axis2.engine.Phase;
 import org.apache.axis2.i18n.Messages;
 
@@ -39,51 +38,34 @@
     }
 
     /**
-     * Method addHandler
+     * If the phase name is equal to "*" that implies , the handler should be
+     * added to each and every phase in the system for a given flow  , and at that
+     * point if the phase rule contains any before or aftere then they will be
+     * ignored. Phase first and phase last are supported , but make sure you dont
+     * break any of the phase rules.
+     * <p/>
+     * If the phase name is not above then the hadler will be added to the phase
+     * specified by  the phase rule , and no rules will be ignored.
      *
      * @param handlerDesc
      * @throws PhaseException
      */
     public void addHandler(HandlerDescription handlerDesc) throws PhaseException {
         String phaseName = handlerDesc.getRules().getPhaseName();
-
-        if (isPhaseExist(phaseName)) {
-            getPhase(phaseName).addHandler(handlerDesc);
+        if (Phase.ALL_PHASES.equals(phaseName)) {
+            handlerDesc.getRules().setBefore("");
+            handlerDesc.getRules().setAfter("");
+            for (int i = 0; i < phaseList.size(); i++) {
+                Phase phase = (Phase) phaseList.get(i);
+                phase.addHandler(handlerDesc);
+            }
         } else {
-            throw new PhaseException(Messages.getMessage(DeploymentErrorMsgs.INVALID_PHASE,
-                    phaseName, handlerDesc.getName().getLocalPart()));
-        }
-    }
-
-    /**
-     * This method is to build the transport phase , here load the corresponding handlers
and added them
-     * in to correct phase
-     *
-     * @param phase
-     * @param handlers
-     * @throws PhaseException
-     */
-    public void buildTransportHandlerChain(Phase phase, ArrayList handlers) throws PhaseException
{
-        try {
-            Class handlerClass = null;
-            Handler handler;
-
-            for (int i = 0; i < handlers.size(); i++) {
-                HandlerDescription description = (HandlerDescription) handlers.get(i);
-
-                handlerClass = Class.forName(description.getClassName(), true,
-                        Thread.currentThread().getContextClassLoader());
-                handler = (Handler) handlerClass.newInstance();
-                handler.init(description);
-                description.setHandler(handler);
-                phase.addHandler(description.getHandler());
+            if (isPhaseExist(phaseName)) {
+                getPhase(phaseName).addHandler(handlerDesc);
+            } else {
+                throw new PhaseException(Messages.getMessage(DeploymentErrorMsgs.INVALID_PHASE,
+                        phaseName, handlerDesc.getName().getLocalPart()));
             }
-        } catch (ClassNotFoundException e) {
-            throw new PhaseException(e);
-        } catch (InstantiationException e) {
-            throw new PhaseException(e);
-        } catch (IllegalAccessException e) {
-            throw new PhaseException(e);
         }
     }
 
@@ -91,7 +73,6 @@
      * this method is used to get the actual phase object given in the phase array list
      *
      * @param phaseName
-     * @return
      */
     private Phase getPhase(String phaseName) {
         for (int i = 0; i < phaseList.size(); i++) {
@@ -109,7 +90,6 @@
      * Method isPhaseExist
      *
      * @param phaseName
-     * @return
      */
     private boolean isPhaseExist(String phaseName) {
         for (int i = 0; i < phaseList.size(); i++) {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java?rev=386280&r1=386279&r2=386280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
Wed Mar 15 23:58:30 2006
@@ -226,6 +226,8 @@
         try {
             ServletContext context = config.getServletContext();
             String repoDir = context.getRealPath("/WEB-INF");
+            //adding weblocation property
+//            setWebLocationProperty(context);
             ConfigurationContext configContext =
                     ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoDir,
null);
             configContext.setProperty(Constants.CONTAINER_MANAGED, Constants.VALUE_TRUE);
@@ -234,6 +236,21 @@
         } catch (Exception e) {
             throw new ServletException(e);
         }
+    }
+
+    /**
+     * To find out the location where web reposurce need to be coiped, when
+     * deployment fine any service aar with web resources.
+     *
+     * @param context
+     */
+    private void setWebLocationProperty(ServletContext context) {
+        String webpath = context.getRealPath("");
+        if (webpath == null || "".equals(webpath)) {
+            return;
+        }
+        File weblocation = new File(webpath);
+        System.setProperty("web.location", weblocation.getAbsolutePath());
     }
 
     protected HashMap getHTTPParameters(HttpServletRequest httpServletRequest) {

Added: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java?rev=386280&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
(added)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/AddingHandlerToEachPhaseTest.java
Wed Mar 15 23:58:30 2006
@@ -0,0 +1,148 @@
+package org.apache.axis2.phaserule;
+
+import org.apache.axis2.AbstractTestCase;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.DispatchPhase;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.engine.Phase;
+import org.apache.axis2.phaseresolver.PhaseHolder;
+
+import java.util.ArrayList;
+/*
+* 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.
+*
+*
+*/
+
+public class AddingHandlerToEachPhaseTest extends AbstractTestCase {
+
+    AddingHandlerToEachPhaseTest phaserul;
+    AxisConfiguration axisSytem;
+
+    public AddingHandlerToEachPhaseTest(String testName) {
+        super(testName);
+    }
+
+    public void testPhaseRules() throws Exception {
+        super.setUp();
+        //TODO fix me
+        phaserul = new AddingHandlerToEachPhaseTest("");
+        axisSytem = new AxisConfiguration();
+        ArrayList inPhase = axisSytem.getGlobalInFlow();
+        Phase transportIN = new Phase("TransportIn");
+        Phase preDispatch = new Phase("PreDispatch");
+        DispatchPhase dispatchPhase = new DispatchPhase();
+//
+        dispatchPhase.setName("Dispatch");
+        inPhase.add(transportIN);
+        inPhase.add(preDispatch);
+        inPhase.add(dispatchPhase);
+
+        HandlerDescription hm = new HandlerDescription();
+        hm.setClassName("org.apache.axis2.handlers.AbstractHandler");
+        Handler h1 = new PhaseRuleHandlers();
+        hm.setHandler(h1);
+        hm.getRules().setPhaseName("*");
+
+        PhaseHolder ph = new PhaseHolder(inPhase);
+        ph.addHandler(hm);
+        boolean found;
+        for (int i = 0; i < inPhase.size(); i++) {
+            found = false;
+            Phase phase = (Phase) inPhase.get(i);
+            ArrayList hnadles = phase.getHandlers();
+            for (int j = 0; j < hnadles.size(); j++) {
+                Handler handler = (Handler) hnadles.get(j);
+                if (h1.equals(handler)) {
+                    found = true;
+                }
+            }
+            if (!found) {
+                fail("Some thing has gone wrong hnadler does not exit in the phase :"
+                        + phase.getPhaseName());
+            }
+        }
+    }
+
+    public void testPhaseRulesWithPhaseFirst() throws Exception {
+        super.setUp();
+        //TODO fix me
+        phaserul = new AddingHandlerToEachPhaseTest("");
+        axisSytem = new AxisConfiguration();
+        ArrayList inPhase = axisSytem.getGlobalInFlow();
+        Phase transportIN = new Phase("TransportIn");
+        Phase preDispatch = new Phase("PreDispatch");
+        DispatchPhase dispatchPhase = new DispatchPhase();
+//
+        dispatchPhase.setName("Dispatch");
+        inPhase.add(transportIN);
+        inPhase.add(preDispatch);
+        inPhase.add(dispatchPhase);
+
+        HandlerDescription hm = new HandlerDescription();
+        hm.setClassName("org.apache.axis2.handlers.AbstractHandler");
+        Handler h1 = new PhaseRuleHandlers();
+        hm.setHandler(h1);
+        hm.getRules().setPhaseName("*");
+        hm.getRules().setPhaseFirst(true);
+
+        PhaseHolder ph = new PhaseHolder(inPhase);
+        ph.addHandler(hm);
+        for (int i = 0; i < inPhase.size(); i++) {
+            Phase phase = (Phase) inPhase.get(i);
+            ArrayList hnadles = phase.getHandlers();
+            Handler handler = (Handler) hnadles.get(0);
+            if (!h1.equals(handler)) {
+                fail("Some thing has gone wrong hnadler does not exit as phase " +
+                        "first handler the phase :"
+                        + phase.getPhaseName());
+            }
+        }
+    }
+
+    public void testPhaseRulesWithAfter() throws Exception {
+        super.setUp();
+        //TODO fix me
+        phaserul = new AddingHandlerToEachPhaseTest("");
+        axisSytem = new AxisConfiguration();
+        ArrayList inPhase = axisSytem.getGlobalInFlow();
+        Phase transportIN = new Phase("TransportIn");
+        Phase preDispatch = new Phase("PreDispatch");
+        DispatchPhase dispatchPhase = new DispatchPhase();
+//
+        dispatchPhase.setName("Dispatch");
+        inPhase.add(transportIN);
+        inPhase.add(preDispatch);
+        inPhase.add(dispatchPhase);
+
+        HandlerDescription hm = new HandlerDescription();
+        hm.setClassName("org.apache.axis2.handlers.AbstractHandler");
+        Handler h1 = new PhaseRuleHandlers();
+        hm.setHandler(h1);
+        hm.getRules().setPhaseName("*");
+        hm.getRules().setPhaseFirst(true);
+        hm.getRules().setAfter("nothing");
+
+        PhaseHolder ph = new PhaseHolder(inPhase);
+        ph.addHandler(hm);
+        for (int i = 0; i < inPhase.size(); i++) {
+            Phase phase = (Phase) inPhase.get(i);
+            ArrayList hnadles = phase.getHandlers();
+            Handler handler = (Handler) hnadles.get(0);
+            assertEquals("",handler.getHandlerDesc().getRules().getAfter());
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/PhaseRuleTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/PhaseRuleTest.java?rev=386280&r1=386279&r2=386280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/PhaseRuleTest.java
(original)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/phaserule/PhaseRuleTest.java
Wed Mar 15 23:58:30 2006
@@ -86,11 +86,5 @@
         rule3.setPhaseName("Dispatch");
         hm3.setRules(rule3);
         ph.addHandler(hm3);
-
-        /*ArrayList oh = ph.getOrderHandler();
-        for (int i = 0; i < oh.size(); i++) {
-            HandlerDescription metadata = (HandlerDescription) oh.get(i);
-            System.out.println("Name:" + metadata.getName().getLocalPart());
-        }*/
     }
 }



Mime
View raw message