geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r676666 - in /geronimo/server/trunk: assemblies/geronimo-jetty6-javaee5/ assemblies/geronimo-tomcat6-javaee5/ plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/ plugins/jaxws/geronimo-jaxws-builder/src/mai...
Date Mon, 14 Jul 2008 18:04:56 GMT
Author: gawor
Date: Mon Jul 14 11:04:55 2008
New Revision: 676666

URL: http://svn.apache.org/viewvc?rev=676666&view=rev
Log:
register wsgen/wsimport commands with gshell - kinda hacky but it works (GERONIMO-3665)

Added:
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/GShellCommandRegistration.java
  (with props)
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/resources/
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/resources/gsh-wsgen.properties
  (with props)
Modified:
    geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml
    geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml

Modified: geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml?rev=676666&r1=676665&r2=676666&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml Mon Jul 14 11:04:55 2008
@@ -649,6 +649,12 @@
                                 <copy todir="${project.build.directory}/assembly">
                                     <fileset dir="${project.build.directory}/geronimo-framework-${version}"/>
                                 </copy>
+                                <java classname="org.apache.geronimo.jaxws.builder.GShellCommandRegistration"

+                                      fork="yes" failonerror="true">
+                                   <classpath refid="maven.runtime.classpath"/>
+                                   <arg value="${project.build.directory}/assembly"/>
+                                   <arg value="gsh-wsgen.properties"/>
+                                </java>
                             </tasks>
                         </configuration>
                     </execution>

Modified: geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml?rev=676666&r1=676665&r2=676666&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml Mon Jul 14 11:04:55
2008
@@ -621,6 +621,12 @@
                                 <copy todir="${project.build.directory}/assembly">
                                     <fileset dir="${project.build.directory}/geronimo-framework-${version}"/>
                                 </copy>
+                                <java classname="org.apache.geronimo.jaxws.builder.GShellCommandRegistration"

+                                      fork="yes" failonerror="true">
+                                   <classpath refid="maven.runtime.classpath"/>
+                                   <arg value="${project.build.directory}/assembly"/>
+                                   <arg value="gsh-wsgen.properties"/>
+                                </java>
                             </tasks>
                         </configuration>
                     </execution>

Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/GShellCommandRegistration.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/GShellCommandRegistration.java?rev=676666&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/GShellCommandRegistration.java
(added)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/GShellCommandRegistration.java
Mon Jul 14 11:04:55 2008
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.jaxws.builder;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+public class GShellCommandRegistration {
+    
+    private static String INDENT = "    ";
+           
+    private static boolean updateClassworlds(File classworldsFile, String classworlsTest,
String classworlds) throws Exception {
+        boolean updated = checkClassworlds(classworldsFile, classworlsTest);
+        if (updated) {
+            return false;
+        }
+                             
+        File tmpFile = new File(classworldsFile.getAbsolutePath() + ".tmp");
+        PrintWriter writer = new PrintWriter(new FileWriter(tmpFile));
+        BufferedReader reader = new BufferedReader(new FileReader(classworldsFile));
+        boolean inGShellSection = false;
+        String line = null;     
+        while( (line = reader.readLine()) != null) {
+            writer.println(line);
+                
+            if (line.startsWith("[gshell]")) {                    
+                inGShellSection = true;     
+            } else if (line.startsWith("[")) {
+                inGShellSection = false;
+            } else if (inGShellSection) {
+                if (!line.startsWith(INDENT)) {
+                    break;
+                }
+            }
+        }
+            
+        if (inGShellSection) {
+            writer.println(INDENT + classworlds);
+        }
+            
+        while( (line = reader.readLine()) != null) {
+            writer.println(line);
+        }
+            
+        reader.close();
+        writer.close();
+            
+        switchFile(tmpFile, classworldsFile);
+        
+        return true;
+    }    
+    
+    private static boolean checkClassworlds(File classworldsFile, String classworlsTest)
throws Exception {
+        BufferedReader reader = new BufferedReader(new FileReader(classworldsFile));
+        String line = null;
+        boolean matches = false;
+        while( (line = reader.readLine()) != null) {
+            if (line.matches(classworlsTest)) {
+                matches = true;
+                break;
+            }            
+        }
+        reader.close();
+        return matches;
+    }
+    
+    private static boolean updateLayout(File layoutFile, String layoutTest, String layout)
throws Exception {  
+        
+        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+        Document layoutDocument = domFactory.newDocumentBuilder().parse(layoutFile);
+        
+        XPathFactory xpathFactory = XPathFactory.newInstance();
+        XPath xPath = xpathFactory.newXPath();
+        
+        Boolean updated = (Boolean)xPath.evaluate(layoutTest, layoutDocument, XPathConstants.BOOLEAN);
+        
+        if (updated.booleanValue()) {
+            return false;
+        }
+                            
+        Document doc = domFactory.newDocumentBuilder().parse(new InputSource(new StringReader(layout)));
+            
+        Element layoutElement = layoutDocument.getDocumentElement();
+        NodeList nodes = layoutElement.getElementsByTagName("nodes");
+        Node n = layoutDocument.importNode(doc.getDocumentElement(), true);
+        nodes.item(0).appendChild(n);
+            
+        TransformerFactory tFactory = TransformerFactory.newInstance();
+        Transformer transformer = tFactory.newTransformer();
+ 
+        DOMSource source = new DOMSource(layoutDocument);
+        File tmpFile = new File(layoutFile.getAbsolutePath() + ".tmp");
+        FileOutputStream out = new FileOutputStream(tmpFile);
+        StreamResult result = new StreamResult(out);
+        transformer.transform(source, result);                    
+        out.close();
+            
+        switchFile(tmpFile, layoutFile);
+            
+        return true;        
+    }
+        
+    private static void switchFile(File tmpFile, File realFile) {
+        realFile.delete();
+        if (!tmpFile.renameTo(realFile)) {
+            throw new RuntimeException("Failed to rename " + tmpFile + " to " + realFile);
+        }
+    }
+    
+    public static void main(String [] args) throws Exception {
+        if (args.length != 2) {
+            throw new Exception("Syntax: GShellCommandRegistration <geronimo_home>
<properties file>");
+        }
+        String baseDir = args[0];
+        String propsFile = args[1];
+        
+        ClassLoader loader = GShellCommandRegistration.class.getClassLoader();
+        InputStream in = loader.getResourceAsStream(propsFile);
+        
+        if (in == null) {
+            throw new Exception("Failed to load properties file: " + propsFile);
+        }
+                
+        Properties p = new Properties();
+        p.load(in);
+                       
+        // update layout.xml
+        String layoutXPathTest = p.getProperty("layoutXPathTest");
+        String layoutEntry = p.getProperty("layoutEntry");
+        
+        if (layoutXPathTest != null && layoutEntry != null) {
+            File layoutFile = new File(baseDir, "etc/layout.xml");
+            if (updateLayout(layoutFile, layoutXPathTest, layoutEntry)) {
+                System.out.println("Registered commands in layout.xml");
+            }
+        }
+        
+        // update gsh-classworlds.conf
+        String classworldsRegExTest = p.getProperty("classworldsRegExTest");
+        String classworldsEntry = p.getProperty("classworldsEntry");
+        if (classworldsRegExTest != null && classworldsEntry != null) {
+            File classworldsFile = new File(baseDir, "etc/gsh-classworlds.conf");       
    
+            if (updateClassworlds(classworldsFile, classworldsRegExTest, classworldsEntry))
{
+                System.out.println("Updated gsh-classworlds.conf");
+            }
+        }
+               
+    }
+     
+}

Propchange: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/GShellCommandRegistration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/resources/gsh-wsgen.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/resources/gsh-wsgen.properties?rev=676666&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/resources/gsh-wsgen.properties
(added)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/resources/gsh-wsgen.properties
Mon Jul 14 11:04:55 2008
@@ -0,0 +1,17 @@
+classworldsRegExTest = .*geronimo-jaxws-builder.*
+classworldsEntry = load ${gshell.home}/lib/geronimo-jaxws-builder-*.jar
+layoutXPathTest = //layout/nodes/group/name[contains(.,'jaxws')]
+layoutEntry = \n          <group>\n            \
+            <name>jaxws</name>\n\n            \
+            <nodes>\n                \
+                <command>\n                    \
+                    <name>wsgen</name>\n                    \
+                    <id>geronimo-jaxws-builder:wsgen</id>\n                \
+                </command>\n\n                \
+                <command>\n                    \
+                    <name>wsimport</name>\n                    \
+                    <id>geronimo-jaxws-builder:wsimport</id>\n              
 \
+                </command>\n            \
+            </nodes>\n        \
+        </group>\n          \n
+

Propchange: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/resources/gsh-wsgen.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message