ws-ews-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guilla...@apache.org
Subject svn commit: r230793 [7/12] - in /webservices/ews/trunk/ws4j2ee: ./ docs/ docs/images/ docs/src/ samples/ samples/clients/ samples/ejb/ samples/ejb/bookquote/ samples/ejb/bookquote/META-INF/ samples/ejb/bookquote/com/ samples/ejb/bookquote/com/jwsbook/ ...
Date Mon, 08 Aug 2005 12:42:47 GMT
Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/DomEJBDDParser.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/DomEJBDDParser.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/DomEJBDDParser.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/DomEJBDDParser.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,87 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.parsers;
+
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.impl.EJBDDContextImpl;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+
+/**
+ * Parse the ejb-jar.xml file and get the name of the EJB
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class DomEJBDDParser {
+    private J2EEWebServiceContext j2eewscontext;
+    private String ejbName = null;
+    private EJBContext context;
+
+    public DomEJBDDParser(J2EEWebServiceContext j2eewscontext) {
+        this.j2eewscontext = j2eewscontext;
+    }
+
+    public void parse(InputStream inputStream) throws GenerationFault {
+        try {
+            Document doc = Utils.createDocument(inputStream);
+            Element root = doc.getDocumentElement();
+            NodeList beaneles = root.getElementsByTagName("enterprise-beans");
+            if (beaneles.getLength() > 0) {
+                Element beanele = (Element) beaneles.item(0);
+                NodeList sessionList = beanele.getElementsByTagName("session");
+                if (sessionList.getLength() > 0) {
+                    Element session = (Element) sessionList.item(0);
+                    String ejbName = Utils.getElementValue(session.getElementsByTagName("ejb-name"));
+                    String home = Utils.getElementValue(session.getElementsByTagName("home"));
+                    String remote = Utils.getElementValue(session.getElementsByTagName("remote"));
+                    String ejbClass = Utils.getElementValue(session.getElementsByTagName("ejb-class"));
+                    context = new EJBDDContextImpl(ejbName,
+                            ejbClass,
+                            home, remote, null, null);
+                } else {
+                    throw new GenerationFault("session tag not found");
+                }
+            } else {
+                throw new GenerationFault("enterprise-beans tag not found");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    /**
+     * @return
+     */
+    public EJBContext getContext() {
+        return context;
+    }
+
+    /**
+     * @param context
+     */
+    public void setContext(EJBContext context) {
+        this.context = context;
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFactory.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFactory.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFactory.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFactory.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,39 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.parsers;
+
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
+import org.apache.ws.ews.context.webservices.client.ServiceReferenceContext;
+import org.apache.ws.ews.context.webservices.server.WSCFContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+
+import java.io.InputStream;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public interface ParserFactory {
+    public ServiceReferenceContext parseServiceReferance(J2EEWebServiceContext context, InputStream inputStream) throws GenerationFault;
+
+    public WSCFContext parseWSCF(J2EEWebServiceContext context, InputStream inputStream) throws GenerationFault;
+
+    public WebContext parseWebDD(J2EEWebServiceContext context, InputStream inputStream) throws GenerationFault;
+
+    public EJBContext parseEJBDDContext(J2EEWebServiceContext context, InputStream inputStream) throws GenerationFault;
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFault.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFault.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFault.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ParserFault.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,80 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.parsers;
+
+/**
+ * <p>This denotes the Exception occured at the code genaration.
+ * There is a isssue of wrapping the Exception such that JDK1.3 compatibility.
+ * This code write same way as it was done at the RemoteException.</p>
+ */
+public class ParserFault extends Exception {
+    /**
+     * Nested Exception to hold wrapped exception.
+     * <p>This field predates the general-purpose exception chaining facility.
+     * The {@link Throwable#getCause()} method is now the preferred means of
+     * obtaining this information.</p>
+     *
+     * @serial
+     */
+    public Throwable detail;
+
+    public ParserFault(Exception e) {
+        initCause(null);  // Disallow subsequent initCause
+        detail = e;
+    }
+
+    public ParserFault(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a <code>Exception</code> with the specified
+     * detail message and nested exception.
+     *
+     * @param s  the detail message
+     * @param ex the nested exception
+     */
+    public ParserFault(String s, Throwable ex) {
+        super(s);
+        initCause(null);  // Disallow subsequent initCause
+        detail = ex;
+    }
+
+    /**
+     * Returns the detail message, including the message from the nested
+     * exception if there is one.
+     *
+     * @return	the detail message, including nested exception message if any
+     */
+    public String getMessage() {
+        if (detail == null) {
+            return super.getMessage();
+        } else {
+            return super.getMessage() + "; nested exception is: \n\t" +
+                    detail.toString();
+        }
+    }
+
+    /**
+     * Returns the wrapped exception (the <i>cause</i>).
+     *
+     * @return the wrapped exception, which may be <tt>null</tt>.
+     */
+    public Throwable getCause() {
+        return detail;
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ServiceReferanceParser.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ServiceReferanceParser.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ServiceReferanceParser.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/ServiceReferanceParser.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,108 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.parsers;
+
+import org.apache.geronimo.ews.ws4j2ee.context.webservices.client.impl.ServiceReferenceImpl;
+import org.apache.ws.ews.context.webservices.client.ServiceReferenceContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+
+/**
+ * <service-ref>
+ * <service-ref-name>service/Joe</service-ref-name>
+ * <service-interface>javax.xml.rpc.Service</service-interface>
+ * <wsdl-file>WEB-INF/joe.wsdl</wsdl-file>
+ * <jaxrpc-mapping-file>WEB-INF/joe.xml</jaxrpc-mapping-file>
+ * <service-qname></service-qname>
+ * <port-component-ref>
+ * <service-endpoint-interface>sample.Joe</service-endpoint-interface>
+ * <port-component-link>JoePort</port-component-link>
+ * </port-component-ref>
+ * <handler>
+ * <handler-name></handler-name>
+ * <handler-class></handler-class>
+ * </handler>
+ * </service-ref>
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class ServiceReferanceParser {
+    private ServiceReferenceContext ref;
+
+    public ServiceReferanceParser(InputStream inputStream) throws GenerationFault {
+        try {
+            Document doc = Utils.createDocument(inputStream);
+            Element root = doc.getDocumentElement();
+            Element serviceref = findServiceReferance(root);
+            if (serviceref != null)
+                parse(serviceref);
+            else
+                throw new GenerationFault("No service Referance in the file");
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    /**
+     * find the service-ref element from the xml file.
+     *
+     * @param ele
+     * @return
+     */
+    public Element findServiceReferance(Element ele) {
+        if ("service-ref".equals((ele).getLocalName())) {
+            return ele;
+        } else {
+            NodeList nodes = ele.getChildNodes();
+            for (int i = 0; i < nodes.getLength(); i++) {
+                Node node = nodes.item(i);
+                if (node instanceof Element) {
+                    return findServiceReferance((Element) node);
+                }
+            }
+            return null;
+        }
+    }
+
+    public ServiceReferanceParser(Element refEle) {
+        parse(refEle);
+    }
+
+    public void parse(Element refEle) {
+        ref = new ServiceReferenceImpl();
+        Element root = refEle;
+        ref.setServiceRefName(Utils.getElementValue(root.getElementsByTagName("service-ref-name")));
+        ref.setServiceInterface(Utils.getElementValue(root.getElementsByTagName("service-interface")));
+        ref.setWsdlFile(Utils.getElementValue(root.getElementsByTagName("wsdl-file")));
+        ref.setJaxrpcMappingFile(Utils.getElementValue(root.getElementsByTagName("jaxrpc-mapping-file")));
+    }
+
+    /**
+     * @return
+     */
+    public ServiceReferenceContext getRef() {
+        return ref;
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/WebDDParser.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/WebDDParser.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/WebDDParser.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/WebDDParser.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,104 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.parsers;
+
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.impl.WebDDContextImpl;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+
+/**
+ * &lt;web-app&gt; .....
+ * &lt;servlet&gt;
+ * &lt;servlet-name&gt;AxisServlet&lt;/servlet-name&gt;
+ * &lt;display-name&gt;Apache-Axis Servlet&lt;/display-name&gt;
+ * &lt;servlet-class&gt;
+ * org.apache.axis.transport.http.AxisServlet
+ * &lt;/servlet-class&gt;
+ * &lt;/servlet&gt;
+ * ...
+ * &lt;/web-app&gt;
+ * Parse the web,xl file and get the servlet class corresponds to the given servlet
+ *
+ * @author hemapani
+ */
+public class WebDDParser {
+    private J2EEWebServiceContext j2eewscontext;
+    private WebContext context;
+    private String servletClass = null;
+    private String servletName = null;
+
+    public WebDDParser(J2EEWebServiceContext j2eewscontext) {
+        this.j2eewscontext = j2eewscontext;
+    }
+
+    public void parse(InputStream inputStream) throws GenerationFault {
+        Document doc = Utils.createDocument(inputStream);
+        Element root = doc.getDocumentElement();
+        NodeList sevlele = root.getElementsByTagName("servlet");
+        
+        String j2eeLink = j2eewscontext.getMiscInfo().getJ2eeComponetLink();
+        int count = 0;
+        while (count < sevlele.getLength()) {
+            Element serv = (Element) sevlele.item(count);
+            servletName = Utils.getElementValue(serv.getElementsByTagName("servlet-name"));
+            if (servletName.equals(j2eeLink)) {
+                servletClass = Utils.getElementValue(serv.getElementsByTagName("servlet-class"));
+                context = new WebDDContextImpl(servletClass, servletName);
+                return;
+            }
+            count++;
+        }
+        throw new UnrecoverableGenerationFault("J2EE link not found");
+    }
+
+    /**
+     * @return
+     */
+    public String getServletClass() {
+        return servletClass;
+    }
+
+    /**
+     * @param string
+     */
+    public void setServletClass(String string) {
+        servletClass = string;
+    }
+
+    /**
+     * @return
+     */
+    public WebContext getContext() {
+        return context;
+    }
+
+    /**
+     * @param context
+     */
+    public void setContext(WebContext context) {
+        this.context = context;
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/XMLBeansEJBDDParser.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/XMLBeansEJBDDParser.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/XMLBeansEJBDDParser.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/XMLBeansEJBDDParser.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,91 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.parsers;
+
+import noNamespace.EjbJarDocument;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.impl.EJBDDContextImpl;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+
+/**
+ * Parse the ejb-jar.xml file and get the name of the EJB
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class XMLBeansEJBDDParser {
+    private J2EEWebServiceContext j2eewscontext;
+    private String ejbName = null;
+    private EJBContext context;
+
+    public XMLBeansEJBDDParser(J2EEWebServiceContext j2eewscontext) {
+        this.j2eewscontext = j2eewscontext;
+    }
+
+    public void parse(InputStream inputStream) throws GenerationFault {
+        try {
+            EjbJarDocument ejbjarDoc = EjbJarDocument.Factory.parse(inputStream);
+            EjbJarDocument.EjbJar ejbjar = ejbjarDoc.getEjbJar();
+            ejbjar.selectPath("ejb-jar/enterprise-beans/session/home");
+            Document doc = Utils.createDocument(inputStream);
+            Element root = doc.getDocumentElement();
+            NodeList beaneles = root.getElementsByTagName("enterprise-beans");
+            if (beaneles.getLength() > 0) {
+                Element beanele = (Element) beaneles.item(0);
+                NodeList sessionList = beanele.getElementsByTagName("session");
+                if (sessionList.getLength() > 0) {
+                    Element session = (Element) sessionList.item(0);
+                    String ejbName = Utils.getElementValue(session.getElementsByTagName("ejb-name"));
+                    String home = Utils.getElementValue(session.getElementsByTagName("home"));
+                    String remote = Utils.getElementValue(session.getElementsByTagName("remote"));
+                    String ejbClass = Utils.getElementValue(session.getElementsByTagName("ejb-class"));
+                    context = new EJBDDContextImpl(ejbName,
+                            ejbClass,
+                            home, remote, null, null);
+                } else {
+                    throw new GenerationFault("session tag not found");
+                }
+            } else {
+                throw new GenerationFault("enterprise-beans tag not found");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    /**
+     * @return
+     */
+    public EJBContext getContext() {
+        return context;
+    }
+
+    /**
+     * @param context
+     */
+    public void setContext(EJBContext context) {
+        this.context = context;
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/impl/ParserFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/impl/ParserFactoryImpl.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/impl/ParserFactoryImpl.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/parsers/impl/ParserFactoryImpl.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,84 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.parsers.impl;
+
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
+import org.apache.ws.ews.context.webservices.client.ServiceReferenceContext;
+import org.apache.ws.ews.context.webservices.server.impl.WSCFException;
+import org.apache.ws.ews.context.webservices.server.WSCFContext;
+import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.impl.xmlbeans.WSCFContextImpl;
+import org.apache.geronimo.ews.ws4j2ee.parsers.DomEJBDDParser;
+import org.apache.geronimo.ews.ws4j2ee.parsers.ParserFactory;
+import org.apache.geronimo.ews.ws4j2ee.parsers.ServiceReferanceParser;
+import org.apache.geronimo.ews.ws4j2ee.parsers.WebDDParser;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+
+import java.io.InputStream;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class ParserFactoryImpl implements ParserFactory {
+
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.ews.ws4j2ee.parsers.ParserFactory#parseEJBDDContext(org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext, java.io.InputStream)
+     */
+    public EJBContext parseEJBDDContext(J2EEWebServiceContext context,
+                                        InputStream inputStream)
+            throws GenerationFault {
+        DomEJBDDParser ejbDDparser = new DomEJBDDParser(context);
+        ejbDDparser.parse(inputStream);
+        return ejbDDparser.getContext();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.ews.ws4j2ee.parsers.ParserFactory#parseServiceReferance(org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext, java.io.InputStream)
+     */
+    public ServiceReferenceContext parseServiceReferance(J2EEWebServiceContext context,
+                                                         InputStream inputStream)
+            throws GenerationFault {
+        ServiceReferanceParser parser = new ServiceReferanceParser(inputStream);
+        return parser.getRef();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.ews.ws4j2ee.parsers.ParserFactory#parseWebDD(org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext, java.io.InputStream)
+     */
+    public WebContext parseWebDD(J2EEWebServiceContext context,
+                                 InputStream inputStream)
+            throws GenerationFault {
+        WebDDParser parser = new WebDDParser(context);
+        parser.parse(inputStream);
+        return parser.getContext();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.ews.ws4j2ee.parsers.ParserFactory#parseWSCF(org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext, java.io.InputStream)
+     */
+    public WSCFContext parseWSCF(J2EEWebServiceContext context,
+                                 InputStream inputStream)
+            throws GenerationFault {
+        try {
+            return new WSCFContextImpl(inputStream, context);
+        } catch (WSCFException e) {
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/AbstractWriter.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/AbstractWriter.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/AbstractWriter.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/AbstractWriter.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,99 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * <p>This is a conveniance class to wite the Writers</p>
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+
+public abstract class AbstractWriter implements Writer {
+    /**
+     * <p>this parameter act as a mediator, It contains all the information
+     * this will be passed to the each writer. This will make sure
+     * even if the information that should passed around it will keep
+     * method signatures intact.</p>
+     */
+    protected static Log log =
+            LogFactory.getLog(AbstractWriter.class.getName());
+    protected J2EEWebServiceContext j2eewscontext;
+    /* this is used to write the file */
+    protected PrintWriter out;
+    private String fileName;
+    private boolean verbose;
+
+    public AbstractWriter(J2EEWebServiceContext j2eewscontext, String filename)
+            throws GenerationFault {
+        this.j2eewscontext = j2eewscontext;
+        this.fileName = filename;
+        verbose = j2eewscontext.getMiscInfo().isVerbose();
+    }
+
+    protected abstract void writeCode() throws GenerationFault;
+
+    protected final void prepare() throws GenerationFault {
+        try {
+            File file = new File(this.fileName);
+            if (verbose) {
+                log.info("genarating ... " + file.getAbsolutePath());
+            }
+            if (!isOverWrite() && file.exists()) {
+                out = null;
+                if (verbose) {
+                    log.info("the file already exists .. tool will not overwrite it ");
+                }
+            } else {
+                File parent = file.getParentFile();
+                if (parent != null)
+                    parent.mkdirs();
+                file.createNewFile();
+                out = new PrintWriter(new FileWriter(file, false));
+            }
+        } catch (IOException e) {
+            log.error(e);
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    protected final void cleanUp() throws GenerationFault {
+        if (out != null)
+            out.close();
+    }
+
+    protected boolean isOverWrite() {
+        return true;
+    }
+
+    public final void write() throws GenerationFault {
+        try {
+            prepare();
+            writeCode();
+        } finally {
+            cleanUp();
+        }
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationConstants.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationConstants.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationConstants.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationConstants.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,96 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+/**
+ * <p>This interface has constants that are specific to the generators.</p>
+ */
+public class GenerationConstants {
+
+    //generators
+    public static final int EJB_GENERATOR = 0;
+    public static final int AXIS_WEBSERVICE_WRAPPER_GENERATOR = 1;
+    public static final int WSDL_GENERATOR = 2;
+    public static final int CLIENT_STUB_GENERATOR = 3;
+    public static final int SEI_AND_TYPES_GENERATOR = 4;
+    public static final int HANDLER_GENERATOR = 13;
+    public static final int JAXRPCMAPPER_GENERATOR = 14;
+    public static final int WEBSERVICEDD_GENERATOR = 15;
+    public static final int J2EE_CONTAINER_DD_GENERATOR = 16;
+    public static final int BUILD_FILE_GENERATOR = 17;
+    public static final int WEB_CONTAINER_DD_GENERATOR = 18;
+
+    //writers
+    public static final int EJB_REMOTE_INTERFACE_WRITER = 5;
+    public static final int EJB_HOME_INTERFACE_WRITER = 6;
+    public static final int EJB_LOCAL_INTERFACE_WRITER = 13;
+    public static final int EJB_LOCAL_HOME_INTERFACE_WRITER = 14;
+
+    public static final int EJB_IMPLEMENTATION_BEAN_WRITER = 7;
+    public static final int EJB_DD_WRITER = 8;
+    public static final int AXIS_WEBSERVICE_WRAPPER_WRITER = 9;
+    public static final int AXIS_WEBSERVICE_WRAPPER_DEPLOYMENT_FILE_WRITER = 10;
+    public static final int WSDL_FILE_WRITER = 11;
+    public static final int SEI_FILE_WRITER = 12;
+
+    public static final String OPTION_WS4J2EE_PROPERTY_FILE = "ws4j2ee.ConfigFile";
+
+    public static final String J2EE_CONTAINER_DD = "j2ee-container-dd";
+    public static final String WS4J2EE_PROPERTY_FILE = "ws4j2ee.properties";
+    public static final String WS4J2EE_PROVIDER = "j2ee";
+    public static final String J2EE_VERSION = "j2ee-version";
+    public static final String J2EE_VERSION_1_3 = "1.3";
+    public static final String J2EE_VERSION_1_4 = "1.4";
+    public static final String AXIS_HOST = "axis-host";
+    public static final String AXIS_PORT = "axis-port";
+    public static final String AXIS_WEBAPPS_LIB = "axis-webapps-lib";
+    public static final String EJB_DEPLOY_DIR = "ejb-deploy";
+	
+	
+//	private static Ws4J2eeProperties properties = new Ws4J2eeProperties();
+//	public static String getProperty(String key){
+//		return properties.getProperty(key);
+//	}
+
+    /**
+     * j2ee Container DDs
+     */
+    public static final String JBOSS_DD = "jboss.xml";
+    public static final String JONAS_DD = "jonas-ejb-jar.xml";
+    public static final String GERONIMO_DD = "openejb-jar.xml";
+    public static final String GERONIMO_WEB_DD = "geronimo-jetty.xml";
+
+    /**
+     * j2ee Containers
+     */
+    public static final String JBOSS_CONTAINER = "jboss";
+    public static final String JONAS_CONTAINER = "jonas";
+    public static final String GERONIMO_CONTAINER = "geronimo";
+
+    /**
+     * implementation styles
+     */
+    public static final String USE_REMOTE = "use-remote";
+    public static final String USE_LOCAL = "use-local";
+    public static final String USE_INTERNALS = "use-internals";
+    public static final String USE_LOCAL_AND_REMOTE = "use-local-remote";
+    public static final String USE_PROVIDER = "USE_PROVIDER";
+
+    public static final String CONFIG_STORE = "target/configStore";
+    public static final String MAVEN_LOCAL_REPOSITARY = "maven.repo.local";
+    
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFactory.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFactory.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFactory.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFactory.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,62 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.axis.wsdl.fromJava.Emitter;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public interface GenerationFactory {
+    public Writer createEJBWriter(J2EEWebServiceContext j2eewscontext,
+                                  EJBContext ejbcontext,
+                                  int writerType)
+            throws GenerationFault;
+
+    public Generator createEJBGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createWrapperWsGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createClientSideWsGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createWSDLGenerator(J2EEWebServiceContext wscontext,
+                                         Emitter emitter,
+                                         Ws4J2eeDeployContext clparser) throws GenerationFault;
+
+    public Generator createServerSideWsGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createHandlerGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createJaxrpcMapperGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createContainerSpecificDDGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createBuildFileGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+
+    public Generator createWebContainerDDGenerator(J2EEWebServiceContext j2eewscontext)
+            throws GenerationFault;
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFault.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFault.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFault.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/GenerationFault.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,87 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+/**
+ * <p>This denotes the Exception occured at the code genaration.
+ * There is a isssue of wrapping the Exception such that JDK1.3 compatibility.
+ * This code write same way as it was done at the RemoteException.</p>
+ */
+public class GenerationFault extends Exception {
+    /**
+     * Nested Exception to hold wrapped exception.
+     * <p>This field predates the general-purpose exception chaining facility.
+     * The {@link Throwable#getCause()} method is now the preferred means of
+     * obtaining this information.
+     *
+     * @serial
+     */
+    public Throwable detail;
+
+    private GenerationFault(Exception e) {
+        initCause(null); // Disallow subsequent initCause
+        setStackTrace(e.getStackTrace());
+        detail = e;
+    }
+
+    public GenerationFault(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a <code>Exception</code> with the specified
+     * detail message and nested exception.
+     *
+     * @param s  the detail message
+     * @param ex the nested exception
+     */
+    public GenerationFault(String s, Throwable ex) {
+        initCause(null); // Disallow subsequent initCause
+        detail = ex;
+        setStackTrace(ex.getStackTrace());
+    }
+
+    /**
+     * Returns the detail message, including the message from the nested
+     * exception if there is one.
+     *
+     * @return	the detail message, including nested exception message if any
+     */
+    public String getMessage() {
+        if (detail == null) {
+            return super.getMessage();
+        } else {
+            return detail.getMessage();
+        }
+    }
+
+    /**
+     * Returns the wrapped exception (the <i>cause</i>).
+     *
+     * @return the wrapped exception, which may be <tt>null</tt>.
+     */
+    public Throwable getCause() {
+        return detail;
+    }
+
+    public static GenerationFault createGenerationFault(Exception e) {
+        if (e instanceof GenerationFault) {
+            return (GenerationFault) e;
+        } else
+            return new GenerationFault(e);
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Generator.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Generator.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Generator.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Generator.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,30 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+/**
+ * <p>Instance of the Genarator represents an entity that genarates a
+ * Module. for e.g. EJB classes or JAX-RPC wrapper class and WSDD file genarator.</p>
+ */
+public interface Generator {
+    /**
+     * <p>at the call of the genarate method the Genarator will genarate what
+     * it is suppose to be genarate. Usally the Genarator is a assembly of
+     * One or more writers.</p>
+     */
+    public abstract void generate() throws GenerationFault;
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaClassWriter.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaClassWriter.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaClassWriter.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+
+/**
+ * abstract class writer
+ *
+ * @author Srianth Perera(hemapani@opensource.lk)
+ */
+public abstract class JavaClassWriter extends AbstractWriter {
+    protected String qulifiedName;
+    protected String classname;
+    protected String packageName;
+    private String pacakgesatement;
+    private String targetDirectory;
+
+    public JavaClassWriter(J2EEWebServiceContext j2eewscontext, String qulifiedName) throws GenerationFault {
+        super(j2eewscontext, Utils.getFileNamefromClass(j2eewscontext, qulifiedName));
+        this.qulifiedName = qulifiedName;
+        packageName = Utils.getPackageNameFromQuallifiedName(qulifiedName);
+        classname = Utils.getClassNameFromQuallifiedName(qulifiedName);
+    }
+
+    public void writeCode() throws GenerationFault {
+        if (out == null)
+            return;
+        out.write((packageName != null) ? ("package " + packageName + ";\n") : "");
+        writeImportStatements();
+        writeClassComment();
+        out.write("public class "
+                + classname
+                + getExtendsPart()
+                + getimplementsPart()
+                + "{\n");
+        writeAttributes();
+        writeConstructors();
+        writeMethods();
+        out.write("}\n");
+    }
+
+    protected String getExtendsPart() {
+        return " ";
+    }
+
+    protected String getimplementsPart() {
+        return " ";
+    }
+
+    protected void writeClassComment() throws GenerationFault {
+    }
+
+    protected void writeImportStatements() throws GenerationFault {
+    }
+
+    protected abstract void writeAttributes() throws GenerationFault;
+
+    protected abstract void writeConstructors() throws GenerationFault;
+
+    protected abstract void writeMethods() throws GenerationFault;
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaInterfaceWriter.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaInterfaceWriter.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaInterfaceWriter.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/JavaInterfaceWriter.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,72 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+
+/**
+ * abstract class writer
+ *
+ * @author Srianth Perera(hemapani@opensource.lk)
+ */
+public abstract class JavaInterfaceWriter extends AbstractWriter {
+    protected String qulifiedName;
+    protected String classname;
+    protected String packageName;
+    private String pacakgesatement;
+    private String targetDirectory;
+
+    public JavaInterfaceWriter(J2EEWebServiceContext j2eewscontext, String qulifiedName) throws GenerationFault {
+        super(j2eewscontext, Utils.getFileNamefromClass(j2eewscontext, qulifiedName));
+        if (qulifiedName == null) {
+            throw new GenerationFault("the class qualified name must not be null");
+        }
+        this.qulifiedName = qulifiedName;
+        packageName = Utils.getPackageNameFromQuallifiedName(qulifiedName);
+        classname = Utils.getClassNameFromQuallifiedName(qulifiedName);
+    }
+
+    public void writeCode() throws GenerationFault {
+        if (out == null)
+            return;
+        out.write((packageName != null) ? ("package " + packageName + ";\n") : "");
+        writeImportStatements();
+        writeClassComment();
+        out.write("public interface "
+                + classname
+                + getExtendsPart()
+                + "{\n");
+        writeAttributes();
+        writeMethods();
+        out.write("}\n");
+    }
+
+    protected String getExtendsPart() {
+        return " ";
+    }
+
+    protected void writeClassComment() throws GenerationFault {
+    }
+
+    protected void writeImportStatements() throws GenerationFault {
+    }
+
+    protected abstract void writeAttributes() throws GenerationFault;
+
+    protected abstract void writeMethods() throws GenerationFault;
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/UnrecoverableGenerationFault.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/UnrecoverableGenerationFault.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/UnrecoverableGenerationFault.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/UnrecoverableGenerationFault.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+/**
+ * <p>this error means that due to the error the programme going fail
+ * and can't recoverd.</p>
+ *
+ * @author hemapani
+ */
+public class UnrecoverableGenerationFault extends RuntimeException {
+    public UnrecoverableGenerationFault() {
+        super();
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public UnrecoverableGenerationFault(String message, Throwable cause) {
+        super(message, cause);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param cause
+     */
+    public UnrecoverableGenerationFault(Throwable cause) {
+        super(cause);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     */
+    public UnrecoverableGenerationFault(String message) {
+        super(message);
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Writer.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Writer.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Writer.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Writer.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,33 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+/**
+ * <p>for each single classs to be written there should be an associated
+ * writer instance. The writer instances of a single module, (e.g. writer
+ * instances of the EJB say <code>RemoteInterface Writer,HomeInterfaceWriter,
+ * ImplementationBeanWriter</code>) are bundeled by a single Genarator instance.
+ * The writer instaces should extend from the AbstractWriter unless it
+ * is required to have it otherwise.</p>
+ */
+public interface Writer {
+    /**
+     * The method writeCode() of the Writer should write the file Associated
+     * with this writer.
+     */
+    public abstract void write() throws GenerationFault;
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2EEClientwithWSDL.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2EEClientwithWSDL.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2EEClientwithWSDL.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2EEClientwithWSDL.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,105 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.ews.ws4j2ee.context.ContextValidator;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.MiscInfo;
+import org.apache.ws.ews.context.webservices.client.ServiceReferenceContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.impl.Ws4J2eeFactoryImpl;
+import org.apache.geronimo.ews.ws4j2ee.utils.MiscFactory;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+
+import java.io.FileInputStream;
+import java.util.HashMap;
+
+/**
+ * <p>this class genarate the code when the WSDL presents.</p>
+ */
+public class Ws4J2EEClientwithWSDL implements Generator {
+    private String wsConfFileLocation;
+    private boolean verbose = false;
+    private Ws4J2eeCLOptionParser clparser;
+    private Ws4J2eeFactory factory;
+    protected static Log log =
+            LogFactory.getLog(Ws4J2EEClientwithWSDL.class.getName());
+
+    private MiscInfo misc;
+
+    public Ws4J2EEClientwithWSDL(String[] args) throws Exception {
+        clparser = new Ws4J2eeCLOptionParser(args);
+    }
+
+    /**
+     * genarate. what is genarated is depend on genarators included.
+     *
+     * @see org.apache.geronimo.ews.ws4j2ee.toWs.Generator#genarate()
+     */
+    public void generate() throws GenerationFault {
+        try {
+            factory = new Ws4J2eeFactoryImpl();
+            J2EEWebServiceContext wscontext = factory.getContextFactory().getJ2EEWsContext(true);
+            wscontext.setFactory(factory);
+
+            misc = factory.getContextFactory().createMiscInfo(new HashMap());
+            wscontext.setMiscInfo(misc);
+            String wscfClientfile = clparser.getWscffile();
+            misc.setWsconffile(MiscFactory.getInputFile(wscfClientfile));
+            misc.setOutputPath(clparser.getOutputDirectory());
+            wsConfFileLocation = Utils.getRootDirOfFile(wscfClientfile);
+            wscontext.getMiscInfo().setImplStyle(clparser.getImplStyle());
+            wscontext.getMiscInfo().setTargetJ2EEContainer(clparser.getContanier());
+            
+            
+            //parsing of the webservices.xml happen here 
+            ServiceReferenceContext serviceContext =
+                    factory.getParserFactory().parseServiceReferance(wscontext,
+                            new FileInputStream(wscfClientfile));
+            if (verbose) {
+                log.info(wscfClientfile + " parsed ..");
+                log.info(serviceContext.getJaxrpcMappingFile());
+                log.info(serviceContext.getWsdlFile());
+            }
+            wscontext.getMiscInfo().setJaxrpcfile(MiscFactory.getInputFile(Utils.getAbsolutePath(serviceContext.getJaxrpcMappingFile(),
+                    wsConfFileLocation)));
+            wscontext.getMiscInfo().setWsdlFile(MiscFactory.getInputFile(Utils.getAbsolutePath(serviceContext.getWsdlFile(),
+                    wsConfFileLocation)));
+            wscontext.getMiscInfo().setVerbose(verbose);
+            wscontext.getMiscInfo().setHandlers(serviceContext.getHandlers()); 
+			
+            //JAX-RPC mapper calling
+            if (verbose)
+                log.info("starting client side code genaration .. ");
+            Generator clientStubGen = factory.getGenerationFactory().createClientSideWsGenerator(wscontext);
+            clientStubGen.generate();
+            ContextValidator cvalidator = new ContextValidator(wscontext);
+            //cvalidator.validateWithWSDL();
+            Generator handlerGen = factory.getGenerationFactory().createHandlerGenerator(wscontext);
+            handlerGen.generate();
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        Ws4J2EEClientwithWSDL gen = new Ws4J2EEClientwithWSDL(args);
+        gen.generate();
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2ee.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2ee.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2ee.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2ee.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,306 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.axis.wsdl.fromJava.Emitter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
+import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
+import org.apache.ws.ews.context.webservices.server.WSCFContext;
+import org.apache.ws.ews.context.webservices.server.WSCFPortComponent;
+import org.apache.ws.ews.context.webservices.server.WSCFWebserviceDescription;
+import org.apache.geronimo.ews.ws4j2ee.module.Module;
+import org.apache.geronimo.ews.ws4j2ee.toWs.impl.Ws4J2eeFactoryImpl;
+import org.apache.geronimo.ews.ws4j2ee.utils.FileUtils;
+import org.apache.geronimo.ews.ws4j2ee.utils.MiscFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * <p>this class genarate the code when the WSDL does not presents.</p>
+ */
+public class Ws4J2ee implements Generator {
+    protected static Log log =
+            LogFactory.getLog(Ws4J2ee.class.getName());
+    private J2EEWebServiceContext wscontext;
+    private boolean verbose = false;
+    private Ws4J2eeDeployContext clparser;
+    private WSCFPortComponent port;
+    private ClassLoader classloader;
+
+    private Module module;
+    private String wsdlImplFilename;
+
+    private InputStream wscffile;
+    private InputStream ejbddin;
+    private InputStream webddin;
+    private InputStream wsdlFile;
+    private InputStream jaxrpcmappingFile;
+    private String ejbLink;
+    private Emitter emitter;
+    private Ws4J2eeFactory factory;
+
+    public Ws4J2ee(Ws4J2eeDeployContext doployContext, Emitter emitter)
+            throws GenerationFault {
+        if (emitter == null) {
+            this.emitter = new Emitter();
+        } else {
+            this.emitter = emitter;
+        }
+        this.clparser = doployContext;
+        //create the context
+        prepareContext();
+        //parse the arguments 
+        parseCLargs();
+    }
+
+    /**
+     * genarate. what is genarated is depend on genarators included.
+     *
+     * @see org.apache.geronimo.ews.ws4j2ee.toWs.Generator#genarate()
+     */
+    public void generate() throws GenerationFault {
+        try {
+            //create the wscf context
+            WSCFWebserviceDescription wscfwsdis = parseTheWSCF();
+            populateWebserviceInfo(wscfwsdis);
+            pareseJ2eeModule();
+            checkAndGenerateWsdlAndMapping(wscfwsdis);
+            Ws4J2eeEmitter ws4j2eeEmitter = new Ws4J2eeEmitter(wscontext);
+            ws4j2eeEmitter.emmit();
+        } finally {
+            cleanup();
+        }
+    }
+
+    private void prepareContext() {
+        factory = new Ws4J2eeFactoryImpl();
+        this.wscontext = factory.getContextFactory().getJ2EEWsContext(false);
+        this.wscontext.setFactory(factory);
+        this.wscontext.setMiscInfo(factory.getContextFactory().createMiscInfo(clparser.getProperties()));
+        wscontext.getMiscInfo().setVerbose(verbose);
+    }
+
+    private void parseCLargs() throws GenerationFault {
+        module = clparser.getModule();
+        classloader = module.getClassLoaderWithPackageLoaded();
+
+        wscontext.getMiscInfo().setClassloader(classloader);
+        wscontext.getMiscInfo().setOutputPath(clparser.getOutPutLocation());
+        wscontext.getMiscInfo().setImplStyle(clparser.getImplStyle());
+        wscontext.getMiscInfo().setTargetJ2EEContainer(clparser.getContanier());
+        wscontext.getMiscInfo().setCompile(clparser.isCompile());
+        wsdlImplFilename = clparser.getWsdlImplFilename();
+        this.wscffile = module.getWscfFile();
+        ejbddin = module.getEjbJarfile();
+        webddin = module.getWebddfile();
+        wscontext.getMiscInfo().setWsconffile(MiscFactory.getInputFile(this.wscffile));
+        wscontext.getMiscInfo().setClassPathElements(module.getClassPathElements());
+    }
+
+    private WSCFWebserviceDescription parseTheWSCF() throws GenerationFault {
+        WSCFContext wscfcontext =
+                factory.getParserFactory().parseWSCF(wscontext, this.wscffile);
+        wscontext.setWSCFContext(wscfcontext);
+        if (verbose)
+            log.info(wscffile + " parsed ..");
+        WSCFWebserviceDescription[] wscfwsdiss =
+                wscontext.getWSCFContext().getWebServicesDescription();
+        //TODO fix this to handle multiple discriptions let us take the first discription
+        if (wscfwsdiss == null || wscfwsdiss.length == 0)
+            throw new UnrecoverableGenerationFault("no webservice discription "
+                    + "found in the webservices.xml file");
+        wscontext.getWSCFContext().setWscfdWsDescription(wscfwsdiss[0]);
+        return wscfwsdiss[0];
+    }
+
+    private void generateTheWSDLfile() throws GenerationFault {
+        Generator wsdlgen
+                = factory.getGenerationFactory().createWSDLGenerator(wscontext, emitter, clparser);
+        wsdlgen.generate();
+    }
+
+    /**
+     * generate the mapper file
+     */
+    private void generateTheJaxrpcmappingFile() throws GenerationFault {
+        // everything is good
+        if (verbose)
+            log.info("genarating jaxrpc-mapper.xml ..............");
+        Generator jaxrpcfilegen = factory.getGenerationFactory()
+                .createJaxrpcMapperGenerator(wscontext);
+        jaxrpcfilegen.generate();
+    }
+
+    private void parseEJBModule() throws GenerationFault {
+        try {
+            File file = null;
+            if (ejbddin != null) {
+                EJBContext ejbcontext = factory.getParserFactory()
+                        .parseEJBDDContext(wscontext, ejbddin);
+                wscontext.setEJBDDContext(ejbcontext);
+                ejbddin.close();
+                checkForImplBean(ejbcontext.getImplBean());
+            } else {
+                throw new GenerationFault("ejb-jar.xml file file does not exsits");
+            }
+        } catch (IOException e) {
+            log.error(e);
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    public void parseWebModule() throws GenerationFault {
+        wscontext.getMiscInfo().setImplwithEJB(false);
+        if (webddin != null) {
+            WebContext webcontext = factory.getParserFactory().parseWebDD(wscontext, webddin);
+            wscontext.setWebDDContext(webcontext);
+            checkForImplBean(webcontext.getServletClass());
+        } else {
+            throw new GenerationFault("web.xml file does not exsits");
+        }
+    }
+
+    private void checkForImplBean(String implBean) {
+        //TODO fix this java.lang.NoClassDefFoundError: javax/ejb/SessionBean
+        //from the dependancy class
+        if (implBean == null) {
+            wscontext.getMiscInfo().setImplAvalible(false);
+        } else {
+            try {
+                Class.forName(implBean, true, classloader);
+            } catch (ClassNotFoundException e) {
+                wscontext.getMiscInfo().setImplAvalible(false);
+            } catch (java.lang.NoClassDefFoundError e) {
+                wscontext.getMiscInfo().setImplAvalible(false);
+            }
+        }
+    }
+
+    private void populateWebserviceInfo(WSCFWebserviceDescription wscfwsdis) {
+        wscontext.getWSCFContext().setWscfdWsDescription(wscfwsdis);
+        wscontext.getMiscInfo().setSEIExists(true);
+        WSCFPortComponent[] ports = wscfwsdis.getPortComponent();
+        //TODO how to create the correct port type 
+        if (ports == null || ports.length == 0)
+            throw new UnrecoverableGenerationFault("no port discription"
+                    + " found in the webservices.xml file");
+        this.port = ports[0];
+        wscontext.getWSCFContext().setWscfport(port);
+        this.ejbLink = port.getServiceImplBean().getEjblink();
+        String seiName = port.getServiceEndpointInterface();
+        wscontext.getMiscInfo().setJaxrpcSEI(seiName);
+        wscontext.getMiscInfo().setHandlers(port.getHandlers());
+    }
+
+    private void pareseJ2eeModule() throws GenerationFault {
+        if (ejbLink != null) {
+            wscontext.getMiscInfo().setJ2eeComponetLink(ejbLink);
+            wscontext.getMiscInfo().setImplwithEJB(true);
+            parseEJBModule();
+        } else {
+            wscontext.getMiscInfo().setJ2eeComponetLink(port.getServiceImplBean().getServletlink());
+            wscontext.getMiscInfo().setImplwithEJB(false);
+            parseWebModule();
+        }
+    }
+
+    private void checkAndGenerateWsdlAndMapping(WSCFWebserviceDescription wscfwsdis)
+            throws GenerationFault {
+        try {
+            String wsdlFilename = wscfwsdis.getWsdlFile();
+            String jaxrpcMappingFileName = wscfwsdis.getJaxrpcMappingFile();
+            this.wsdlFile = module.findFileInModule(wsdlFilename);
+            if (this.wsdlFile == null) {
+                String wsdlabsoluteFile = wscontext.getMiscInfo().getOutPutPath() + "/" + wsdlFilename;
+                wscontext.getMiscInfo().setWsdlFile(MiscFactory.getInputFile(wsdlabsoluteFile));
+                File jaxrpcfile = new File(wscontext.getMiscInfo().getOutPutPath() + "/" + jaxrpcMappingFileName);
+                wscontext.getMiscInfo().setJaxrpcfile(MiscFactory.getInputFile(jaxrpcfile.getAbsolutePath()));
+                generateTheWSDLfile();
+                generateTheJaxrpcmappingFile();
+                wscontext.getMiscInfo().setSEIExists(true);
+            } else {
+                File file = new File(wscontext.getMiscInfo().getOutPutPath() + "/" + wsdlFilename);
+                file.getParentFile().mkdirs();
+                FileUtils.copyFile(wsdlFile, new FileOutputStream(file));
+                wscontext.getMiscInfo().setWsdlFile(MiscFactory.getInputFile(file.getAbsolutePath()));
+                jaxrpcmappingFile = module.findFileInModule(jaxrpcMappingFileName);
+                file = new File(wscontext.getMiscInfo().getOutPutPath() + "/" + jaxrpcMappingFileName);
+                file.getParentFile().mkdirs();
+                FileUtils.copyFile(jaxrpcmappingFile, new FileOutputStream(file));
+                if (jaxrpcmappingFile == null) {
+                    throw new GenerationFault("if the wsdlfile avalible the mapper file must be avalible");
+                } else {
+                    wscontext.getMiscInfo().setJaxrpcfile(MiscFactory.getInputFile(file.getAbsolutePath()));
+                }
+                wscontext.getMiscInfo().setSEIExists(false);
+            }
+        } catch (FileNotFoundException e) {
+            log.error(e);
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    public void cleanup() throws GenerationFault {
+        try {
+            wscffile.close();
+            if (ejbddin != null) {
+                ejbddin.close();
+            }
+            if (webddin != null) {
+                webddin.close();
+            }
+            if (jaxrpcmappingFile != null) {
+                jaxrpcmappingFile.close();
+            }
+            if (wsdlFile != null) {
+                wsdlFile.close();
+            }
+        } catch (Exception e) {
+            log.error(e);
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    /**
+     * args is String array s.t.
+     * 1)first argument is webservices.xml file
+     * 2)Other arguments are any option that can given to Java2WSDL
+     * 3)the SEI and the service Implementation bean should be avalible on the class path
+     * 4)the ws4j2ee will search for the web.xml or ejb-jar.xml
+     * a)same directory as the webservices.xml file
+     * b)file should be in the class path s.t META-INF/web.xml or META-INF/ejb-jar.xml
+     * 5)if no file found at the #4 the ws4j2ee continue assuming the Impl bean and the
+     * DD is not avalible. This is additional to spec.
+     *
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        Ws4J2ee gen = null;
+        Emitter emitter = new Emitter();
+        Ws4J2eeDeployContext deployContext = new Ws4J2eeServerCLOptionParser(args, emitter);
+        gen = new Ws4J2ee(deployContext, emitter);
+        gen.generate();
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeCLOptionParser.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeCLOptionParser.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeCLOptionParser.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeCLOptionParser.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,244 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.axis.utils.CLArgsParser;
+import org.apache.axis.utils.CLOption;
+import org.apache.axis.utils.CLOptionDescriptor;
+
+import java.util.List;
+
+/**
+ * @author hemapani
+ */
+public class Ws4J2eeCLOptionParser {
+    // Define our short one-letter option identifiers.
+    protected static final int SERVER_OPT = 's';
+    protected static final int SKELETON_DEPLOY_OPT = 'S';
+    protected static final int NAMESPACE_OPT = 'N';
+    protected static final int NAMESPACE_FILE_OPT = 'f';
+    protected static final int OUTPUT_OPT = 'o';
+    protected static final int SCOPE_OPT = 'd';
+    protected static final int TEST_OPT = 't';
+    protected static final int PACKAGE_OPT = 'p';
+    protected static final int ALL_OPT = 'a';
+    protected static final int TYPEMAPPING_OPT = 'T';
+    protected static final int FACTORY_CLASS_OPT = 'F';
+    protected static final int HELPER_CLASS_OPT = 'H';
+    protected static final int USERNAME_OPT = 'U';
+    protected static final int PASSWORD_OPT = 'P';
+    protected static final int IMPL_STYLE_OPT = 'E';
+    protected static final int CONTAINER_OPT = 'J';
+
+    private String wscffile;
+    private String outputDirectory = ".";
+    private boolean isServerSide = false;
+    private String userName;
+    private String password;
+    private String implStyle = GenerationConstants.USE_LOCAL_AND_REMOTE;
+    private String contanier = GenerationConstants.JBOSS_CONTAINER;
+
+    protected static final CLOptionDescriptor[] options = new CLOptionDescriptor[]{
+        new CLOptionDescriptor("server-side",
+                CLOptionDescriptor.ARGUMENT_OPTIONAL,
+                SERVER_OPT,
+                "Genarate Server side codes"),
+        new CLOptionDescriptor("output",
+                CLOptionDescriptor.ARGUMENT_REQUIRED,
+                OUTPUT_OPT,
+                "output Directory "),
+        new CLOptionDescriptor("user",
+                CLOptionDescriptor.ARGUMENT_REQUIRED,
+                USERNAME_OPT,
+                "user name"),
+        new CLOptionDescriptor("password",
+                CLOptionDescriptor.ARGUMENT_REQUIRED,
+                PASSWORD_OPT,
+                "password"),
+        new CLOptionDescriptor("implStyle",
+                CLOptionDescriptor.ARGUMENT_REQUIRED,
+                IMPL_STYLE_OPT,
+                "impelemtation Style"),
+        new CLOptionDescriptor("container",
+                CLOptionDescriptor.ARGUMENT_REQUIRED,
+                CONTAINER_OPT,
+                "the J2EE contianer")
+    };
+
+    public Ws4J2eeCLOptionParser(String[] args) {
+        CLArgsParser argsParser = new CLArgsParser(args, options);
+
+        // Print parser errors, if any
+        if (null != argsParser.getErrorString()) {
+            System.err.println(argsParser.getErrorString());
+            //printUsage();
+        }
+
+        // Get a list of parsed options
+        List clOptions = argsParser.getArguments();
+        int size = clOptions.size();
+        try {
+            // Parse the options and configure the emitter as appropriate.
+            for (int i = 0; i < size; i++) {
+                parseOption((CLOption) clOptions.get(i));
+            }
+
+            // validate argument combinations
+            //
+            //validateOptions();
+
+            //parser.run(wsdlURI);
+
+            // everything is good
+            //System.exit(0);
+        } catch (Throwable t) {
+            t.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+    protected void parseOption(CLOption option) {
+        switch (option.getId()) {
+            case SERVER_OPT:
+                isServerSide = true;
+                break;
+            case OUTPUT_OPT:
+                outputDirectory = option.getArgument();
+                break;
+            case USERNAME_OPT:
+                userName = option.getArgument();
+                break;
+            case PASSWORD_OPT:
+                password = option.getArgument();
+                break;
+            case CLOption.TEXT_ARGUMENT:
+                if (wscffile != null) {
+                    throw new UnrecoverableGenerationFault("Only one arguement allowed ");
+                    //printUsage();
+                }
+                wscffile = option.getArgument();
+                break;
+            case IMPL_STYLE_OPT:
+                this.implStyle = option.getArgument();
+                break;
+            case CONTAINER_OPT:
+                this.contanier = option.getArgument();
+                break;
+            default:
+                throw new UnrecoverableGenerationFault("unknown option");
+        }
+    } // parseOption
+
+    /**
+     * @return
+     */
+    public String getWscffile() {
+        return wscffile;
+    }
+
+    /**
+     * @param string
+     */
+    public void setWscffile(String string) {
+        wscffile = string;
+    }
+
+    /**
+     * @return
+     */
+    public boolean isServerSide() {
+        return isServerSide;
+    }
+
+    /**
+     * @return
+     */
+    public String getOutputDirectory() {
+        return outputDirectory;
+    }
+
+    /**
+     * @return
+     */
+    public String getPassword() {
+        return password;
+    }
+
+    /**
+     * @return
+     */
+    public String getUserName() {
+        return userName;
+    }
+
+    /**
+     * @param b
+     */
+    public void setServerSide(boolean b) {
+        isServerSide = b;
+    }
+
+    /**
+     * @param string
+     */
+    public void setOutputDirectory(String string) {
+        outputDirectory = string;
+    }
+
+    /**
+     * @param string
+     */
+    public void setPassword(String string) {
+        password = string;
+    }
+
+    /**
+     * @param string
+     */
+    public void setUserName(String string) {
+        userName = string;
+    }
+
+    /**
+     * @return
+     */
+    public String getImplStyle() {
+        return implStyle;
+    }
+
+    /**
+     * @param string
+     */
+    public void setImplStyle(String string) {
+        implStyle = string;
+    }
+
+    /**
+     * @return
+     */
+    public String getContanier() {
+        return contanier;
+    }
+
+    /**
+     * @param string
+     */
+    public void setContanier(String string) {
+        contanier = string;
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeDeployContext.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeDeployContext.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeDeployContext.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeDeployContext.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,44 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import java.util.Map;
+
+import org.apache.geronimo.ews.ws4j2ee.module.Module;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public interface Ws4J2eeDeployContext {
+    public int getMode();
+
+    public String getWsdlImplFilename();
+
+    public Module getModule();
+
+    public String getModuleLocation();
+
+    public String getContanier();
+
+    public String getImplStyle();
+
+    public String getOutPutLocation();
+
+    public boolean isCompile();
+    
+    public Map getProperties();
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeEmitter.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeEmitter.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeEmitter.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,115 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.ews.ws4j2ee.context.ContextValidator;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+
+import java.io.File;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class Ws4J2eeEmitter {
+    protected static Log log =
+            LogFactory.getLog(Ws4J2eeEmitter.class.getName());
+    protected Ws4J2eeFactory factory;
+    protected J2EEWebServiceContext wscontext;
+    private boolean ejbBased;
+    private boolean verbose;
+
+    public Ws4J2eeEmitter(J2EEWebServiceContext wscontext) {
+        this.wscontext = wscontext;
+        this.factory = wscontext.getFactory();
+        this.ejbBased = wscontext.getMiscInfo().isImplwithEJB();
+        this.verbose = wscontext.getMiscInfo().isVerbose();
+    }
+
+    public void prepareOutPutDir() {
+        File file = new File(wscontext.getMiscInfo().getOutPutPath() + "/META-INF");
+        if (!file.exists())
+            file.mkdirs();
+    }
+
+    public void generatedSEIandtypes() throws GenerationFault {
+        Generator seiAndTypegen =
+                factory.getGenerationFactory().createServerSideWsGenerator(wscontext);
+        seiAndTypegen.generate();
+    }
+
+    public void validateTheContext() throws GenerationFault {
+        ContextValidator cvalidater = new ContextValidator(wscontext);
+        cvalidater.validateWithWSDL();
+    }
+
+    public void generateEJB() throws GenerationFault {
+        if (verbose) {
+            log.info("genarating ejb >>");
+        }
+        Generator ejbgen = factory.getGenerationFactory().createEJBGenerator(wscontext);
+        ejbgen.generate();
+        if (verbose) {
+            log.info("genarating j2ee dd >>");
+        }
+        Generator j2eeContainerDDGen =
+                factory.getGenerationFactory()
+                .createContainerSpecificDDGenerator(wscontext);
+        j2eeContainerDDGen.generate();
+    }
+
+    public void generateWrapperWs() throws GenerationFault {
+        Generator wrapgen =
+                factory.getGenerationFactory().createWrapperWsGenerator(wscontext);
+        wrapgen.generate();
+    }
+
+    public void generatedHandlers() throws GenerationFault {
+        Generator handlerGen =
+                factory.getGenerationFactory().createHandlerGenerator(wscontext);
+        handlerGen.generate();
+    }
+
+    public void generateBuildFile() throws GenerationFault {
+        Generator buildFileGen =
+                factory.getGenerationFactory().createBuildFileGenerator(wscontext);
+        if (buildFileGen != null)
+            buildFileGen.generate();
+    }
+
+    public void executeAnt() throws GenerationFault {
+        if (wscontext.getMiscInfo().isCompile()) {
+            org.apache.geronimo.ews.ws4j2ee.utils.AntExecuter executer
+                    = new org.apache.geronimo.ews.ws4j2ee.utils.AntExecuter(wscontext);
+            executer.execute(wscontext.getMiscInfo().getOutPutPath() + "/build.xml");
+        }
+    }
+
+    public void emmit() throws GenerationFault {
+        prepareOutPutDir();
+        generatedSEIandtypes();
+        validateTheContext();
+        if (ejbBased) {
+            generateEJB();
+        }
+        generateWrapperWs();
+        generatedHandlers();
+        generateBuildFile();
+        executeAnt();
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeFactory.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeFactory.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeFactory.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/Ws4J2eeFactory.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,31 @@
+/*
+ * 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.geronimo.ews.ws4j2ee.toWs;
+
+import org.apache.geronimo.ews.ws4j2ee.context.ContextFactory;
+import org.apache.geronimo.ews.ws4j2ee.parsers.ParserFactory;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public interface Ws4J2eeFactory {
+    public ContextFactory getContextFactory();
+
+    public GenerationFactory getGenerationFactory();
+
+    public ParserFactory getParserFactory();
+}



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


Mime
View raw message