You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2011/02/22 10:00:25 UTC

svn commit: r1073261 - in /geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main: java/org/apache/geronimo/jaxws/sun/tools/ resources/ resources/OSGI-INF/ resources/OSGI-INF/blueprint/

Author: xuhaihong
Date: Tue Feb 22 09:00:24 2011
New Revision: 1073261

URL: http://svn.apache.org/viewvc?rev=1073261&view=rev
Log:
Convert GShell based web service commands to gogo command style

Added:
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/OSGI-INF/
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/OSGI-INF/blueprint/
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/OSGI-INF/blueprint/shell-jaxws-sun-tools.xml
Modified:
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsgenCommand.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsimportCommand.java

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java?rev=1073261&r1=1073260&r2=1073261&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java Tue Feb 22 09:00:24 2011
@@ -43,8 +43,8 @@ public class JAXWSTools {
     {
         { "org.apache.geronimo.specs", "geronimo-jaxws_2.2_spec" },
         { "org.apache.geronimo.specs", "geronimo-saaj_1.3_spec" },
-        { "org.apache.geronimo.specs", "geronimo-jaxb_2.1_spec" },
-        { "com.sun.xml.bind", "jaxb-impl" },
+        { "org.apache.geronimo.specs", "geronimo-jaxb_2.2_spec" },
+        { "org.apache.geronimo.bundles", "jaxb-impl" },
         { "com.sun.xml.bind", "jaxb-xjc" },
         { "com.sun.xml.ws",   "jaxws-tools" },
         { "com.sun.xml.ws",   "jaxws-rt" },
@@ -52,22 +52,22 @@ public class JAXWSTools {
         { "org.jvnet.staxex",             "stax-ex" },
         { "org.apache.geronimo.javamail", "geronimo-javamail_1.4_mail"},
         { "org.apache.geronimo.specs",    "geronimo-activation_1.1_spec"},
-        { "org.apache.geronimo.specs",    "geronimo-annotation_1.0_spec"},
+        { "org.apache.geronimo.specs",    "geronimo-annotation_1.1_spec"},
         { "org.apache.geronimo.specs",    "geronimo-ws-metadata_2.0_spec"},
         { "org.apache.geronimo.specs",    "geronimo-ejb_3.1_spec"},
-        { "org.apache.geronimo.specs",    "geronimo-interceptor_3.0_spec"},
-        { "org.apache.geronimo.specs",    "geronimo-stax-api_1.0_spec"},
+        { "org.apache.geronimo.specs",    "geronimo-interceptor_1.1_spec"},
+        { "org.apache.geronimo.specs",    "geronimo-stax-api_1.2_spec"},
         { "org.apache.geronimo.specs",    "geronimo-jpa_2.0_spec"},
         { "org.apache.geronimo.specs",    "geronimo-j2ee-connector_1.6_spec"},
         { "org.apache.geronimo.specs",    "geronimo-jms_1.1_spec"},
         { "org.apache.geronimo.specs",    "geronimo-jta_1.1_spec"},
         { "org.apache.geronimo.specs",    "geronimo-j2ee-management_1.1_spec"},
-        { "org.codehaus.woodstox",        "wstx-asl" },
+        { "org.apache.geronimo.bundles",        "woodstox" },
         { "org.apache.geronimo.modules",  "geronimo-webservices" },
     };
 
     private final static Artifact SUN_SAAJ_IMPL_ARTIFACT = new Artifact("com.sun.xml.messaging.saaj","saaj-impl", (Version)null, "jar");
-    private final static Artifact AXIS2_SAAJ_IMPL_ARTIFACT = new Artifact("org.apache.axis2","axis2-saaj", (Version)null, "jar");
+    private final static Artifact AXIS2_SAAJ_IMPL_ARTIFACT = new Artifact("org.apache.geronimo.bundles","axis2", (Version)null, "jar");
     private final static String TOOLS = "tools.jar";
 
     private Artifact saajImpl;
@@ -144,13 +144,13 @@ public class JAXWSTools {
         for (Repository arepository : repositories) {
             if (arepository instanceof ListableRepository) {
                 ListableRepository repository = (ListableRepository) arepository;
-                SortedSet artifactSet = repository.list(artifactQuery);
+                SortedSet<Artifact> artifactSet = repository.list(artifactQuery);
                 // if we have exactly one artifact found
                 if (artifactSet.size() == 1) {
-                    file = repository.getLocation((Artifact) artifactSet.first());
+                    file = repository.getLocation(artifactSet.first());
                     return file.getAbsoluteFile();
                 } else if (artifactSet.size() > 1) {// if we have more than 1 artifacts found use the latest one.
-                    file = repository.getLocation((Artifact) artifactSet.last());
+                    file = repository.getLocation(artifactSet.last());
                     return file.getAbsoluteFile();
                 }
             }
@@ -194,7 +194,7 @@ public class JAXWSTools {
 
     private boolean invoke(String toolName, URL[] jars, OutputStream os, String[] arguments) throws Exception {
         TemporaryClassLoader loader = new TemporaryClassLoader(jars, ClassLoader.getSystemClassLoader());
-        if (this.overrideContextClassLoader) {
+        if (overrideContextClassLoader) {
             ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
             Thread.currentThread().setContextClassLoader(loader);
             try {
@@ -209,7 +209,7 @@ public class JAXWSTools {
 
     private boolean invoke(String toolName, ClassLoader loader, OutputStream os, String[] arguments) throws Exception {
         LOG.debug("Invoking " + toolName);
-        Class clazz = loader.loadClass("com.sun.tools.ws.spi.WSToolsObjectFactory");
+        Class<?> clazz = loader.loadClass("com.sun.tools.ws.spi.WSToolsObjectFactory");
         Method method = clazz.getMethod("newInstance");
         Object factory = method.invoke(null);
         Method method2 = clazz.getMethod(toolName, OutputStream.class, String[].class);

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsgenCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsgenCommand.java?rev=1073261&r1=1073260&r2=1073261&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsgenCommand.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsgenCommand.java Tue Feb 22 09:00:24 2011
@@ -19,45 +19,25 @@
 
 package org.apache.geronimo.jaxws.sun.tools;
 
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.command.CommandSupport;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.annotation.Requirement;
-import org.apache.geronimo.gshell.shell.ShellInfo;
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
 
 /**
- * GShell command for wsgen tool.
- * 
+ * OSGi command for wsgen tool.
+ *
  * @version $Rev: 595889 $ $Date: 2007-11-16 20:13:06 -0500 (Fri, 16 Nov 2007) $
  */
-@CommandComponent(id="geronimo-jaxws-sun-tools:wsgen", description="Generate JAX-WS artifacts from class")
-public class WsgenCommand extends CommandSupport {
-    
-    @Requirement
-    ShellInfo shellInfo;
-             
-    @Override
-    public Object execute(final CommandContext context, final Object... args) throws Exception {
-        init(context);
-        
-        String[] arguments = toString(args); 
-        return JAXWSToolsCLI.run(JAXWSToolsCLI.Command.WSGEN, 
-                                 shellInfo.getHomeDir().getAbsolutePath(),
-                                 arguments, 
-                                 System.out); // should use io.out instead of System.out?
-    }
-    
+@Command(scope = "jaxws-sun-tools", name = "wsgen", description = "Generate JAX-WS artifacts from class")
+public class WsgenCommand extends OsgiCommandSupport {
+
+    @Argument(index = 0, name = "arguments", description = "The list arguments for wsgen command", required = true, multiValued = true)
+    private List<String> arguments;
+
     @Override
-    protected Object doExecute() throws Exception { 
-        return null;
-    }
-        
-    private static String[] toString(Object [] args) {
-        String [] a = new String[args.length];
-        for (int i=0; i<a.length; i++) {
-            a[i] = args[i].toString();
-        }
-        return a;
+    protected Object doExecute() throws Exception {
+        return JAXWSToolsCLI.run(JAXWSToolsCLI.Command.WSGEN, System.getProperty("org.apache.geronimo.home.dir"), arguments.toArray(new String[arguments.size()]), System.out); // should use io.out instead of System.out?
     }
-        
 }

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsimportCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsimportCommand.java?rev=1073261&r1=1073260&r2=1073261&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsimportCommand.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsimportCommand.java Tue Feb 22 09:00:24 2011
@@ -19,45 +19,27 @@
 
 package org.apache.geronimo.jaxws.sun.tools;
 
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.command.CommandSupport;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.annotation.Requirement;
-import org.apache.geronimo.gshell.shell.ShellInfo;
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
 
 /**
- * GShell command for wsimport tool.
- *  
+ * OSGi command for wsimport tool.
+ *
  * @version $Rev: 595889 $ $Date: 2007-11-16 20:13:06 -0500 (Fri, 16 Nov 2007) $
  */
-@CommandComponent(id="geronimo-jaxws-sun-tools:wsimport", description="Generate JAX-WS artifacts from WSDL")
-public class WsimportCommand extends CommandSupport {
-    
-    @Requirement
-    ShellInfo shellInfo;
-             
-    @Override
-    public Object execute(final CommandContext context, final Object... args) throws Exception {
-        init(context);
-        
-        String[] arguments = toString(args); 
-        return JAXWSToolsCLI.run(JAXWSToolsCLI.Command.WSIMPORT, 
-                                 shellInfo.getHomeDir().getAbsolutePath(),
-                                 arguments, 
-                                 System.out); // should use io.out instead of System.out?
-    }
-    
+@Command(scope = "jaxws-sun-tools", name = "wsimport", description = "Generate JAX-WS artifacts from WSDL")
+public class WsimportCommand extends OsgiCommandSupport {
+
+    @Argument(index = 0, name = "arguments", description = "The list arguments for wsimport command", required = true, multiValued = true)
+    private List<String> arguments;
+
     @Override
-    protected Object doExecute() throws Exception { 
-        return null;
-    }
-        
-    private static String[] toString(Object [] args) {
-        String [] a = new String[args.length];
-        for (int i=0; i<a.length; i++) {
-            a[i] = args[i].toString();
-        }
-        return a;
+    protected Object doExecute() throws Exception {
+        //TODO  should use io.out instead of System.out?
+        return JAXWSToolsCLI.run(JAXWSToolsCLI.Command.WSIMPORT, System.getProperty("org.apache.geronimo.home.dir"), arguments.toArray(new String[arguments.size()]), System.out);
     }
-        
+
 }

Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/OSGI-INF/blueprint/shell-jaxws-sun-tools.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/OSGI-INF/blueprint/shell-jaxws-sun-tools.xml?rev=1073261&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/OSGI-INF/blueprint/shell-jaxws-sun-tools.xml (added)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/resources/OSGI-INF/blueprint/shell-jaxws-sun-tools.xml Tue Feb 22 09:00:24 2011
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           default-activation="lazy">
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+        <command name=jaxws-sun-tools/wsgen>
+            <action class="org.apache.geronimo.jaxws.sun.tools.WsgenCommand"></action>
+        </command>
+        <command name="jaxws-sun-tools/wsimport">
+            <action class="org.apache.geronimo.jaxws.sun.tools.WsimportCommand"></action>
+        </command>
+    </command-bundle>
+
+</blueprint>