You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ve...@apache.org on 2009/02/28 01:25:27 UTC

svn commit: r748761 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java

Author: veithen
Date: Sat Feb 28 00:25:27 2009
New Revision: 748761

URL: http://svn.apache.org/viewvc?rev=748761&view=rev
Log:
Fixed AXIS2-4258: Support "wsjar:" URLs when loading modules from classpath. Also avoid the overhead of opening a URLConnection.

Modified:
    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/RepositoryListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java?rev=748761&r1=748760&r2=748761&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 Sat Feb 28 00:25:27 2009
@@ -119,17 +119,31 @@
             while (moduleURLs.hasMoreElements()) {
                 try {
                     URL url = (URL)moduleURLs.nextElement();
-                    String fileName = url.toString();
-                    if (fileName.startsWith("jar")) {
-                        url = ((java.net.JarURLConnection)url.openConnection()).getJarFileURL();
-                        fileName = url.toString();
-                    } else if (fileName.startsWith("file")) {
-                        fileName =
-                                fileName.substring(0, fileName.lastIndexOf("/META-INF/module.xml"));
-                    } else continue;
-
-                    log.debug("Deploying module from classpath at '" + fileName + "'");
-                    File f = new File(new URI(fileName));
+                    URI moduleURI;
+                    if (url.getProtocol().equals("file")) {
+                        String urlString = url.toString();
+                        moduleURI = new URI(urlString.substring(0,
+                                urlString.lastIndexOf("/META-INF/module.xml")));
+                    } else {
+                        // Check if the URL refers to an archive (such as
+                        // jar:file:/dir/some.jar!/META-INF/module.xml) and extract the
+                        // URL of the archive. In general the protocol will be "jar", but
+                        // some containers may use other protocols, e.g. WebSphere uses
+                        // "wsjar" (AXIS2-4258).
+                        String path = url.getPath();
+                        int idx = path.lastIndexOf("!/");
+                        if (idx != -1 && path.substring(idx+2).equals("META-INF/module.xml")) {
+                            moduleURI = new URI(path.substring(0, idx));
+                            if (!moduleURI.getScheme().equals("file")) {
+                                continue;
+                            }
+                        } else {
+                            continue;
+                        }
+                    }
+    
+                    log.debug("Deploying module from classpath at '" + moduleURI + "'");
+                    File f = new File(moduleURI);
                     addFileToDeploy(f, deployer, WSInfo.TYPE_MODULE);
 
                 } catch (URISyntaxException e) {