You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by th...@apache.org on 2006/10/07 15:26:21 UTC

svn commit: r453901 - in /webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool: core/ util/

Author: thilina
Date: Sat Oct  7 06:26:21 2006
New Revision: 453901

URL: http://svn.apache.org/viewvc?view=rev&rev=453901
Log:
Eclipse pluging- Bits which I missed from the patch...

Added:
    webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/
    webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java
    webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java
    webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java
    webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ServiceFileCreator.java
    webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java
    webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java

Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java?view=auto&rev=453901
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java (added)
+++ webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java Sat Oct  7 06:26:21 2006
@@ -0,0 +1,53 @@
+package org.apache.axis2.tool.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+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 ClassFileHandler {
+
+
+   
+/**
+ * 
+ * @param classFileName
+ * @param location
+ * @return
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+    public ArrayList getMethodNamesFromClass(String classFileName,String location) throws IOException, ClassNotFoundException{
+        ArrayList returnList = new ArrayList();
+        File fileEndpoint = new File(location);
+        if (!fileEndpoint.exists())
+            throw new IOException("the location is invalid");
+        URL[] urlList = {fileEndpoint.toURL()};
+        URLClassLoader clazzLoader = new URLClassLoader(urlList);
+        Class clazz = clazzLoader.loadClass(classFileName);
+        Method[] methods = clazz.getDeclaredMethods();
+
+        for (int i = 0; i < methods.length; i++) {
+            returnList.add(methods[i].getName());
+
+        }
+        return returnList;
+    }
+
+}

Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java?view=auto&rev=453901
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java (added)
+++ webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java Sat Oct  7 06:26:21 2006
@@ -0,0 +1,56 @@
+package org.apache.axis2.tool.core;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Copy;
+import org.apache.tools.ant.types.FileSet;
+
+import java.io.File;
+
+/*
+ * 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 FileCopier extends Copy{
+    public FileCopier() {
+        this.setProject(new Project());
+        this.getProject().init();
+        this.setTaskType("copy");
+        this.setTaskName("copy-files");
+        this.setOwningTarget(new org.apache.tools.ant.Target());
+    }
+
+    public void copyFiles(File sourceFile,File destinationDirectory,String filter){
+
+        this.filesets.clear();
+
+        if (sourceFile.isFile())
+            this.setFile(sourceFile);
+        else {
+            FileSet fileset = new FileSet();
+            fileset.setDir(sourceFile);
+            if (filter!=null){
+                if (filter.matches("\\.\\w*")){
+                    fileset.setIncludes("*/**/*"+filter); 
+                }
+            }
+            
+            this.addFileset(fileset);
+        }
+        this.setTodir(destinationDirectory);
+        this.perform();
+    }
+
+
+}

Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java?view=auto&rev=453901
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java (added)
+++ webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java Sat Oct  7 06:26:21 2006
@@ -0,0 +1,55 @@
+package org.apache.axis2.tool.core;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Jar;
+
+import java.io.File;
+import java.io.IOException;
+
+/*
+ * 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 JarFileWriter extends Jar{
+
+
+    public JarFileWriter() {
+        this.setProject(new Project());
+        this.getProject().init();
+        this.setTaskType("jar");
+        this.setTaskName("jar");
+        this.setOwningTarget(new org.apache.tools.ant.Target());
+    }
+
+    public void writeJarFile(File outputFolder,String outputFileName,File inputFileFolder) throws IOException,Exception {
+
+        if (!outputFolder.exists()){
+            outputFolder.mkdir(); //create the output path
+        }else{
+            if (!outputFolder.isDirectory())
+                return;
+        }
+
+        File targetFile = new File(outputFolder,outputFileName);
+        this.setBasedir(inputFileFolder);
+        this.setDestFile(targetFile);
+
+        //run the task
+        this.perform();
+
+
+    }
+
+
+}

Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ServiceFileCreator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ServiceFileCreator.java?view=auto&rev=453901
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ServiceFileCreator.java (added)
+++ webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ServiceFileCreator.java Sat Oct  7 06:26:21 2006
@@ -0,0 +1,104 @@
+package org.apache.axis2.tool.core;
+
+import org.apache.axis2.wsdl.codegen.writer.ClassWriter;
+import org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+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 ServiceFileCreator {
+    
+    public File createServiceFile(String serviceName,String implementationClassName,ArrayList methodList) throws Exception {
+        
+        String currentUserDir = System.getProperty("user.dir");
+        String fileName = "services.xml";
+        
+        ClassWriter serviceXmlWriter = new ServiceXMLWriter(currentUserDir);
+        writeClass(getServiceModel(serviceName,implementationClassName,methodList),serviceXmlWriter,fileName);
+
+        return new File(currentUserDir + File.separator + fileName);
+
+
+
+
+    }
+
+    private Document getServiceModel(String serviceName,String className,ArrayList methods){
+
+        DocumentBuilder builder = null;
+        try {
+            builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        } catch (ParserConfigurationException e) {
+            throw new RuntimeException(e);
+        }
+        Document doc = builder.newDocument();
+        
+        Element rootElement = doc.createElement("interface");
+        rootElement.setAttribute("classpackage","");
+        rootElement.setAttribute("name",className);
+        rootElement.setAttribute("servicename",serviceName);
+        Element methodElement = null;
+        int size = methods.size();
+        for(int i=0;i<size;i++){
+            methodElement = doc.createElement("method");
+            rootElement.setAttribute("name",methods.get(i).toString());
+            rootElement.appendChild(methodElement);
+        }
+        doc.appendChild(rootElement);
+        return doc;
+    }
+    
+    /**
+     * A resusable method for the implementation of interface and implementation writing
+     * @param model
+     * @param writer
+     * @throws IOException
+     * @throws Exception
+     */
+    private void writeClass(Document model, ClassWriter writer,String fileName) throws IOException,Exception {
+        
+        Source source = new DOMSource(model);
+        ByteArrayOutputStream memoryStream = new ByteArrayOutputStream();
+        Result result = new StreamResult(memoryStream);
+        Transformer xformer = TransformerFactory.newInstance().newTransformer();
+        xformer.transform(source, result);
+        
+        //TODO: Doesn't really output stuff from the memorystream to file...hmm.
+        
+        writer.loadTemplate();
+        writer.createOutFile(null,
+                 fileName);
+    }
+    
+   
+
+}

Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java?view=auto&rev=453901
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java (added)
+++ webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java Sat Oct  7 06:26:21 2006
@@ -0,0 +1,63 @@
+package org.apache.axis2.tool.core;
+/*
+ * 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.
+ */
+import org.apache.tools.ant.taskdefs.Javac;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+import org.apache.tools.ant.Project;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.FilenameFilter;
+import java.io.FileFilter;
+import java.net.URL;
+import java.util.Properties;
+
+/**
+ * This is the custom class for compiling the source 
+ */
+public class SrcCompiler extends Javac {
+
+    Project project;
+    public SrcCompiler() {
+        project = new Project();
+        this.setProject(project);
+        project.init();
+    }
+
+    public void compileSource(File destDir, String compilableSrcLocation){
+
+        Path path;
+        Path srcPath = new Path(project,compilableSrcLocation + File.separator + "src");
+        this.setSrcdir(srcPath);
+        this.setDestdir(destDir);
+        this.setIncludes("**/*.java, *.java");
+        File lib = new File(compilableSrcLocation+  File.separator + "lib");
+        File files [] = new File[lib.listFiles().length];
+        files = lib.listFiles();
+
+        Path classpath = new Path(project);
+        for (int count =0;count<files.length;count++){
+            path = new Path(project,files[count].getAbsolutePath());
+            classpath.add(path);
+        }
+        
+        this.setClasspath(classpath);
+        this.setFork(true);
+        this.perform();
+
+    }
+}

Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java?view=auto&rev=453901
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java (added)
+++ webservices/axis2/branches/java/1_1/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java Sat Oct  7 06:26:21 2006
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+package org.apache.axis2.tool.util;
+
+public class Constants {
+    public class UIConstants{
+        public static final int LABEL_WIDTH=100;
+        public static final int RADIO_BUTTON_WIDTH=200;
+        public static final int TEXT_BOX_WIDTH=250;
+        public static final int BROWSE_BUTTON_WIDTH=20;
+        public static final int GENERAL_BUTTON_WIDTH=80;
+
+        public static final int GENERAL_COMP_HEIGHT=20;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org