You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/06/14 21:11:13 UTC

svn commit: r190648 [1/2] - in /incubator/beehive/trunk: system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/ wsm/drt/tests/org/apache/beehive/wsm/model/ wsm/drt/tests/org/apache/beehive/wsm/model/wsdl/ wsm/src/runtime/org/apache/beehive/wsm/axis/tools/ wsm/src/runtime/org/apache/beehive/wsm/model/wsdl/ wsm/src/runtime/org/apache/beehive/wsm/wsdl/

Author: ekoneil
Date: Tue Jun 14 12:11:11 2005
New Revision: 190648

URL: http://svn.apache.org/viewcvs?rev=190648&view=rev
Log:
Patch for JIRA BEEHIVE-780.  This patch rearranges the way that DefinitionsDocument instances are created and passed around and fixes at least two InputStream leaks which were occurring before.

Contribution from Daryoush Mehrtash.

Changes from the patch include:
- unformatting some errant reformatting
- fixing some error reporting in Wsdl2AJava

BB: self
DRT: Beehive pass / build.dist pass


Added:
    incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/model/
    incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/model/wsdl/
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/Model2AJava.java
      - copied, changed from r190625, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/AbstractWsdl2AJava.java
Removed:
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/AbstractWsdl2AJava.java
Modified:
    incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ExtensionMaker.java
    incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.jcs
    incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/tools/Wsdl2AJava.java
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/Schema.java
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/Utilities.java
    incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/WSDLParser.java

Modified: incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ExtensionMaker.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ExtensionMaker.java?rev=190648&r1=190647&r2=190648&view=diff
==============================================================================
--- incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ExtensionMaker.java (original)
+++ incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ExtensionMaker.java Tue Jun 14 12:11:11 2005
@@ -1,367 +1,347 @@
-/*
- * Copyright 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.
- *
- * $Header:$
- */
-package org.apache.beehive.controls.system.webservice.generator;
-
-import java.util.List;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.PrintWriter;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.FileInputStream;
-import javax.jws.WebParam;
-
-import org.apache.axis.wsdl.toJava.Namespaces;
-import org.apache.axis.wsdl.toJava.Utils;
-import org.apache.beehive.wsm.axis.databinding.SystemTypeLookupService;
-import org.apache.beehive.wsm.model.BeehiveWsMethodMetadata;
-import org.apache.beehive.wsm.model.BeehiveWsParameterMetadata;
-import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
-import org.apache.beehive.wsm.model.wsdl.XmlBeanWSDLProcessor;
-import org.apache.beehive.wsm.wsdl.WSDLParser;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.xmlbeans.XmlException;
-
-/**
- *
- */
-public class ExtensionMaker {
-
-    private static final FileFilter FILE_FILTER_WSDL = new WSDLFilter();
-
-    private static final String[] standardImports = {
-            "org.apache.beehive.controls.api.bean.ControlExtension",
-            "org.apache.beehive.controls.system.webservice.ServiceControl",
-            "org.apache.beehive.controls.system.webservice.ServiceControl.Location",
-            "org.apache.beehive.controls.system.webservice.ServiceControl.WSDL", };
-
-    File mOutputDir;
-
-    String mWSDLPath = "<path to WSDL>";
-
-    String packageName = null;
-
-    private String serviceURL = null;
-
-    public ExtensionMaker(File outputDir) {
-        mOutputDir = outputDir;
-    }
-
-    public void setWSDLPath(String wsdlPath) {
-        mWSDLPath = wsdlPath.replace('\\', '/');
-    }
-
-    /**
-     * @param serviceURL
-     *            The serviceURL to set.
-     */
-    public void setServiceURL(String serviceURL) {
-        this.serviceURL = serviceURL;
-    }
-
-    public void writeJCX(BeehiveWsTypeMetadata wsm) throws Exception {
-        String serviceName = wsm.getWsServiceName();
-
-        // TODO: Should the class generation depend on Axis?
-        if (packageName == null) {
-            packageName = Utils.makePackageName(wsm.getWsTargetNamespace());
-        }
-        if (serviceName != null && packageName != null) {
-            File subDir = new File(mOutputDir, new Namespaces(null)
-                    .toDir(packageName));
-            subDir.mkdirs();
-            if (subDir.isDirectory()) {
-                File jcx = new File(subDir, serviceName + ".jcx");
-                PrintWriter jcxWriter = new PrintWriter(jcx, "UTF-8");
-
-                jcxWriter.print("package ");
-                jcxWriter.print(packageName);
-                jcxWriter.print(";\n\n");
-
-                for (String imp : standardImports) {
-                    jcxWriter.print("import ");
-                    jcxWriter.print(imp);
-                    jcxWriter.print(";\n");
-                }
-
-                jcxWriter.print("@ControlExtension\n");
-                jcxWriter.print("@Location(urls = {\"");
-                jcxWriter.print(serviceURL);
-                jcxWriter.print("\"})\n");
-                jcxWriter.print("@WSDL(path = \"");
-                jcxWriter.print(mWSDLPath);
-                jcxWriter.print("\",\n\tservice = \"");
-                jcxWriter.print(serviceName);
-                jcxWriter.print("\")\n");
-                jcxWriter.print("\n\npublic interface ");
-                jcxWriter.print(serviceName);
-                jcxWriter.print(" extends ServiceControl {\n\n");
-
-                for (BeehiveWsMethodMetadata method : wsm.getMethods()) {
-                    jcxWriter.print("public ");
-                    // String returnVal = "Object";
-                    // Class javaType = method.getJavaReturnType();
-                    // if (javaType != null) {
-                    // returnVal = getClassName(javaType);
-                    // }
-                    //
-                    // QName q = method.getXmlReturnType();
-                    // if (q != null) {
-                    // returnVal = Utils.makePackageName(q.getNamespaceURI())
-                    // + q.getLocalPart();
-                    // }
-                    //
-                    // jcxWriter.print(returnVal);
-                    jcxWriter.print(method.getJavaReturnTypeFullName());
-                    jcxWriter.write(' ');
-                    jcxWriter.print(method.getWmOperationName());
-                    jcxWriter.write('(');
-                    printParameters(method.getParams(), jcxWriter);
-                    jcxWriter.print(") throws Exception;\n\n");
-                }
-
-                jcxWriter.print("}\n");
-                jcxWriter.close();
-            }
-        }
-    }
-
-    private String getClassName(Class cls) {
-        if (cls.isArray()) {
-            return getClassName(cls.getComponentType()) + "[]";
-        } else {
-            return cls.getName().replace('$', '.');
-        }
-    }
-
-    // NOTE: For OUT and IN/OUT parameters this method can use the GenericHolder
-    // class...TBD
-    private void printParameters(
-           List< ? extends BeehiveWsParameterMetadata> params, PrintWriter pw) {
-        int paramPos = 0;
-        for (BeehiveWsParameterMetadata param : params) {
-            if (paramPos > 0) {
-                pw.print(", ");
-            }
-
-            // String paramType = "Object";
-            // Class javaType = param.getJavaType();
-            // if (javaType != null) {
-            // paramType = getClassName(javaType);
-            // }
-            //
-            // QName q = param.getXmlType();
-            // if (q != null) {
-            // paramType = Utils.makePackageName(q.getNamespaceURI())
-            // + q.getLocalPart();
-            // }
-            //
-            // pw.print(paramType);
-            if( param.getWpMode() == WebParam.Mode.INOUT || param.getWpMode() == WebParam.Mode.OUT)  {
-                pw.print(getHolderForType(param.getJavaType()));
-            } else {
-                pw.print(param.getJavaTypeFullName());
-            }
-            pw.write(' ');
-            String paramName = param.getWpName();
-            if (paramName == null) {
-                paramName = "param" + paramPos;
-            }
-            pw.print(paramName);
-            paramPos++;
-        }
-    }
-
-    private String getHolderForType(Class clazz) {
-       if( clazz == int.class) return "javax.xml.rpc.holders.IntHolder";
-       else if( clazz == boolean.class) return "javax.xml.rpc.holders.BooleanHolder";
-       else if (clazz == new byte[0].getClass()) return "javax.xml.rpc.holders.ByteArrayHolder";
-       else if (clazz == byte.class) return "javax.xml.rpc.holders.ByteHolder";
-       else if (clazz == double.class) return "javax.xml.rpc.holders.DoubleHolder";
-       else if (clazz == float.class) return "javax.xml.rpc.holders.FloatHolder";
-       else if (clazz == long.class) return "javax.xml.rpc.holders.FloatHolder";
-       else if (clazz == short.class) return "javax.xml.rpc.holders.ShortHolder";
-       else     
-       return  "org.apache.beehive.wsm.databinding.GenericHolder<" + clazz.getCanonicalName() + ">";
-    }
-    
-    private static Options buildOptions() {
-        Options options = new Options();
-        OptionBuilder.hasArg();
-        OptionBuilder.withArgName("dir");
-        OptionBuilder.withDescription("Base directory of the wsdl file(s)");
-        OptionBuilder.isRequired(true);
-        Option option = OptionBuilder.create("wsdl");
-        options.addOption(option);
-
-        OptionBuilder.hasArg();
-        OptionBuilder.withArgName("dir");
-        OptionBuilder.withDescription("Root directory for the jcx file.");
-        OptionBuilder.isRequired(true);
-        option = OptionBuilder.create("gen_root");
-        options.addOption(option);
-
-//        OptionBuilder.hasArg();
-//        OptionBuilder.withArgName("URL");
-//        OptionBuilder.withDescription("URL to the web service.");
-//        option = OptionBuilder.create("serviceURL");
-//        OptionBuilder.isRequired(false); // if specified, it will overwrite
-//                                            // the one in WSDL
-//        options.addOption(option);
-
-        OptionBuilder.hasArg();
-        OptionBuilder.withArgName("dir");
-        OptionBuilder.isRequired(false);
-        OptionBuilder.withDescription("path annotation to use in the jcx");
-        option = OptionBuilder.create("wsdl_path_annotation");
-        options.addOption(option);
-
-        OptionBuilder.hasArg();
-        OptionBuilder.withArgName("package_name");
-        OptionBuilder.isRequired(false);
-        OptionBuilder.withDescription("Package name of the jcx");
-        option = OptionBuilder.create("pkg");
-        options.addOption(option);
-
-        return options;
-    }
-
-    public static void main(String[] args) throws Exception {
-
-        String outFileName = null;
-        String wsdlDirName = null;
-        String serviceURL = null;
-        String wsdlPathAnnotation = null;
-        String pkgName = null;
-
-        try {
-            Options options = buildOptions();
-            CommandLineParser parser = new GnuParser();
-            CommandLine line = parser.parse(options, args);
-
-            outFileName = line.getOptionValue("gen_root");
-            wsdlDirName = line.getOptionValue("wsdl");
-//            if (line.hasOption("serviceURL"))
-//                serviceURL = line.getOptionValue("serviceURL");
-            if (line.hasOption("wsdl_path_annotation"))
-                wsdlPathAnnotation = line
-                        .getOptionValue("wsdl_path_annotation");
-
-            if (line.hasOption("pkg"))
-                pkgName = line.getOptionValue("pkg");
-
-        } catch (ParseException exp) {
-            // oops, something went wrong
-            System.err.println("Parsing failed.  Reason: " + exp.getMessage());
-            System.exit(-1);
-        }
-
-        File out = new File(outFileName);
-        ExtensionMaker em = new ExtensionMaker(out);
-
-        em.genJCX(wsdlDirName, serviceURL, pkgName, wsdlPathAnnotation);
-
-    }
-
-    /**
-     * @param wsdlDirName
-     * @param serviceURL
-     * @param pkgName
-     * @param wsdlPathAnnotation
-     * @throws IOException
-     * @throws Exception
-     * @throws FileNotFoundException
-     * @throws XmlException
-     * @throws IllegalAccessException
-     * @throws NoSuchFieldException
-     */
-    private void genJCX(String wsdlDirName, String serviceURL, String pkgName, String wsdlPathAnnotation)
-        throws IOException, Exception, FileNotFoundException, XmlException,
-               IllegalAccessException, NoSuchFieldException {
-        setServiceURL(serviceURL);
-        setPackageName(pkgName);
-        File wsdlDir = new File(wsdlDirName);
-        if (wsdlDir.isDirectory()) {
-            for (File wsdlFile : wsdlDir.listFiles(FILE_FILTER_WSDL)) {
-                genJCXForWSDLFile( wsdlPathAnnotation, wsdlFile);
-            }
-        } else if (wsdlDir.isFile()) {
-            genJCXForWSDLFile(wsdlPathAnnotation, wsdlDir);
-            
-        } else {
-            throw new Exception("no WSDL location specified at: " + wsdlDir.getCanonicalPath());
-        }
-    }
-
-    /**
-     * @param wsdlPathAnnotation
-     * @param wsdlFile
-     * @throws IOException
-     * @throws Exception
-     * @throws java.io.FileNotFoundException
-     * @throws XmlException
-     * @throws IllegalAccessException
-     * @throws NoSuchFieldException
-     */
-    private void genJCXForWSDLFile(String wsdlPathAnnotation, File wsdlFile)
-        throws IOException, Exception, FileNotFoundException, XmlException, IllegalAccessException,
-               NoSuchFieldException {
-        if (wsdlPathAnnotation != null) {
-            setWSDLPath(wsdlPathAnnotation + "/" + wsdlFile.getName());
-        } else {
-            setWSDLPath(wsdlFile.getName());
-
-        }
-        // get additional wsdl information
-        WSDLParser parser = new WSDLParser(
-                new FileInputStream(wsdlFile));
-//        if (null == serviceURL) { // none has been defined, get it
-//                                    // from wsdl
-//        }
-
-       serviceURL = parser.getSoapAddressLocation();
-	   
-	   
-	   XmlBeanWSDLProcessor wsdlProcessor =  new XmlBeanWSDLProcessor( new FileInputStream(wsdlFile));
-
-	   
-       writeJCX(wsdlProcessor.getObjectModel( new SystemTypeLookupService()));
-    }
-
-    /**
-     * @param packageName
-     *            The packageName to set.
-     */
-    public void setPackageName(String packageName) {
-        this.packageName = packageName;
-    }
-
-    private static class WSDLFilter
-        implements java.io.FileFilter {
-
-        public boolean accept(java.io.File f) {
-            return (f.isFile() && (f.getName().endsWith("wsdl") || f.getName().endsWith("WSDL")));
-        }
-    }
-}
+/*
+ * Copyright 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.beehive.controls.system.webservice.generator;
+
+import java.util.List;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.PrintWriter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import javax.jws.WebParam;
+
+import org.apache.axis.wsdl.toJava.Namespaces;
+import org.apache.axis.wsdl.toJava.Utils;
+import org.apache.beehive.wsm.axis.databinding.SystemTypeLookupService;
+import org.apache.beehive.wsm.model.BeehiveWsMethodMetadata;
+import org.apache.beehive.wsm.model.BeehiveWsParameterMetadata;
+import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
+import org.apache.beehive.wsm.model.wsdl.XmlBeanWSDLProcessor;
+import org.apache.beehive.wsm.wsdl.Utilities;
+import org.apache.beehive.wsm.wsdl.WSDLParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.xmlbeans.XmlException;
+import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
+
+/**
+ *
+ */
+public class ExtensionMaker {
+
+    private static final FileFilter FILE_FILTER_WSDL = new WSDLFilter();
+
+    private static final String[] standardImports = {
+            "org.apache.beehive.controls.api.bean.ControlExtension",
+            "org.apache.beehive.controls.system.webservice.ServiceControl",
+            "org.apache.beehive.controls.system.webservice.ServiceControl.Location",
+            "org.apache.beehive.controls.system.webservice.ServiceControl.WSDL", };
+
+    File mOutputDir;
+
+    String mWSDLPath = "<path to WSDL>";
+
+    String packageName = null;
+
+    private String serviceURL = null;
+
+    public ExtensionMaker(File outputDir) {
+        mOutputDir = outputDir;
+    }
+
+    public void setWSDLPath(String wsdlPath) {
+        mWSDLPath = wsdlPath.replace('\\', '/');
+    }
+
+    /**
+     * @param serviceURL The service URL to set.
+     */
+    public void setServiceURL(String serviceURL) {
+        this.serviceURL = serviceURL;
+    }
+
+    /**
+     * @param packageName The packageName to set.
+     */
+    public void setPackageName(String packageName) {
+        this.packageName = packageName;
+    }
+
+    public void writeJCX(BeehiveWsTypeMetadata wsm) throws Exception {
+        String serviceName = wsm.getWsServiceName();
+
+        // TODO: Should the class generation depend on Axis?
+        if (packageName == null) {
+            packageName = Utils.makePackageName(wsm.getWsTargetNamespace());
+        }
+        if (serviceName != null && packageName != null) {
+            File subDir = new File(mOutputDir, new Namespaces(null)
+                    .toDir(packageName));
+            subDir.mkdirs();
+            if (subDir.isDirectory()) {
+                File jcx = new File(subDir, serviceName + ".jcx");
+                PrintWriter jcxWriter = new PrintWriter(jcx, "UTF-8");
+
+                jcxWriter.print("package ");
+                jcxWriter.print(packageName);
+                jcxWriter.print(";\n\n");
+
+                for (String imp : standardImports) {
+                    jcxWriter.print("import ");
+                    jcxWriter.print(imp);
+                    jcxWriter.print(";\n");
+                }
+
+                jcxWriter.print("@ControlExtension\n");
+                jcxWriter.print("@Location(urls = {\"");
+                jcxWriter.print(serviceURL);
+                jcxWriter.print("\"})\n");
+                jcxWriter.print("@WSDL(path = \"");
+                jcxWriter.print(mWSDLPath);
+                jcxWriter.print("\",\n\tservice = \"");
+                jcxWriter.print(serviceName);
+                jcxWriter.print("\")\n");
+                jcxWriter.print("\n\npublic interface ");
+                jcxWriter.print(serviceName);
+                jcxWriter.print(" extends ServiceControl {\n\n");
+
+                for (BeehiveWsMethodMetadata method : wsm.getMethods()) {
+                    jcxWriter.print("public ");
+                    // String returnVal = "Object";
+                    // Class javaType = method.getJavaReturnType();
+                    // if (javaType != null) {
+                    // returnVal = getClassName(javaType);
+                    // }
+                    //
+                    // QName q = method.getXmlReturnType();
+                    // if (q != null) {
+                    // returnVal = Utils.makePackageName(q.getNamespaceURI())
+                    // + q.getLocalPart();
+                    // }
+                    //
+                    // jcxWriter.print(returnVal);
+                    jcxWriter.print(method.getJavaReturnTypeFullName());
+                    jcxWriter.write(' ');
+                    jcxWriter.print(method.getWmOperationName());
+                    jcxWriter.write('(');
+                    printParameters(method.getParams(), jcxWriter);
+                    jcxWriter.print(") throws Exception;\n\n");
+                }
+
+                jcxWriter.print("}\n");
+                jcxWriter.close();
+            }
+        }
+    }
+
+
+    public static void main(String[] args) throws Exception {
+
+        String outFileName = null;
+        String wsdlDirName = null;
+        String serviceURL = null;
+        String wsdlPathAnnotation = null;
+        String pkgName = null;
+
+        try {
+            Options options = buildOptions();
+            CommandLineParser parser = new GnuParser();
+            CommandLine line = parser.parse(options, args);
+
+            outFileName = line.getOptionValue("gen_root");
+            wsdlDirName = line.getOptionValue("wsdl");
+            if (line.hasOption("wsdl_path_annotation"))
+                wsdlPathAnnotation = line
+                        .getOptionValue("wsdl_path_annotation");
+
+            if (line.hasOption("pkg"))
+                pkgName = line.getOptionValue("pkg");
+
+        } catch (ParseException exp) {
+            System.err.println("Parsing failed.  Reason: " + exp.getMessage());
+            System.exit(-1);
+        }
+
+        File out = new File(outFileName);
+        ExtensionMaker em = new ExtensionMaker(out);
+
+        em.genJCX(wsdlDirName, serviceURL, pkgName, wsdlPathAnnotation);
+    }
+
+    // NOTE: For OUT and IN/OUT parameters this method can use the GenericHolder
+    // class...TBD
+    private void printParameters(
+           List< ? extends BeehiveWsParameterMetadata> params, PrintWriter pw) {
+        int paramPos = 0;
+        for (BeehiveWsParameterMetadata param : params) {
+            if (paramPos > 0) {
+                pw.print(", ");
+            }
+
+            // String paramType = "Object";
+            // Class javaType = param.getJavaType();
+            // if (javaType != null) {
+            // paramType = getClassName(javaType);
+            // }
+            //
+            // QName q = param.getXmlType();
+            // if (q != null) {
+            // paramType = Utils.makePackageName(q.getNamespaceURI())
+            // + q.getLocalPart();
+            // }
+            //
+            // pw.print(paramType);
+            if( param.getWpMode() == WebParam.Mode.INOUT || param.getWpMode() == WebParam.Mode.OUT)  {
+                pw.print(getHolderForType(param.getJavaType()));
+            } else {
+                pw.print(param.getJavaTypeFullName());
+            }
+            pw.write(' ');
+            String paramName = param.getWpName();
+            if (paramName == null) {
+                paramName = "param" + paramPos;
+            }
+            pw.print(paramName);
+            paramPos++;
+        }
+    }
+
+    private String getHolderForType(Class clazz) {
+       if( clazz == int.class) return "javax.xml.rpc.holders.IntHolder";
+       else if( clazz == boolean.class) return "javax.xml.rpc.holders.BooleanHolder";
+       else if (clazz == new byte[0].getClass()) return "javax.xml.rpc.holders.ByteArrayHolder";
+       else if (clazz == byte.class) return "javax.xml.rpc.holders.ByteHolder";
+       else if (clazz == double.class) return "javax.xml.rpc.holders.DoubleHolder";
+       else if (clazz == float.class) return "javax.xml.rpc.holders.FloatHolder";
+       else if (clazz == long.class) return "javax.xml.rpc.holders.FloatHolder";
+       else if (clazz == short.class) return "javax.xml.rpc.holders.ShortHolder";
+       else return  "org.apache.beehive.wsm.databinding.GenericHolder<" + clazz.getCanonicalName() + ">";
+    }
+
+    private static Options buildOptions() {
+        Options options = new Options();
+        OptionBuilder.hasArg();
+        OptionBuilder.withArgName("dir");
+        OptionBuilder.withDescription("Base directory of the wsdl file(s)");
+        OptionBuilder.isRequired(true);
+        Option option = OptionBuilder.create("wsdl");
+        options.addOption(option);
+
+        OptionBuilder.hasArg();
+        OptionBuilder.withArgName("dir");
+        OptionBuilder.withDescription("Root directory for the jcx file.");
+        OptionBuilder.isRequired(true);
+        option = OptionBuilder.create("gen_root");
+        options.addOption(option);
+
+//        OptionBuilder.hasArg();
+//        OptionBuilder.withArgName("URL");
+//        OptionBuilder.withDescription("URL to the web service.");
+//        option = OptionBuilder.create("serviceURL");
+//        OptionBuilder.isRequired(false); // if specified, it will overwrite
+//                                            // the one in WSDL
+//        options.addOption(option);
+
+        OptionBuilder.hasArg();
+        OptionBuilder.withArgName("dir");
+        OptionBuilder.isRequired(false);
+        OptionBuilder.withDescription("path annotation to use in the jcx");
+        option = OptionBuilder.create("wsdl_path_annotation");
+        options.addOption(option);
+
+        OptionBuilder.hasArg();
+        OptionBuilder.withArgName("package_name");
+        OptionBuilder.isRequired(false);
+        OptionBuilder.withDescription("Package name of the jcx");
+        option = OptionBuilder.create("pkg");
+        options.addOption(option);
+
+        return options;
+    }
+
+
+    /**
+     * @param wsdlDirName
+     * @param serviceURL
+     * @param pkgName
+     * @param wsdlPathAnnotation
+     * @throws IOException
+     * @throws Exception
+     * @throws FileNotFoundException
+     * @throws XmlException
+     * @throws IllegalAccessException
+     * @throws NoSuchFieldException
+     */
+    private void genJCX(String wsdlDirName, String serviceURL, String pkgName, String wsdlPathAnnotation)
+        throws IOException, Exception, FileNotFoundException, XmlException,
+        IllegalAccessException, NoSuchFieldException {
+
+        setServiceURL(serviceURL);
+        setPackageName(pkgName);
+        File wsdlDir = new File(wsdlDirName);
+        if (wsdlDir.isDirectory()) {
+            for (File wsdlFile : wsdlDir.listFiles(FILE_FILTER_WSDL)) {
+                genJCXForWSDLFile( wsdlPathAnnotation, wsdlFile);
+            }
+        } else if (wsdlDir.isFile()) {
+            genJCXForWSDLFile(wsdlPathAnnotation, wsdlDir);
+
+        } else {
+            throw new Exception("no WSDL location specified at: " + wsdlDir.getCanonicalPath());
+        }
+    }
+
+    /**
+     * @param wsdlPathAnnotation
+     * @param wsdlFile
+     * @throws IOException
+     * @throws Exception
+     * @throws java.io.FileNotFoundException
+     * @throws XmlException
+     * @throws IllegalAccessException
+     * @throws NoSuchFieldException
+     */
+    private void genJCXForWSDLFile(String wsdlPathAnnotation, File wsdlFile)
+        throws IOException, Exception, FileNotFoundException, XmlException, IllegalAccessException,
+               NoSuchFieldException {
+
+        /* todo:  Does this make sense here? */
+        if (wsdlPathAnnotation != null)
+            setWSDLPath(wsdlPathAnnotation + "/" + wsdlFile.getName());
+        else setWSDLPath(wsdlFile.getName());
+
+        DefinitionsDocument wsdlDocument = Utilities.parseWSDL(wsdlFile);
+        serviceURL = new WSDLParser(wsdlDocument).getSoapAddressLocation();
+
+        SystemTypeLookupService lookupService = new SystemTypeLookupService();
+        XmlBeanWSDLProcessor xbwp = new XmlBeanWSDLProcessor(Utilities.parseWSDL(wsdlFile), lookupService);
+
+        writeJCX(xbwp.getObjectModel());
+    }
+
+    private static class WSDLFilter
+        implements java.io.FileFilter {
+
+        public boolean accept(java.io.File f) {
+            return (f.isFile() && (f.getName().endsWith("wsdl") || f.getName().endsWith("WSDL")));
+        }
+    }
+}

Modified: incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.jcs
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.jcs?rev=190648&r1=190647&r2=190648&view=diff
==============================================================================
--- incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.jcs (original)
+++ incubator/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.jcs Tue Jun 14 12:11:11 2005
@@ -1,664 +1,656 @@
-/*
- * Copyright 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.
- *
- * $Header:$
- */
-package org.apache.beehive.controls.system.webservice.jaxrpc;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Iterator;
-
-import javax.jws.WebParam;
-import javax.jws.soap.SOAPBinding;
-import javax.xml.namespace.QName;
-import javax.xml.rpc.Call;
-import javax.xml.rpc.ParameterMode;
-import javax.xml.rpc.Service;
-import javax.xml.rpc.ServiceException;
-import javax.xml.rpc.ServiceFactory;
-import javax.xml.rpc.encoding.TypeMapping;
-import javax.xml.rpc.handler.HandlerInfo;
-import javax.xml.rpc.holders.Holder;
-
-import org.apache.axis.constants.Use;
-import org.apache.beehive.controls.api.bean.ControlImplementation;
-import org.apache.beehive.controls.api.bean.Extensible;
-import org.apache.beehive.controls.api.context.Context;
-import org.apache.beehive.controls.api.context.ControlBeanContext;
-import org.apache.beehive.wsm.axis.databinding.SystemTypeLookupService;
-import org.apache.beehive.wsm.axis.registration.AxisTypeRegistrar;
-import org.apache.beehive.wsm.databinding.BindingLookupService;
-import org.apache.beehive.wsm.model.BeehiveWsMethodMetadata;
-import org.apache.beehive.wsm.model.BeehiveWsParameterMetadata;
-import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
-import org.apache.beehive.wsm.model.wsdl.XmlBeanWSDLProcessor;
-import org.apache.beehive.wsm.registration.TypeRegistrar;
-import org.apache.beehive.controls.system.webservice.ServiceControl;
-import org.apache.beehive.controls.system.webservice.utils.HolderUtils;
-import org.apache.log4j.Logger;
-
-import org.w3c.dom.Element;
-
-@ControlImplementation
-public class ServiceControlImpl
-    implements ServiceControl, Extensible, Serializable {
-
-    static Logger logger = Logger.getLogger(ServiceControlImpl.class);
-
-	@Context
-	public ControlBeanContext cbContext;
-
-	BindingLookupService lookupService = null;
-
-	TypeRegistrar registrar = null;
-
-	Service service = null;
-
-	QName portType;
-
-	BeehiveWsTypeMetadata mWSTM;
-
-	URL endPoint = null;
-
-	QName wsdlPort = null;
-
-	String username = null;
-
-	String password = null;
-
-	int timeout = 1000;
-
-	boolean initialized = false;
-
-	public ServiceControlImpl() {}
-
-	/**
-	 * @param method
-	 * @param args
-	 * @throws Exception
-	 */
-	public Object invoke(Method method, Object[] args)
-			throws NoSuchMethodException, Exception {
-
-        assert method != null;
-
-        logger.debug("invoke method: " + method.getName());
-		initialize();
-		String operationName = method.getName();
-		String alternateOperationName = getAlternateOperationName(method);
-		if (null != alternateOperationName)
-			operationName = alternateOperationName;
-
-        BeehiveWsMethodMetadata wmm = findMethodInOM(method, operationName);
-
-		Call call = buildCallObject(method, wmm);
-
-		Object[] callArgs = prepareArgsForSend(method, wmm, args);
-
-		Object res = call.invoke(callArgs);
-		fillHolders(method, wmm, call, args);
-
-		return res;
-	}
-
-	// create a new copy of the args where holders value have been extracted.
-	// ignore the out values
-	private Object[] prepareArgsForSend(Method method,
-                                        BeehiveWsMethodMetadata wmm,
-                                        Object[] args) {
-
-		ArrayList argsList = new ArrayList();
-		Class[] methodParameterTypes = method.getParameterTypes();
-		Iterator<BeehiveWsParameterMetadata> it = wmm.getParams().iterator();
-
-        // size of the param list must be the size of the args array
-		for (int i = 0; i < methodParameterTypes.length; i++) {
-			Class javaTypeFromClass = methodParameterTypes[i];
-			BeehiveWsParameterMetadata nxtParamMetaData = it.next();
-			if (nxtParamMetaData.getWpMode() == WebParam.Mode.OUT)
-				continue; // don't send OUT parameters.
-
-            if ((nxtParamMetaData.getWpMode() == WebParam.Mode.INOUT)
-                && Holder.class.isAssignableFrom(javaTypeFromClass)) {
-				try {
-					Holder holder = (Holder) args[i];
-					Field valueField = holder.getClass().getField("value");
-					argsList.add(valueField.get(holder));
-				} catch (Exception e) {
-					throw new RuntimeException(
-							"failed in getting holder value for: "
-									+ nxtParamMetaData.getWpName());
-				}
-
-			} else {
-				argsList.add(args[i]);
-			}
-		}
-		Object[] res = (Object[]) argsList.toArray(new Object[argsList.size()]);
-
-		return res;
-	}
-
-	// fill the hodlers in the argument array with the result of the call
-	private void fillHolders(Method method,
-                             BeehiveWsMethodMetadata wmm,
-                             Call call,
-                             Object[] args) {
-		Map outParam = call.getOutputParams();
-
-		if (outParam.isEmpty())
-			return;
-
-        for (Object nxtOutParamKey : outParam.keySet()) {
-			logger.info("Got outparam: " + nxtOutParamKey + " value: "
-                + outParam.get(nxtOutParamKey)
-                + " Stuff this into the holders");
-		}
-
-		Class[] methodParameterTypes = method.getParameterTypes();
-		Iterator<BeehiveWsParameterMetadata> it = wmm.getParams().iterator();
-        // size of the param list must be the size of the args array
-		for (int i = 0; i < methodParameterTypes.length; i++) {
-			Class javaTypeFromClass = methodParameterTypes[i];
-			BeehiveWsParameterMetadata nxtParamMetaData = it.next();
-
-			if ((nxtParamMetaData.getWpMode() == WebParam.Mode.INOUT || nxtParamMetaData
-                .getWpMode() == WebParam.Mode.OUT)
-                && Holder.class.isAssignableFrom(javaTypeFromClass)) {
-
-                try {
-					logger.info("Fill the holder object: " + nxtParamMetaData.getWpName());
-					Holder holder = (Holder) args[i];
-					Object value = null; // find the value, only check for
-					// localpart of the name, as the
-					// namespace
-					// may not be filled
-					boolean hasReturnValue = false;
-					for (Object nxtOutParamKey : outParam.keySet()) {
-						if (((QName) nxtOutParamKey).getLocalPart().equals(nxtParamMetaData.getWpName())) {
-							value = outParam.get(nxtOutParamKey);
-							hasReturnValue = true;
-							break;
-						}
-					}
-
-					if (hasReturnValue)
-						stuffHolderValue(holder, value);
-
-				} catch (Exception e) {
-					throw new RuntimeException("Failed in getting holder value for: " + nxtParamMetaData.getWpName());
-				}
-
-			} else {
-				continue;
-			}
-		}
-	}
-
-	private void stuffHolderValue(Holder holder, Object value)
-        throws NoSuchFieldException, IllegalAccessException {
-		HolderUtils.stuffHolderValue(holder, value);
-	}
-
-	/**
-	 * @param method
-	 * @param wmm
-	 * @return
-	 * @throws ServiceException
-	 * @throws Exception
-	 */
-	private Call buildCallObject(Method method, BeehiveWsMethodMetadata wmm)
-        throws ServiceException, Exception {
-
-		// TODO: Later cache the call objects for each method.
-
-		Call call = service.createCall();
-		if (getWsdlPort() != null) {
-			call.setPortTypeName(getWsdlPort());
-		}
-		if (getUsername() != null) {
-			call.setProperty(Call.USERNAME_PROPERTY, getUsername());
-		}
-		if (getPassword() != null) {
-			call.setProperty(Call.PASSWORD_PROPERTY, getPassword());
-		}
-		call.setOperationName(
-            new javax.xml.namespace.QName(mWSTM.getWsTargetNamespace(), wmm.getWmOperationName()));
-
-		// The target endpoint
-		logger.debug("endpoint: " + getEndPoint().toExternalForm());
-		call.setTargetEndpointAddress(getEndPoint().toExternalForm());
-		//       
-		// NO TImeout property in the JaxRPC
-		// int timeout = serviceControl.getTimeout();
-		// if (timeout != 0) {
-		// call.setTimeout(new Integer(timeout));
-		// }
-
-		// set style
-		SOAPBinding.Style omStyle = mWSTM.getSoapBinding().getStyle();
-		String style;
-		if (omStyle == SOAPBinding.Style.DOCUMENT) {
-			if (mWSTM.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.WRAPPED)
-				// wrapped implies document also!
-				style = "wrapped";
-			else
-				style = "document";
-		} else if (omStyle == SOAPBinding.Style.RPC)
-			style = "rpc";
-		else
-			throw new RuntimeException("Ivalid Binding style: " + omStyle);
-
-		logger.debug("Call style: " + style);
-		call.setProperty(Call.OPERATION_STYLE_PROPERTY, style);
-
-		if ("rpc".equals(style)	&& SOAPBinding.Use.LITERAL == mWSTM.getSoapBinding().getUse()) {
-			((org.apache.axis.client.Call) call).setOperationUse(Use.LITERAL);
-		}
-		// walk the argument meta data list, register type of parameters, add
-		// parameters to the
-		// call object
-		// TODO: Make sure there is nothing special that needs to be done about
-		// holder objects.
-		List<BeehiveWsParameterMetadata> omArgMetaDataList = new ArrayList<BeehiveWsParameterMetadata>();
-		omArgMetaDataList.addAll(wmm.getParams());
-
-		Class[] methodParameterTypes = method.getParameterTypes();
-		Type[] genericMethodParamTypes = method.getGenericParameterTypes();
-
-		if (omArgMetaDataList.size() != methodParameterTypes.length)
-			throw new RuntimeException("Object model and method definition don't match!");
-		List argsToSend = new ArrayList<Object>();
-		for (int i = 0; i < methodParameterTypes.length; i++) {
-
-			BeehiveWsParameterMetadata nxtArgMetaData = omArgMetaDataList.get(i);
-			Class javaTypeFromClass = methodParameterTypes[i];
-
-			// sure
-			// the
-			// type
-			// is
-			// registered
-			ParameterMode mode;
-			WebParam.Mode omMode = nxtArgMetaData.getWpMode();
-			if (omMode == WebParam.Mode.IN)
-				mode = ParameterMode.IN;
-			else if (omMode == WebParam.Mode.OUT)
-				mode = ParameterMode.OUT;
-			else if (omMode == WebParam.Mode.INOUT) {
-				if (!Holder.class.isAssignableFrom(javaTypeFromClass))
-					throw new RuntimeException("Holder classes are required for the in/out parameters.");
-				mode = ParameterMode.INOUT;
-			} else
-				throw new RuntimeException("Invalid parameter mode: " + omMode);
-
-			// if mode is in or in/out and the type is holder then holder, get
-			// its value type
-			QName registeredTypeQName;
-
-			if ((mode == ParameterMode.OUT || mode == ParameterMode.INOUT)
-                && Holder.class.isAssignableFrom(javaTypeFromClass)) {
-				javaTypeFromClass = TypeRegistrar.getHoldersValueClass(genericMethodParamTypes[i]);
-			}
-
-            registeredTypeQName =
-                registrar.registerType(javaTypeFromClass,
-                    nxtArgMetaData.getXmlType(),
-                    mWSTM.getSoapBinding().getStyle(),
-                    mWSTM.getSoapBinding().getUse());
-
-            if (nxtArgMetaData.isWpHeader()) {
-				// TODO: addParameterAsHeader is Axis specific, later abstract
-				// out Axis from this implementation
-				logger.debug("Argument: " + nxtArgMetaData.getWpName()
-                    + " in method: " + method.getName()
-                    + " is send as soap header");
-				((org.apache.axis.client.Call) call).addParameterAsHeader(
-                    new QName(nxtArgMetaData.getWpTargetNamespace(),
-                        nxtArgMetaData.getWpName()),
-                    registeredTypeQName, javaTypeFromClass, mode, mode);
-            } else {
-                logger.debug("Argument: " + nxtArgMetaData.getWpName()
-                    + " in method: " + method.getName()
-                    + " is send in the soap body");
-                call.addParameter(nxtArgMetaData.getWpName(), registeredTypeQName, javaTypeFromClass, mode);
-			}
-		}
-		// register the return type
-		if (!wmm.isOneWay()) {
-			// QName xmlTypeFromWSDL = new QName(wmm.getWrTargetNamespace(),
-			// wmm.getWrName()); //wmm.getXmlReturnType();
-			Class javaTypeFromClass = method.getReturnType();
-            QName resultsRegisteredTypeQName = registrar.registerType(
-                javaTypeFromClass,
-                wmm.getXmlReturnType(),
-                mWSTM.getSoapBinding().getStyle(),
-                mWSTM.getSoapBinding().getUse());
-
-            call.setReturnType(resultsRegisteredTypeQName);
-//			if ("rpc".equals(style)) {
-//				((org.apache.axis.client.Call) call).setReturnQName(new QName("", "return"));   // Hack, may need this for google!  TBD, verify the need for this.
-//				((org.apache.axis.client.Call) call).setReturnClass(javaTypeFromClass);   // Hack, may need this for google!  TBD, verify the need for this.
-//			}
-		} else
-			call.setReturnType(registrar.getVoidType());
-		// AXIS dependecy... this is needed for the Handlers
-		call.setProperty(org.apache.axis.client.Call.JAXRPC_PORTTYPE_NAME,
-				portType);
-		return call;
-	}
-
-	/**
-	 * @param method
-	 * @param operationName
-	 * @throws Exception
-	 */
-	private BeehiveWsMethodMetadata findMethodInOM(Method method, String operationName)
-        throws NoSuchMethodException, Exception {
-
-		// the obejct model doesn't store holders, rather the underlying
-		// types, so to get the method
-		// we need to get the underlying types. After the loop above the
-		// paramTypes have the underlying types
-		// for any holders in the arg list.
-
-		Type[] genericParamTypes = method.getGenericParameterTypes();
-		Class[] paramTypes = method.getParameterTypes();
-		for (int i = 0; i < paramTypes.length; i++) {
-			if (Holder.class.isAssignableFrom(paramTypes[i])) {
-				paramTypes[i] = TypeRegistrar.getHoldersValueClass(genericParamTypes[i]);
-			}
-		}
-		BeehiveWsMethodMetadata wmm = mWSTM.getMethod(operationName, paramTypes);
-		if (wmm == null) {
-			StringBuffer sb = new StringBuffer("No Jsr181MethodMetadata found for " + operationName + '(');
-			boolean first = true;
-			for (Class cls : paramTypes) {
-				if (first) {
-					first = false;
-				} else {
-					sb.append(',');
-				}
-				sb.append(cls.getName());
-			}
-			sb.append(')');
-			throw new NoSuchMethodException(sb.toString());
-
-		}
-		return wmm;
-	}
-
-	private synchronized void initialize()
-        throws Exception {
-
-        if (initialized)
-			return;
-
-        XmlBeanWSDLProcessor wsdlProcessor = null;
-		ServiceControl.WSDL wsdl = (ServiceControl.WSDL)cbContext.getControlPropertySet(ServiceControl.WSDL.class);
-
-        if(wsdl == null)
-            throw new RuntimeException("No WSDL annotation found.");
-
-        InputStream is = null;
-        try {
-            logger.debug("read wsdl from: " + wsdl.path());
-			is = getWSDLStream(wsdl.path());
-
-			if(is != null)
-				wsdlProcessor = new XmlBeanWSDLProcessor(is);
-            else throw new RuntimeException("No WSDL found at the provided path: " + wsdl.path());
-        }
-        finally {
-            if(is != null)
-                is.close();
-        }
-
-        assert wsdlProcessor != null : "Did not find a valid WSDL processor";
-
-        ServiceFactory factory = ServiceFactory.newInstance();
-
-		service = factory.createService(wsdlProcessor.getServiceName());
-
-		HandlerInfo hInfo = new HandlerInfo();
-		hInfo.setHandlerClass(HeaderHandler.class);
-
-		TypeMapping tm = service.getTypeMappingRegistry().getDefaultTypeMapping();
-		lookupService = new SystemTypeLookupService();
-		registrar = new AxisTypeRegistrar((org.apache.axis.encoding.TypeMapping)tm, lookupService);
-
-        configureEndPoint();
-
-		mWSTM = wsdlProcessor.getObjectModel(lookupService);
-
-        // porttype
-        portType = new QName(mWSTM.getWsTargetNamespace(), mWSTM.getWsName());
-
-		// name
-		service.getHandlerRegistry().getHandlerChain(portType).add(hInfo);
-
-		initialized = true;
-
-	}
-
-	private String getAlternateOperationName(Method method) {
-
-		ServiceControl.OperationName opName =
-            cbContext.getMethodPropertySet(method, ServiceControl.OperationName.class);
-
-        if (opName != null) {
-			return opName.value();
-		}
-		return null;
-	}
-
-    private InputStream getWSDLStream(String pathToWSDL)
-        throws Exception {
-
-        /* Note, due to the architectural arrangement of the service control, the caller *must* close
-           this InputStream.  Otherwise, it will leak.
-         */
-
-        File f = null;
-		URL url = null;
-		try {
-			InputStream wsdlStream = null;
-			logger.debug("wsdl at:" + pathToWSDL);
-			if (pathToWSDL.startsWith("http://") || pathToWSDL.startsWith("file:/")) {
-				url = new URL(pathToWSDL);
-				wsdlStream = url.openStream();
-			}
-            else { // it is a local file name
-				wsdlStream = cbContext.getBeanContext().getResourceAsStream(pathToWSDL, null);
-
-				if (wsdlStream == null) {
-					logger.info("Failed to load the wsdl from context, will try classloader!");
-					wsdlStream = this.getClass().getClassLoader().getResourceAsStream(pathToWSDL);
-					if(null == wsdlStream) {
-						f = new File(pathToWSDL);
-						wsdlStream = new FileInputStream(f);
-					}
-				}
-			}
-			return wsdlStream;
-		} catch (MalformedURLException e) {
-			logger.error("ERROR: WSDL is not found, invalid URL  " + url);
-			throw e;
-		} catch (FileNotFoundException e) {
-			logger.error("ERROR: WSDL File not found: " + f.getCanonicalPath());
-			throw e;
-		} catch (IOException e) {
-			logger.error("ERROR: IO Exception in reading WSDL File" );
-			throw e;
-		}
-	}
-
-	private void configureEndPoint()
-        throws Exception {
-
-		if (null == getEndPoint()) {
-			ServiceControl.Location location =
-                (ServiceControl.Location)cbContext.getControlPropertySet(ServiceControl.Location.class);
-
-			if (location != null) {
-                assert location.urls() != null;
-                assert location.urls().length > 0;
-
-                setEndPoint(new URL(location.urls()[0]));
-			} else {
-				throw new RuntimeException("No Location annotation found.");
-			}
-		}
-	}
-
-	/**
-	 * @return Returns the endPoint.
-	 */
-	public URL getEndPoint() {
-		return endPoint;
-	}
-
-	/**
-	 * @param endPoint The endPoint to set.
-	 */
-	public void setEndPoint(URL endPoint) {
-		this.endPoint = endPoint;
-	}
-
-	/**
-	 * @return Returns the password.
-	 */
-	public String getPassword() {
-		return password;
-	}
-
-	/**
-	 * @param password The password to set.
-	 */
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-	/**
-	 * @return Returns the registrar.
-	 */
-	public TypeRegistrar getRegistrar() {
-		return registrar;
-	}
-
-	/**
-	 * @param registrar The registrar to set.
-	 */
-	public void setRegistrar(TypeRegistrar registrar) {
-		this.registrar = registrar;
-	}
-
-	/**
-	 * @return Returns the service.
-	 */
-	public Service getService() {
-		return service;
-	}
-
-	/**
-	 * @param service The service to set.
-	 */
-	public void setService(Service service) {
-		this.service = service;
-	}
-
-	/**
-	 * @return Returns the timeout.
-	 */
-	public int getTimeout() {
-		return timeout;
-	}
-
-	/**
-	 * @param timeout The timeout to set.
-	 */
-	public void setTimeout(int timeout) {
-		this.timeout = timeout;
-	}
-
-	/**
-	 * @return Returns the username.
-	 */
-	public String getUsername() {
-		return username;
-	}
-
-	/**
-	 * @param username The username to set.
-	 */
-	public void setUsername(String username) {
-		this.username = username;
-	}
-
-	/**
-	 * @return Returns the wsdlPort.
-	 */
-	public QName getWsdlPort() {
-		return wsdlPort;
-	}
-
-	/**
-	 * @param wsdlPort The wsdlPort to set.
-	 */
-	public void setWsdlPort(QName wsdlPort) {
-		this.wsdlPort = wsdlPort;
-	}
-
-	/**
-	 * 
-	 */
-	public void reset() {
-		endPoint = null;
-		wsdlPort = null;
-		username = null;
-		password = null;
-		timeout = 0;
-		HeaderHandler.reset();
-	}
-
-	/*
-	 * @see org.apache.beehive.controls.system.webservice.ServiceControl#getInputHeaders()
-	 * 
-	 * If there are any input header it is stored on my thread's Handler.
-	 */
-	public Element[] getInputHeaders() {
-		return HeaderHandler.getInHeaders();
-	}
-
-	/*
-	 * @see org.apache.beehive.controls.system.webservice.ServiceControl#setOutputHeaders(org.w3c.dom.Element[])
-	 */
-	public void setOutputHeaders(Element[] headers) {
-		HeaderHandler.setOutHeaders(headers);
-	}
-}
+/*
+ * Copyright 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.beehive.controls.system.webservice.jaxrpc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Iterator;
+
+import javax.jws.WebParam;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.Call;
+import javax.xml.rpc.ParameterMode;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.ServiceFactory;
+import javax.xml.rpc.encoding.TypeMapping;
+import javax.xml.rpc.handler.HandlerInfo;
+import javax.xml.rpc.holders.Holder;
+
+import org.apache.axis.constants.Use;
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Extensible;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.wsm.axis.databinding.SystemTypeLookupService;
+import org.apache.beehive.wsm.axis.registration.AxisTypeRegistrar;
+import org.apache.beehive.wsm.databinding.BindingLookupService;
+import org.apache.beehive.wsm.model.BeehiveWsMethodMetadata;
+import org.apache.beehive.wsm.model.BeehiveWsParameterMetadata;
+import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
+import org.apache.beehive.wsm.model.wsdl.XmlBeanWSDLProcessor;
+import org.apache.beehive.wsm.registration.TypeRegistrar;
+import org.apache.beehive.controls.system.webservice.ServiceControl;
+import org.apache.beehive.controls.system.webservice.utils.HolderUtils;
+import org.apache.beehive.wsm.wsdl.Utilities;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
+
+@ControlImplementation
+public class ServiceControlImpl
+    implements ServiceControl, Extensible, Serializable {
+
+    static Logger logger = Logger.getLogger(ServiceControlImpl.class);
+
+	@Context
+	public ControlBeanContext cbContext;
+
+	BindingLookupService lookupService = null;
+
+	TypeRegistrar registrar = null;
+
+	Service service = null;
+
+	QName portType;
+
+	BeehiveWsTypeMetadata mWSTM;
+
+	URL endPoint = null;
+
+	QName wsdlPort = null;
+
+	String username = null;
+
+	String password = null;
+
+	int timeout = 1000;
+
+	boolean initialized = false;
+
+	public ServiceControlImpl() {}
+
+	/**
+	 * @param method
+	 * @param args
+	 * @throws Exception
+	 */
+	public Object invoke(Method method, Object[] args)
+			throws NoSuchMethodException, Exception {
+
+        assert method != null;
+
+        logger.debug("invoke method: " + method.getName());
+		initialize();
+		String operationName = method.getName();
+		String alternateOperationName = getAlternateOperationName(method);
+		if (null != alternateOperationName)
+			operationName = alternateOperationName;
+
+        BeehiveWsMethodMetadata wmm = findMethodInOM(method, operationName);
+
+		Call call = buildCallObject(method, wmm);
+
+		Object[] callArgs = prepareArgsForSend(method, wmm, args);
+
+		Object res = call.invoke(callArgs);
+		fillHolders(method, wmm, call, args);
+
+		return res;
+	}
+
+	// create a new copy of the args where holders value have been extracted.
+	// ignore the out values
+	private Object[] prepareArgsForSend(Method method,
+                                        BeehiveWsMethodMetadata wmm,
+                                        Object[] args) {
+
+		ArrayList argsList = new ArrayList();
+		Class[] methodParameterTypes = method.getParameterTypes();
+		Iterator<BeehiveWsParameterMetadata> it = wmm.getParams().iterator();
+
+        // size of the param list must be the size of the args array
+		for (int i = 0; i < methodParameterTypes.length; i++) {
+			Class javaTypeFromClass = methodParameterTypes[i];
+			BeehiveWsParameterMetadata nxtParamMetaData = it.next();
+			if (nxtParamMetaData.getWpMode() == WebParam.Mode.OUT)
+				continue; // don't send OUT parameters.
+
+            if ((nxtParamMetaData.getWpMode() == WebParam.Mode.INOUT)
+                && Holder.class.isAssignableFrom(javaTypeFromClass)) {
+				try {
+					Holder holder = (Holder) args[i];
+					Field valueField = holder.getClass().getField("value");
+					argsList.add(valueField.get(holder));
+				} catch (Exception e) {
+					throw new RuntimeException(
+							"failed in getting holder value for: "
+									+ nxtParamMetaData.getWpName());
+				}
+
+			} else {
+				argsList.add(args[i]);
+			}
+		}
+		Object[] res = (Object[]) argsList.toArray(new Object[argsList.size()]);
+
+		return res;
+	}
+
+	// fill the hodlers in the argument array with the result of the call
+	private void fillHolders(Method method,
+                             BeehiveWsMethodMetadata wmm,
+                             Call call,
+                             Object[] args) {
+		Map outParam = call.getOutputParams();
+
+		if (outParam.isEmpty())
+			return;
+
+        for (Object nxtOutParamKey : outParam.keySet()) {
+			logger.info("Got outparam: " + nxtOutParamKey + " value: "
+                + outParam.get(nxtOutParamKey)
+                + " Stuff this into the holders");
+		}
+
+		Class[] methodParameterTypes = method.getParameterTypes();
+		Iterator<BeehiveWsParameterMetadata> it = wmm.getParams().iterator();
+        // size of the param list must be the size of the args array
+		for (int i = 0; i < methodParameterTypes.length; i++) {
+			Class javaTypeFromClass = methodParameterTypes[i];
+			BeehiveWsParameterMetadata nxtParamMetaData = it.next();
+
+			if ((nxtParamMetaData.getWpMode() == WebParam.Mode.INOUT || nxtParamMetaData
+                .getWpMode() == WebParam.Mode.OUT)
+                && Holder.class.isAssignableFrom(javaTypeFromClass)) {
+
+                try {
+					logger.info("Fill the holder object: " + nxtParamMetaData.getWpName());
+					Holder holder = (Holder) args[i];
+					Object value = null; // find the value, only check for
+					// localpart of the name, as the
+					// namespace
+					// may not be filled
+					boolean hasReturnValue = false;
+					for (Object nxtOutParamKey : outParam.keySet()) {
+						if (((QName) nxtOutParamKey).getLocalPart().equals(nxtParamMetaData.getWpName())) {
+							value = outParam.get(nxtOutParamKey);
+							hasReturnValue = true;
+							break;
+						}
+					}
+
+					if (hasReturnValue)
+						stuffHolderValue(holder, value);
+
+				} catch (Exception e) {
+					throw new RuntimeException("Failed in getting holder value for: " + nxtParamMetaData.getWpName());
+				}
+
+			} else {
+				continue;
+			}
+		}
+	}
+
+	private void stuffHolderValue(Holder holder, Object value)
+        throws NoSuchFieldException, IllegalAccessException {
+		HolderUtils.stuffHolderValue(holder, value);
+	}
+
+	/**
+	 * @param method
+	 * @param wmm
+	 * @return
+	 * @throws ServiceException
+	 * @throws Exception
+	 */
+	private Call buildCallObject(Method method, BeehiveWsMethodMetadata wmm)
+        throws ServiceException, Exception {
+
+		// TODO: Later cache the call objects for each method.
+
+		Call call = service.createCall();
+		if (getWsdlPort() != null) {
+			call.setPortTypeName(getWsdlPort());
+		}
+		if (getUsername() != null) {
+			call.setProperty(Call.USERNAME_PROPERTY, getUsername());
+		}
+		if (getPassword() != null) {
+			call.setProperty(Call.PASSWORD_PROPERTY, getPassword());
+		}
+		call.setOperationName(
+            new javax.xml.namespace.QName(mWSTM.getWsTargetNamespace(), wmm.getWmOperationName()));
+
+		// The target endpoint
+		logger.debug("endpoint: " + getEndPoint().toExternalForm());
+		call.setTargetEndpointAddress(getEndPoint().toExternalForm());
+		//       
+		// NO TImeout property in the JaxRPC
+		// int timeout = serviceControl.getTimeout();
+		// if (timeout != 0) {
+		// call.setTimeout(new Integer(timeout));
+		// }
+
+		// set style
+		SOAPBinding.Style omStyle = mWSTM.getSoapBinding().getStyle();
+		String style;
+		if (omStyle == SOAPBinding.Style.DOCUMENT) {
+			if (mWSTM.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.WRAPPED)
+				// wrapped implies document also!
+				style = "wrapped";
+			else
+				style = "document";
+		} else if (omStyle == SOAPBinding.Style.RPC)
+			style = "rpc";
+		else
+			throw new RuntimeException("Ivalid Binding style: " + omStyle);
+
+		logger.debug("Call style: " + style);
+		call.setProperty(Call.OPERATION_STYLE_PROPERTY, style);
+
+		if ("rpc".equals(style)	&& SOAPBinding.Use.LITERAL == mWSTM.getSoapBinding().getUse()) {
+			((org.apache.axis.client.Call) call).setOperationUse(Use.LITERAL);
+		}
+		// walk the argument meta data list, register type of parameters, add
+		// parameters to the
+		// call object
+		// TODO: Make sure there is nothing special that needs to be done about
+		// holder objects.
+		List<BeehiveWsParameterMetadata> omArgMetaDataList = new ArrayList<BeehiveWsParameterMetadata>();
+		omArgMetaDataList.addAll(wmm.getParams());
+
+		Class[] methodParameterTypes = method.getParameterTypes();
+		Type[] genericMethodParamTypes = method.getGenericParameterTypes();
+
+		if (omArgMetaDataList.size() != methodParameterTypes.length)
+			throw new RuntimeException("Object model and method definition don't match!");
+		List argsToSend = new ArrayList<Object>();
+		for (int i = 0; i < methodParameterTypes.length; i++) {
+
+			BeehiveWsParameterMetadata nxtArgMetaData = omArgMetaDataList.get(i);
+			Class javaTypeFromClass = methodParameterTypes[i];
+
+			// make sure the type is registered
+			ParameterMode mode;
+			WebParam.Mode omMode = nxtArgMetaData.getWpMode();
+			if (omMode == WebParam.Mode.IN)
+				mode = ParameterMode.IN;
+			else if (omMode == WebParam.Mode.OUT)
+				mode = ParameterMode.OUT;
+			else if (omMode == WebParam.Mode.INOUT) {
+				if (!Holder.class.isAssignableFrom(javaTypeFromClass))
+					throw new RuntimeException("Holder classes are required for the in/out parameters.");
+				mode = ParameterMode.INOUT;
+			} else
+				throw new RuntimeException("Invalid parameter mode: " + omMode);
+
+			// if mode is in or in/out and the type is holder then holder, get
+			// its value type
+			QName registeredTypeQName;
+
+			if ((mode == ParameterMode.OUT || mode == ParameterMode.INOUT)
+                && Holder.class.isAssignableFrom(javaTypeFromClass)) {
+				javaTypeFromClass = TypeRegistrar.getHoldersValueClass(genericMethodParamTypes[i]);
+			}
+
+            registeredTypeQName =
+                registrar.registerType(javaTypeFromClass,
+                    nxtArgMetaData.getXmlType(),
+                    mWSTM.getSoapBinding().getStyle(),
+                    mWSTM.getSoapBinding().getUse());
+
+            if (nxtArgMetaData.isWpHeader()) {
+				// TODO: addParameterAsHeader is Axis specific, later abstract
+				// out Axis from this implementation
+				logger.debug("Argument: " + nxtArgMetaData.getWpName()
+                    + " in method: " + method.getName()
+                    + " is send as soap header");
+				((org.apache.axis.client.Call) call).addParameterAsHeader(
+                    new QName(nxtArgMetaData.getWpTargetNamespace(),
+                        nxtArgMetaData.getWpName()),
+                    registeredTypeQName, javaTypeFromClass, mode, mode);
+            } else {
+                logger.debug("Argument: " + nxtArgMetaData.getWpName()
+                    + " in method: " + method.getName()
+                    + " is send in the soap body");
+                call.addParameter(nxtArgMetaData.getWpName(), registeredTypeQName, javaTypeFromClass, mode);
+			}
+		}
+		// register the return type
+		if (!wmm.isOneWay()) {
+			// QName xmlTypeFromWSDL = new QName(wmm.getWrTargetNamespace(),
+			// wmm.getWrName()); //wmm.getXmlReturnType();
+			Class javaTypeFromClass = method.getReturnType();
+            QName resultsRegisteredTypeQName = registrar.registerType(
+                javaTypeFromClass,
+                wmm.getXmlReturnType(),
+                mWSTM.getSoapBinding().getStyle(),
+                mWSTM.getSoapBinding().getUse());
+
+            call.setReturnType(resultsRegisteredTypeQName);
+//			if ("rpc".equals(style)) {
+//				((org.apache.axis.client.Call) call).setReturnQName(new QName("", "return"));   // Hack, may need this for google!  TBD, verify the need for this.
+//				((org.apache.axis.client.Call) call).setReturnClass(javaTypeFromClass);   // Hack, may need this for google!  TBD, verify the need for this.
+//			}
+		} else
+			call.setReturnType(registrar.getVoidType());
+		// AXIS dependecy... this is needed for the Handlers
+		call.setProperty(org.apache.axis.client.Call.JAXRPC_PORTTYPE_NAME,
+				portType);
+		return call;
+	}
+
+	/**
+	 * @param method
+	 * @param operationName
+	 * @throws Exception
+	 */
+	private BeehiveWsMethodMetadata findMethodInOM(Method method, String operationName)
+        throws NoSuchMethodException, Exception {
+
+		// the obejct model doesn't store holders, rather the underlying
+		// types, so to get the method
+		// we need to get the underlying types. After the loop above the
+		// paramTypes have the underlying types
+		// for any holders in the arg list.
+
+		Type[] genericParamTypes = method.getGenericParameterTypes();
+		Class[] paramTypes = method.getParameterTypes();
+		for (int i = 0; i < paramTypes.length; i++) {
+			if (Holder.class.isAssignableFrom(paramTypes[i])) {
+				paramTypes[i] = TypeRegistrar.getHoldersValueClass(genericParamTypes[i]);
+			}
+		}
+		BeehiveWsMethodMetadata wmm = mWSTM.getMethod(operationName, paramTypes);
+		if (wmm == null) {
+			StringBuffer sb = new StringBuffer("No Jsr181MethodMetadata found for " + operationName + '(');
+			boolean first = true;
+			for (Class cls : paramTypes) {
+				if (first) {
+					first = false;
+				} else {
+					sb.append(',');
+				}
+				sb.append(cls.getName());
+			}
+			sb.append(')');
+			throw new NoSuchMethodException(sb.toString());
+
+		}
+		return wmm;
+	}
+
+	private synchronized void initialize()
+        throws Exception {
+
+        if (initialized)
+			return;
+
+        XmlBeanWSDLProcessor wsdlProcessor = null;
+
+        lookupService = new SystemTypeLookupService();
+        wsdlProcessor = new XmlBeanWSDLProcessor(parseWSDL(), lookupService);
+
+        assert wsdlProcessor != null : "Did not find a valid WSDL processor";
+        mWSTM = wsdlProcessor.getObjectModel();
+
+        
+        ServiceFactory factory = ServiceFactory.newInstance();
+		service = factory.createService(wsdlProcessor.getServiceName());
+
+		HandlerInfo hInfo = new HandlerInfo();
+		hInfo.setHandlerClass(HeaderHandler.class);
+
+		TypeMapping tm = service.getTypeMappingRegistry().getDefaultTypeMapping();
+		registrar = new AxisTypeRegistrar((org.apache.axis.encoding.TypeMapping)tm, lookupService);
+
+        configureEndPoint();
+
+        // porttype
+        portType = new QName(mWSTM.getWsTargetNamespace(), mWSTM.getWsName());
+
+		// name
+		service.getHandlerRegistry().getHandlerChain(portType).add(hInfo);
+
+		initialized = true;
+
+	}
+
+	private String getAlternateOperationName(Method method) {
+
+		ServiceControl.OperationName opName =
+            cbContext.getMethodPropertySet(method, ServiceControl.OperationName.class);
+
+        if (opName != null) {
+			return opName.value();
+		}
+		return null;
+	}
+
+    private DefinitionsDocument parseWSDL()
+        throws Exception {
+
+        File f = null;
+        URL url = null;
+        InputStream wsdlStream = null;
+
+		try {
+            ServiceControl.WSDL wsdl = (ServiceControl.WSDL)cbContext.getControlPropertySet(ServiceControl.WSDL.class);
+
+            assert(wsdl != null) : "The control is mising the required @WSDL annotations";
+            assert(wsdl.path() != null) : "The control is missing the required path attribute for the @WSDL annotations";
+              
+            if(wsdl == null)
+                throw new RuntimeException("No WSDL annotation found.");
+
+            logger.debug("read wsdl from: " + wsdl.path());
+			
+			if ( wsdl.path().startsWith("http://") ||  wsdl.path().startsWith("file:/")) {
+				url = new URL( wsdl.path());
+				wsdlStream = url.openStream();
+			}
+            else { // it is a local file name
+				wsdlStream = cbContext.getBeanContext().getResourceAsStream( wsdl.path(), null);
+
+				if (wsdlStream == null) {
+					logger.info("Failed to load the wsdl from context, will try classloader!");
+					wsdlStream = this.getClass().getClassLoader().getResourceAsStream(wsdl.path());
+
+                    /*
+                        todo: why does this try to load from a hard file path?
+                             this value is generally unstable in a running server
+                     */
+                    if(null == wsdlStream) {
+						f = new File(wsdl.path());
+						wsdlStream = new FileInputStream(f);
+					}
+				}
+			}
+			return  Utilities.parseWSDL(wsdlStream);
+		} catch (MalformedURLException e) {
+			logger.error("ERROR: WSDL is not found, invalid URL  " + url);
+			throw e;
+		} catch (FileNotFoundException e) {
+			logger.error("ERROR: WSDL File not found: " + f.getCanonicalPath());
+			throw e;
+		} catch (IOException e) {
+			logger.error("ERROR: IO Exception in reading WSDL File" );
+			throw e;
+		} finally {
+            if(wsdlStream != null)
+                wsdlStream.close();
+        }
+	}
+
+	private void configureEndPoint()
+        throws Exception {
+
+		if (null == getEndPoint()) {
+			ServiceControl.Location location =
+                (ServiceControl.Location)cbContext.getControlPropertySet(ServiceControl.Location.class);
+
+			if (location != null) {
+                assert location.urls() != null;
+                assert location.urls().length > 0;
+
+                setEndPoint(new URL(location.urls()[0]));
+			} else {
+				throw new RuntimeException("No Location annotation found.");
+			}
+		}
+	}
+
+	/**
+	 * @return Returns the endPoint.
+	 */
+	public URL getEndPoint() {
+		return endPoint;
+	}
+
+	/**
+	 * @param endPoint The endPoint to set.
+	 */
+	public void setEndPoint(URL endPoint) {
+		this.endPoint = endPoint;
+	}
+
+	/**
+	 * @return Returns the password.
+	 */
+	public String getPassword() {
+		return password;
+	}
+
+	/**
+	 * @param password The password to set.
+	 */
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	/**
+	 * @return Returns the registrar.
+	 */
+	public TypeRegistrar getRegistrar() {
+		return registrar;
+	}
+
+	/**
+	 * @param registrar The registrar to set.
+	 */
+	public void setRegistrar(TypeRegistrar registrar) {
+		this.registrar = registrar;
+	}
+
+	/**
+	 * @return Returns the service.
+	 */
+	public Service getService() {
+		return service;
+	}
+
+	/**
+	 * @param service The service to set.
+	 */
+	public void setService(Service service) {
+		this.service = service;
+	}
+
+	/**
+	 * @return Returns the timeout.
+	 */
+	public int getTimeout() {
+		return timeout;
+	}
+
+	/**
+	 * @param timeout The timeout to set.
+	 */
+	public void setTimeout(int timeout) {
+		this.timeout = timeout;
+	}
+
+	/**
+	 * @return Returns the username.
+	 */
+	public String getUsername() {
+		return username;
+	}
+
+	/**
+	 * @param username The username to set.
+	 */
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	/**
+	 * @return Returns the wsdlPort.
+	 */
+	public QName getWsdlPort() {
+		return wsdlPort;
+	}
+
+	/**
+	 * @param wsdlPort The wsdlPort to set.
+	 */
+	public void setWsdlPort(QName wsdlPort) {
+		this.wsdlPort = wsdlPort;
+	}
+
+	/**
+	 * 
+	 */
+	public void reset() {
+		endPoint = null;
+		wsdlPort = null;
+		username = null;
+		password = null;
+		timeout = 0;
+		HeaderHandler.reset();
+	}
+
+	/*
+	 * @see org.apache.beehive.controls.system.webservice.ServiceControl#getInputHeaders()
+	 * 
+	 * If there are any input header it is stored on my thread's Handler.
+	 */
+	public Element[] getInputHeaders() {
+		return HeaderHandler.getInHeaders();
+	}
+
+	/*
+	 * @see org.apache.beehive.controls.system.webservice.ServiceControl#setOutputHeaders(org.w3c.dom.Element[])
+	 */
+	public void setOutputHeaders(Element[] headers) {
+		HeaderHandler.setOutHeaders(headers);
+	}
+}

Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java?rev=190648&r1=190647&r2=190648&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java Tue Jun 14 12:11:11 2005
@@ -33,6 +33,7 @@
 import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
 import org.apache.beehive.wsm.model.jsr181.Jsr181ObjectModelStore;
 import org.apache.beehive.wsm.model.wsdl.XmlBeanWSDLProcessor;
+import org.apache.beehive.wsm.wsdl.Utilities;
 
 /**
  */
@@ -52,8 +53,9 @@
         InputStream is = null;
         try {
             is = Thread.currentThread().getContextClassLoader().getResourceAsStream("schemas/starwars.wsdl");
-            XmlBeanWSDLProcessor xbwp = new XmlBeanWSDLProcessor(is);
-            clientModel = xbwp.getObjectModel(new SystemTypeLookupService());
+            SystemTypeLookupService lookupService = new SystemTypeLookupService();
+            XmlBeanWSDLProcessor xbwp = new XmlBeanWSDLProcessor(Utilities.parseWSDL(is), lookupService);
+            clientModel = xbwp.getObjectModel();
         }
         finally {
             if(is != null)
@@ -114,10 +116,8 @@
 
         assertEquals(server.getWmOperationName(), client.getWmOperationName());
         assertEquals(server.isOneWay(), client.isOneWay());
-        // FIXME jcolwell@bea.com 2004-Nov-10 -- see FIXME below
         assertEquals(server.getJavaReturnType(), client.getJavaReturnType());
-        assertEquals(server.getWrTargetNamespace(),
-                     client.getWrTargetNamespace());
+        assertEquals(server.getWrTargetNamespace(), client.getWrTargetNamespace());
         assertEquals(server.getWrName(), client.getWrName());
     }
 
@@ -134,8 +134,7 @@
             assertEquals(srvParam.getJavaType(), clParam.getJavaType());
             assertEquals(srvParam.getWpMode(), clParam.getWpMode());
             assertEquals(srvParam.getWpName(), clParam.getWpName());
-            assertEquals(srvParam.getWpTargetNamespace(),
-                         clParam.getWpTargetNamespace());
+            assertEquals(srvParam.getWpTargetNamespace(), clParam.getWpTargetNamespace());
             assertEquals(srvParam.isWpHeader(),
                          clParam.isWpHeader());
         }

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/tools/Wsdl2AJava.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/tools/Wsdl2AJava.java?rev=190648&r1=190647&r2=190648&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/tools/Wsdl2AJava.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/tools/Wsdl2AJava.java Tue Jun 14 12:11:11 2005
@@ -1,56 +1,72 @@
-package org.apache.beehive.wsm.axis.tools;
-/*
- * Wsld2AJava.java
- * 
- * Copyright 2001-2004 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 java.io.InputStream;
-
-import org.apache.beehive.wsm.axis.databinding.SystemTypeLookupService;
-import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
-import org.apache.beehive.wsm.model.wsdl.XmlBeanWSDLProcessor;
-import org.apache.beehive.wsm.wsdl.AbstractWsdl2AJava;
-
-public class Wsdl2AJava
-    extends AbstractWsdl2AJava {
-
-    public Wsdl2AJava()
-        throws Exception {
-        super();
-    }
-
-    protected BeehiveWsTypeMetadata getWSObjectModel(InputStream wsdl)
-        throws Exception {
-        XmlBeanWSDLProcessor processor = new XmlBeanWSDLProcessor(wsdl);
-        SystemTypeLookupService lookupService = new SystemTypeLookupService();
-        return processor.getObjectModel(lookupService);
-    }
-
-    public static int main(String args[])
-        throws Exception {
-
-        if(args.length != 2) {
-            System.out.println("Usage:  Wsdl2AJava <wsdlFileName> <base source dir>");
-            return -1;
-        }
-
-        Wsdl2AJava processor = new Wsdl2AJava();
-        processor.init();
-        processor.generateAnnotatedJavaFromWSDL(args[0], args[1]);
-        return 0;
-    }
-}
+/*
+ * Copyright 2001-2004 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.beehive.wsm.axis.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.beehive.wsm.axis.databinding.SystemTypeLookupService;
+import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
+import org.apache.beehive.wsm.model.wsdl.XmlBeanWSDLProcessor;
+import org.apache.beehive.wsm.wsdl.Model2AJava;
+import org.apache.beehive.wsm.wsdl.Utilities;
+import org.apache.xmlbeans.XmlException;
+
+public class Wsdl2AJava {
+
+    public static int main(String args[]) {
+
+        if(args.length != 2) {
+            System.out.println("Usage:  Wsdl2AJava <wsdlFileName> <base source dir>");
+            return -1;
+        }
+        
+        File baseDir = new File(args[1]);
+        if(!baseDir.exists())
+            baseDir.mkdirs();
+        
+        SystemTypeLookupService lookupService = new SystemTypeLookupService();
+        XmlBeanWSDLProcessor processor;
+        try {
+            processor = new XmlBeanWSDLProcessor(Utilities.parseWSDL(args[0]), lookupService);
+        } catch (MalformedURLException e) {
+            System.out.println("Unable to find WSDL with URL '" + args[0] + "'.  Cause: " + e.getMessage());
+            e.printStackTrace();
+            return -1;
+        } catch (XmlException e) {
+            System.out.println("Failed with an invalid WSDL at '" + args[0] + "'.  Cause: " + e);
+            e.printStackTrace();
+            return -1;
+        } catch (IOException e) {
+            System.out.println("Failed with an IOException generating the Annotated JWS.  Cause: " + e);
+            e.printStackTrace();
+            return -1;
+        }
+
+        BeehiveWsTypeMetadata om;
+        try {
+            om = processor.getObjectModel();
+            Model2AJava.generateAnnotatedJavaFromOM(om, baseDir);
+       } catch (Exception e) {
+           System.out.println("Error:  Failed in generating the Annotated JWS.  Cause: " + e);
+           e.printStackTrace();
+           return -1;
+        }
+        return 0;
+    }
+}

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java?rev=190648&r1=190647&r2=190648&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java Tue Jun 14 12:11:11 2005
@@ -1,9 +1,6 @@
 /*
- * XmlBeanWSDLProcessor.java
- * 
  * Copyright 2001-2004 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
@@ -18,12 +15,7 @@
  */
 package org.apache.beehive.wsm.model.wsdl;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
 import java.lang.reflect.Array;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -42,7 +34,6 @@
 import org.apache.beehive.wsm.model.jsr181.Jsr181TypeMetadataImpl;
 import org.apache.beehive.wsm.model.jsr181.SOAPBindingInfo;
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.xb.xsdschema.ComplexType;
 import org.apache.xmlbeans.impl.xb.xsdschema.Element;
@@ -65,14 +56,10 @@
 import org.xmlsoap.schemas.wsdl.soap.UseChoice;
 
 /**
- * ****************************************************************************
  * An Implementation of WSDLProcessor that uses XmlBeans to convert the WSDL
  * into the WSM Object Model.
- *
- * @author Jonathan Colwell
  */
 public class XmlBeanWSDLProcessor {
-    private BindingLookupService lookupService;
 
     public static final String TRANSPORT = "http://schemas.xmlsoap.org/soap/http";
 
@@ -83,16 +70,24 @@
     public static final String WSDLSOAPNS = "http://schemas.xmlsoap.org/wsdl/soap/";
 
     private DefinitionsDocument defDoc;
+    private BindingLookupService lookupService;
+
+    /* declared to prevent no-args construction */
+    private XmlBeanWSDLProcessor() {
+    }
+
+    public XmlBeanWSDLProcessor(DefinitionsDocument defDoc, BindingLookupService lookupService) {
+        super();
+        this.defDoc = defDoc;
+        this.lookupService = lookupService;
+    }
 
     public QName getServiceName() {
         TService[] services = defDoc.getDefinitions().getServiceArray();
         return new QName(services[0].getName());
     }
 
-    public BeehiveWsTypeMetadata getObjectModel(BindingLookupService lookupService)
-        throws Exception {
-
-        this.lookupService = lookupService;
+    public BeehiveWsTypeMetadata getObjectModel() throws Exception {
 
         BeehiveWsTypeMetadata wsm = new Jsr181TypeMetadataImpl();
         Map<String, BeehiveWsMethodMetadata> methodMap = new HashMap<String, BeehiveWsMethodMetadata>();
@@ -127,7 +122,6 @@
             }
 
             for(TOperation op : operations) {
-
                 processTOperation(op, wsm, methodMap, messageMap, tBind, types);
             }
         }
@@ -175,8 +169,7 @@
             returnType = Void.TYPE;
             returnXMLType = null;
             if(paraMeta.length > 1) {
-                outParamMap = new HashMap<String, BeehiveWsParameterMetadata>(
-                    paraMeta.length);
+                outParamMap = new HashMap<String, BeehiveWsParameterMetadata>(paraMeta.length);
                 boolean returnIsSet = false;
                 for(BeehiveWsParameterMetadata cpm : paraMeta) {
                     outParamMap.put(cpm.getWpName(), cpm);
@@ -563,31 +556,6 @@
         }
     }
 
-    public static DefinitionsDocument parseWSDL(String wsdlLocation)
-        throws XmlException, IOException, MalformedURLException {
-        if(wsdlLocation.indexOf("://") > 2) {
-            return parseWSDL(new URL(wsdlLocation));
-        }
-        else {
-            return parseWSDL(new File(wsdlLocation));
-        }
-    }
-
-    public static DefinitionsDocument parseWSDL(File wsdlFile)
-        throws IOException, XmlException {
-        return DefinitionsDocument.Factory.parse(wsdlFile);
-    }
-
-    public static DefinitionsDocument parseWSDL(URL wsdlURL)
-        throws IOException, XmlException {
-        return DefinitionsDocument.Factory.parse(wsdlURL);
-    }
-
-    public static DefinitionsDocument parseWSDL(InputStream wsdlStream)
-        throws IOException, XmlException {
-        return DefinitionsDocument.Factory.parse(wsdlStream);
-    }
-
     public static org.xmlsoap.schemas.wsdl.soap.TOperation[] getSOAPOperations(TBindingOperation bo)
         throws IllegalAccessException, NoSuchFieldException {
         return selectChildren(bo, org.xmlsoap.schemas.wsdl.soap.TOperation.class);
@@ -623,18 +591,16 @@
         return res;
     }
 
-
-    public static org.xmlsoap.schemas.wsdl.soap.TAddress[] getSOAPAddress(
-        TPort port)
+    public static org.xmlsoap.schemas.wsdl.soap.TAddress[] getSOAPAddress(TPort port)
         throws IllegalAccessException, NoSuchFieldException {
         return selectChildren(port, org.xmlsoap.schemas.wsdl.soap.TAddress.class);
     }
 
-    private static <T extends XmlObject> T[] selectChildren(XmlObject parent,
-                                                            Class<T> childClass)
+    private static <T extends XmlObject> T[] selectChildren(XmlObject parent, Class<T> childClass)
         throws IllegalAccessException, NoSuchFieldException {
         // retrieve the SchemaType from the static type field
-        if(parent == null) return null;
+        if(parent == null)
+            return null;
         SchemaType st = (SchemaType)childClass.getField("type").get(null);
         SchemaType originalType = null;
         QName element;
@@ -651,35 +617,16 @@
         else {
             element = st.getName();
         }
-        /*
-        * System.out.println("Selecting children " + element +" of class " +
-        * st.getJavaClass());
-        */
         XmlObject[] kids = parent.selectChildren(element);
 
         T[] castKids = (T[])Array.newInstance(childClass, kids.length);
         for(int j = 0; j < castKids.length; j++) {
 
             if(!st.getJavaClass().isAssignableFrom(kids[j].getClass())) {
-                // System.out.println("before typechange " +
-                // kids[j].getClass());
                 kids[j] = kids[j].changeType(st);
-                // System.out.println("after typechange " + kids[j].getClass());
-            }
-            else {
-                // System.out.println("no typechange needed");
             }
             castKids[j] = childClass.cast(kids[j]);
         }
         return castKids;
-    }
-
-    public XmlBeanWSDLProcessor(InputStream wsdlStream)
-        throws IOException, XmlException {
-        super();
-        this.defDoc = parseWSDL(wsdlStream);
-    }
-
-    private XmlBeanWSDLProcessor() {
     }
 }