axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r709529 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment: AxisConfigBuilder.java DeploymentEngine.java RepositoryListener.java
Date Fri, 31 Oct 2008 18:40:36 GMT
Author: gawor
Date: Fri Oct 31 11:40:35 2008
New Revision: 709529

URL: http://svn.apache.org/viewvc?rev=709529&view=rev
Log:
partial fix for the multiple deployer for the same extension problem (AXIS2-4101)

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=709529&r1=709528&r2=709529&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
Fri Oct 31 11:40:35 2008
@@ -67,6 +67,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 public class AxisConfigBuilder extends DescriptionBuilder {
 
@@ -354,19 +355,20 @@
     }
     
     private void processDeployers(Iterator deployerItr) {
-        HashMap directoryToExtensionMappingMap = new HashMap();
         HashMap extensionToDeployerMappingMap = new HashMap();
+        Map<String, Map<String, Deployer>> deployers = new HashMap<String,
Map<String, Deployer>>();
         while (deployerItr.hasNext()) {
             OMElement element = (OMElement) deployerItr.next();
             String directory = element.getAttributeValue(new QName(DIRECTORY));
             if (directory == null) {
                 log.error("Deployer missing 'directory' attribute : " + element.toString());
+                continue;
             }
 
             String extension = element.getAttributeValue(new QName(EXTENSION));
             if (extension == null) {
                 log.error("Deployer missing 'extension' attribute : " + element.toString());
-                return;
+                continue;
             }
 
             // A leading dot is redundant, so strip it.  So we allow either ".foo" or "foo",
either
@@ -388,19 +390,18 @@
             }
             deployer.setDirectory(directory);
             deployer.setExtension(extension);
-            if (directory != null) {
-                ArrayList extensionList = (ArrayList) directoryToExtensionMappingMap.get(directory);
-                if (extensionList == null) {
-                    extensionList = new ArrayList();
-                }
-                extensionList.add(extension);
-                directoryToExtensionMappingMap.put(directory, extensionList);
+            
+            Map<String, Deployer> extensionMap = deployers.get(directory);
+            if (extensionMap == null) {
+                extensionMap = new HashMap<String, Deployer>();
+                deployers.put(directory, extensionMap);
             }
+            extensionMap.put(extension, deployer);
             extensionToDeployerMappingMap.put(extension, deployer);
         }
         if (deploymentEngine != null) {
-            deploymentEngine.setDirectoryToExtensionMappingMap(directoryToExtensionMappingMap);
             deploymentEngine.setExtensionToDeployerMappingMap(extensionToDeployerMappingMap);
+            deploymentEngine.setDeployers(deployers);
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=709529&r1=709528&r2=709529&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
Fri Oct 31 11:40:35 2008
@@ -121,12 +121,11 @@
     //To deploy modules (both mar and expanded)
     protected ModuleDeployer moduleDeployer;
 
-    //To keep the mapping that which directory will contain which type ,
-    // for exmaple directory services will contains .aar
-    private HashMap directoryToExtensionMappingMap = new HashMap();
     //to keep map of which deployer can process which file extension ,
     // for example ServiceDeployer will process .aar file
     private HashMap extensionToDeployerMappingMap = new HashMap();
+    
+    private Map<String, Map<String, Deployer>> deployerMap = new HashMap<String,
Map<String, Deployer>>();
 
     public void loadServices() {
         repoListener.checkServices();
@@ -176,62 +175,61 @@
     }
 
     private void loadCustomServices(URL repoURL){
-        Map directoryToExtensionMappingMap = getDirectoryToExtensionMappingMap();
-        if (directoryToExtensionMappingMap.size() > 0) {
-            Iterator keys = directoryToExtensionMappingMap.keySet().iterator();
-            while (keys.hasNext()) {
-                try {
-                    String directory = (String)keys.next();
-                    ArrayList list = (ArrayList)directoryToExtensionMappingMap.get(directory);
-                    String listName;
-                    if (!directory.endsWith("/")) {
-                        listName = directory + ".list";
-                        directory += "/";
-                    } else {
-                        listName = directory.replaceAll("/","") + ".list";
-                    }
-                    String repoPath = repoURL.getPath();
-                    if (!repoPath.endsWith("/")) {
-                        repoPath += "/";
-                        repoURL = new URL(repoURL.getProtocol() + "://" + repoPath);
+        for (Map.Entry<String, Map<String, Deployer>> entry : getDeployers().entrySet())
{
+            String directory = entry.getKey();
+            Map<String, Deployer> extensionMap = entry.getValue();
+            try {
+                String listName;
+                if (!directory.endsWith("/")) {
+                    listName = directory + ".list";
+                    directory += "/";
+                } else {
+                    listName = directory.replaceAll("/","") + ".list";
+                }
+                String repoPath = repoURL.getPath();
+                if (!repoPath.endsWith("/")) {
+                    repoPath += "/";
+                    repoURL = new URL(repoURL.getProtocol() + "://" + repoPath);
+                }
+
+                URL servicesDir = new URL(repoURL, directory);
+                URL filelisturl = new URL(servicesDir, listName);
+                ArrayList files = getFileList(filelisturl);
+                for (int i = 0; i < files.size(); i++) {
+                    String fileName = (String) files.get(i);
+                    String extension = getExtension(fileName);
+                    Deployer deployer = extensionMap.get(extension);
+                    if (deployer == null) {
+                        continue;
                     }
+                    URL servicesURL = new URL(servicesDir, fileName);
 
-                    URL servicesDir = new URL(repoURL, directory);
-                    URL filelisturl = new URL(servicesDir, listName);
-                    ArrayList files = getFileList(filelisturl);
-                    for (int i = 0; i < files.size(); i++) {
-                        String fileName = (String) files.get(i);
-                        Deployer deployer = getDeployerForExtension(getExtension(fileName));
-                        URL servicesURL = new URL(servicesDir, fileName);
-
-                        // We are calling reflection code here , to avoid changes to the
interface
-                        Class classToLoad = deployer.getClass();
-                        // We can not call classToLoad.getDeclaredMethed() , since there
-                        //  can be insatnce where mutiple services extends using one class
-                        // just for init and other reflection methods
-                        Method method =
-                                null;
+                    // We are calling reflection code here , to avoid changes to the interface
+                    Class classToLoad = deployer.getClass();
+                    // We can not call classToLoad.getDeclaredMethed() , since there
+                    //  can be insatnce where mutiple services extends using one class
+                    // just for init and other reflection methods
+                    Method method = null;
+                    try {
+                        method = classToLoad.getMethod("deployFromURL", new Class[]{URL.class});
+                    } catch (Exception e) {
+                        //We do not need to inform this to user , since this something
+                        // Axis2 is checking to support Session. So if the method is
+                        // not there we should ignore that
+                    }
+                    if (method != null) {
                         try {
-                            method = classToLoad.getMethod("deployFromURL", new Class[]{URL.class});
+                            method.invoke(deployer, new Object[]{servicesURL});
                         } catch (Exception e) {
-                            //We do not need to inform this to user , since this something
-                            // Axis2 is checking to support Session. So if the method is
-                            // not there we should ignore that
-                        }
-                        if (method != null) {
-                            try {
-                                method.invoke(deployer, new Object[]{servicesURL});
-                            } catch (Exception e) {
-                                log.info("Exception trying to call " + "deployFromURL for
the deployer" + deployer.getClass() , e);
-                            }
+                            log.info("Exception trying to call " + "deployFromURL for the
deployer" + deployer.getClass() , e);
                         }
                     }
-
-                } catch (MalformedURLException e) {
-                    //I am just ignoring the error at the moment , but need to think how
to handle this
                 }
 
+            } catch (MalformedURLException e) {
+                //I am just ignoring the error at the moment , but need to think how to handle
this
             }
+
         }
     }
 
@@ -989,14 +987,14 @@
 
     private void initializeDeployers(ConfigurationContext configContext) {
         serviceDeployer = new ServiceDeployer();
-        serviceDeployer.init(configContext);
-        Iterator deployers = extensionToDeployerMappingMap.values().iterator();
-        while (deployers.hasNext()) {
-            Deployer deployer = (Deployer) deployers.next();
-            deployer.init(configContext);
+        serviceDeployer.init(configContext);        
+        for (Map<String, Deployer> extensionMap : deployerMap.values()) {
+            for (Deployer deployer : extensionMap.values()) {
+                deployer.init(configContext);
+            }
         }
     }
-
+    
     /**
      * Builds an AxisModule for a given module archive file. This does not
      * called the init method since there is no reference to configuration context
@@ -1170,16 +1168,15 @@
     public void setExtensionToDeployerMappingMap(HashMap extensionToDeployerMappingMap) {
         this.extensionToDeployerMappingMap = extensionToDeployerMappingMap;
     }
-
-    public void setDirectoryToExtensionMappingMap(HashMap directoryToExtensionMappingMap)
{
-        this.directoryToExtensionMappingMap = directoryToExtensionMappingMap;
+    
+    public void setDeployers(Map<String, Map<String, Deployer>> deployerMap)
{
+        this.deployerMap = deployerMap;
+    }    
+    
+    public Map<String, Map<String, Deployer>> getDeployers() {
+        return this.deployerMap;
     }
-
-
-    public HashMap getDirectoryToExtensionMappingMap() {
-        return directoryToExtensionMappingMap;
-    }
-
+    
     public RepositoryListener getRepoListener() {
         return repoListener;
     }
@@ -1192,7 +1189,12 @@
     public ModuleDeployer getModuleDeployer() {
         return moduleDeployer;
     }
-
+    
+    public Deployer getDeployer(String directory, String extension) {
+        Map<String, Deployer> extensionMap = deployerMap.get(directory);
+        return (extensionMap != null) ? extensionMap.get(extension) : null;
+    }
+    
     public Deployer getDeployerForExtension(String extension) {
         return (Deployer) extensionToDeployerMappingMap.get(extension);
     }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java?rev=709529&r1=709528&r2=709529&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java
Fri Oct 31 11:40:35 2008
@@ -240,17 +240,11 @@
     //This will load the files from the directories
     // specified by axis2.xml (As <deployer>)
     private void loadOtherDirectories() {
-        Map directoryToExtensionMappingMap = deploymentEngine.getDirectoryToExtensionMappingMap();
-        if (directoryToExtensionMappingMap.size() > 0) {
-            Iterator keys = directoryToExtensionMappingMap.keySet().iterator();
-            while (keys.hasNext()) {
-                String s = (String)keys.next();
-                ArrayList list = (ArrayList)directoryToExtensionMappingMap.get(s);
-                for (int i = 0; i < list.size(); i++) {
-                    String extension = (String)list.get(i);
-                    findFileForGivenDirectory(s, extension);
-                }
-
+        for (Map.Entry<String, Map<String, Deployer>> entry : deploymentEngine.getDeployers().entrySet())
{
+            String directory = entry.getKey();
+            Map<String, Deployer> extensionMap = entry.getValue();
+            for (String extension : extensionMap.keySet()) {
+                findFileForGivenDirectory(directory, extension);
             }
         }
     }
@@ -274,7 +268,7 @@
                         if (!file.isDirectory() && extension
                                 .equals(DeploymentFileData.getFileExtension(file.getName())))
{
                             addFileToDeploy(file,
-                                            deploymentEngine.getDeployerForExtension(extension),
+                                            deploymentEngine.getDeployer(dir, extension),
                                             WSInfo.TYPE_CUSTOM);
                         }
                     }



Mime
View raw message