You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ews-dev@ws.apache.org by gu...@apache.org on 2005/08/08 14:42:47 UTC

svn commit: r230793 [10/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/...

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ClientSideWsGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ClientSideWsGenerator.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ClientSideWsGenerator.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ClientSideWsGenerator.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,97 @@
+/*
+ * 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.ws;
+
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.ews.mapper.J2eeEmitter;
+import org.apache.ws.ews.mapper.jaxrpc.JaxRpcMapper;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeFactory;
+
+/**
+ * <p>This genarated the Client side SEI and other classes required in the
+ * Axis.</p>
+ * * <h3>Service Endpoint Interface</h3>
+ * <p>The JAX-RPC specification requires that a JAX-RPC service endpoint interface must
+ * follow the following rules:</p>
+ * <ol>
+ * <li>Service endpoint interface must extend java.rmi.Remote either directly or indirectly</li>
+ * <li>All methods in the interface must throw java.rmi.RemoteException. Methods may
+ * throw service specific exceptions in addition to the RemoteException.</li>
+ * <li>Method parameters and return types must be the JAX-RPC supported Java types
+ * (refer to the section 5.1, �JAX-RPC Supported Java Types�). At runtime, values of a
+ * supported Java type must be serializable to and from the corresponding XML
+ * representation.
+ * </li>
+ * <li>Holder classes may be used as method parameters. These Holder classes are either
+ * generated or those packaged in the standard javax.xml.rpc.holders package.</li>
+ * <li>Service endpoint interface must not include constant (as public final static)
+ * declarations. WSDL 1.1 specification does not define any standard representation for
+ * constants in a wsdl:portType definition.</li>
+ * </ol>
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class ClientSideWsGenerator implements Generator {
+    private J2EEWebServiceContext j2eewscontext;
+    private Ws4J2eeFactory factory;
+    protected static Log log =
+            LogFactory.getLog(ServerSideWsGenerator.class.getName());
+
+    public ClientSideWsGenerator(J2EEWebServiceContext j2eewscontext) {
+        this.j2eewscontext = j2eewscontext;
+        factory = j2eewscontext.getFactory();
+    }
+
+    public void generate() throws GenerationFault {
+        try {
+            String mappingfile =
+                    j2eewscontext.getMiscInfo().getJaxrpcfile().fileName();
+            String wsdlfile =
+                    j2eewscontext.getMiscInfo().getWsdlFile().fileName();
+
+//			J2eeEmitter j2ee = new J2eeEmitter(true,
+//				!j2eewscontext.getMiscInfo().isSEIExists(),
+//				j2eewscontext);
+            J2eeEmitter j2ee = new J2eeEmitter(j2eewscontext, new J2eeGeneratorFactory());
+            if (j2eewscontext.getMiscInfo().isVerbose()) {
+                log.info("wsdl file = " + wsdlfile);
+                log.info("jaxrpc mapping file = " + mappingfile);
+                log.info("calling the jaxrpcmapper >> ");
+            }
+            j2ee.setMappingFilePath(mappingfile);
+            j2ee.setOutputDir(j2eewscontext.getMiscInfo().getOutPutPath());
+            j2ee.setServerSide(false);
+            j2ee.setVerbose(j2eewscontext.getMiscInfo().isVerbose());
+            j2ee.setHelperWanted(true);
+            j2ee.setTestCaseWanted(true);
+            j2ee.run(wsdlfile);
+            SymbolTable axisSymboltable = j2ee.getSymbolTable();
+            j2eewscontext.setWSDLContext(factory.getContextFactory().createWSDLContext(axisSymboltable));
+            JaxRpcMapper mapper = j2ee.getJaxRpcMapper();
+            j2eewscontext.setJAXRPCMappingContext(factory.getContextFactory().createJaxRpcMapperContext(mapper, j2ee));
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeBindingWriter.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeBindingWriter.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeBindingWriter.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeBindingWriter.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,55 @@
+/*
+ * 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.ws;
+
+import org.apache.axis.wsdl.gen.Generator;
+import org.apache.axis.wsdl.symbolTable.BindingEntry;
+import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.toJava.Emitter;
+import org.apache.axis.wsdl.toJava.JavaBindingWriter;
+import org.apache.ws.ews.mapper.J2eeEmitter;
+
+import javax.wsdl.Binding;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class J2eeBindingWriter extends JavaBindingWriter {
+    /**
+     * @param arg0
+     * @param arg1
+     * @param arg2
+     */
+    public J2eeBindingWriter(Emitter arg0, Binding arg1, SymbolTable arg2) {
+        super(arg0, arg1, arg2);
+    }
+
+    protected Generator getJavaInterfaceWriter(J2eeEmitter emitter,
+                                               PortTypeEntry ptEntry,
+                                               BindingEntry bEntry,
+                                               SymbolTable st) {
+        //TODO Do we need to generate the SEI sometimes ??
+        return null;
+    }
+
+    protected Generator getJavaImplWriter(J2eeEmitter emitter,
+                                          BindingEntry bEntry,
+                                          SymbolTable st) {
+        return null;
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeDeployWriter.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeDeployWriter.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeDeployWriter.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeDeployWriter.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,681 @@
+/*
+ * 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.ws;
+
+import org.apache.axis.Constants;
+import org.apache.axis.deployment.wsdd.WSDDConstants;
+import org.apache.axis.constants.Scope;
+import org.apache.axis.constants.Style;
+import org.apache.axis.constants.Use;
+import org.apache.axis.utils.JavaUtils;
+import org.apache.axis.utils.Messages;
+import org.apache.axis.wsdl.symbolTable.BindingEntry;
+import org.apache.axis.wsdl.symbolTable.CollectionTE;
+import org.apache.axis.wsdl.symbolTable.Element;
+import org.apache.axis.wsdl.symbolTable.FaultInfo;
+import org.apache.axis.wsdl.symbolTable.Parameter;
+import org.apache.axis.wsdl.symbolTable.Parameters;
+import org.apache.axis.wsdl.symbolTable.SchemaUtils;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.symbolTable.TypeEntry;
+import org.apache.axis.wsdl.toJava.Emitter;
+import org.apache.axis.wsdl.toJava.JavaWriter;
+import org.apache.axis.wsdl.toJava.Utils;
+import org.apache.ws.ews.mapper.J2eeEmitter;
+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.WSCFHandler;
+import org.apache.ws.ews.context.webservices.server.WSCFInitParam;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
+import org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.OperationType;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
+/**
+ * This is Wsdl2java's deploy Writer.  It writes the deploy.wsdd file.
+ */
+public class J2eeDeployWriter extends JavaWriter {
+    protected boolean useProvider = false;
+    /**
+     * Field definition
+     */
+    protected Definition definition;
+
+    /**
+     * Field symbolTable
+     */
+    protected SymbolTable symbolTable;
+    protected J2EEWebServiceContext wscontext;
+
+    /**
+     * Constructor.
+     *
+     * @param emitter
+     * @param definition
+     * @param symbolTable
+     */
+    public J2eeDeployWriter(Emitter emitter, Definition definition,
+                            SymbolTable symbolTable) {
+        super(emitter, "deploy");
+        this.definition = definition;
+        this.symbolTable = symbolTable;
+        wscontext = (J2EEWebServiceContext) ((J2eeEmitter) emitter).getWscontext();
+        if (wscontext == null) {
+            throw new RuntimeException("wscontext can not be null");
+        }
+        String val = System.getProperty("useProvider");
+        if(val != null){
+            useProvider = true;
+        }
+        
+    }    // ctor
+
+    /**
+     * Generate deploy.wsdd.  Only generate it if the emitter
+     * is generating server-side mappings.
+     *
+     * @throws IOException
+     */
+    public void generate() throws IOException {
+        if (emitter.isServerSide()) {
+            super.generate();
+        }
+    }    // generate
+
+    /**
+     * Return the fully-qualified name of the deploy.wsdd file
+     * to be generated.
+     *
+     * @return
+     */
+    protected String getFileName() {
+//		String dir =
+//				emitter.getNamespaces().getAsDir(definition.getTargetNamespace());
+        String dir =
+                emitter.getNamespaces().getAsDir("");
+        return dir + "deploy.wsdd";
+    }    // getFileName
+
+    /**
+     * Replace the default file header with the deployment doc file header.
+     *
+     * @param pw
+     * @throws IOException
+     */
+    protected void writeFileHeader(PrintWriter pw) throws IOException {
+        pw.println(Messages.getMessage("deploy00"));
+        pw.println(Messages.getMessage("deploy02"));
+        pw.println(Messages.getMessage("deploy03"));
+        pw.println(Messages.getMessage("deploy05"));
+        pw.println(Messages.getMessage("deploy06"));
+        pw.println(Messages.getMessage("deploy07"));
+        pw.println(Messages.getMessage("deploy09"));
+        pw.println();
+        pw.println("<deployment");
+        pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD + "\"");
+        pw.println("    xmlns:" + WSDDConstants.NS_PREFIX_WSDD_JAVA + "=\""
+                + WSDDConstants.URI_WSDD_JAVA + "\">");
+    }    // writeFileHeader
+
+    /**
+     * Write the body of the deploy.wsdd file.
+     *
+     * @param pw
+     * @throws IOException
+     */
+    protected void writeFileBody(PrintWriter pw) throws IOException {
+        writeDeployServices(pw);
+        pw.println("</deployment>");
+    }    // writeFileBody
+
+    /**
+     * Write out deployment and undeployment instructions for each WSDL service
+     *
+     * @param pw
+     * @throws IOException
+     */
+    protected void writeDeployServices(PrintWriter pw) throws IOException {
+        // deploy the ports on each service
+        Map serviceMap = definition.getServices();
+        for (Iterator mapIterator = serviceMap.values().iterator();
+             mapIterator.hasNext();) {
+            Service myService = (Service) mapIterator.next();
+            pw.println();
+            pw.println("  <!-- "
+                    + Messages.getMessage("wsdlService00", myService.getQName().getLocalPart()) + " -->");
+            pw.println();
+            for (Iterator portIterator = myService.getPorts().values().iterator();
+                 portIterator.hasNext();) {
+                Port myPort = (Port) portIterator.next();
+                BindingEntry bEntry =
+                        symbolTable.getBindingEntry(myPort.getBinding().getQName());
+
+                // If this isn't an SOAP binding, skip it
+                if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
+                    continue;
+                }
+                writeDeployPort(pw, myPort, myService, bEntry);
+            }
+        }
+    }    // writeDeployServices
+
+    /**
+     * Write out bean mappings for each type
+     *
+     * @param pw
+     * @param binding
+     * @param hasLiteral
+     * @param hasMIME
+     * @param use
+     * @throws IOException
+     */
+    protected void writeDeployTypes(PrintWriter pw, Binding binding, boolean hasLiteral, boolean hasMIME, Use use)
+            throws IOException {
+        pw.println();
+        if (hasMIME) {
+            QName bQName = binding.getQName();
+            writeTypeMapping(pw, bQName.getNamespaceURI(), "DataHandler",
+                    "javax.activation.DataHandler",
+                    "org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory",
+                    "org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory",
+                    use.getEncoding());
+        }
+        Map types = symbolTable.getTypeIndex();
+        Collection typeCollection = types.values();
+        for (Iterator i = typeCollection.iterator(); i.hasNext();) {
+            TypeEntry type = (TypeEntry) i.next();
+
+            // Note this same check is repeated in JavaStubWriter.
+            boolean process = true;
+
+            // 1) Don't register types that are base (primitive) types.
+            // If the baseType != null && getRefType() != null this
+            // is a simpleType that must be registered.
+            // 2) Don't register the special types for collections
+            // (indexed properties) or element types
+            // 3) Don't register types that are not referenced
+            // or only referenced in a literal context.
+            if (((type.getBaseType() != null) && (type.getRefType() == null))
+                    || (type instanceof CollectionTE)
+                    || (type instanceof Element) || !type.isReferenced()
+                    || type.isOnlyLiteralReferenced()) {
+                process = false;
+            }
+            if (process) {
+                String namespaceURI = type.getQName().getNamespaceURI();
+                String localPart = type.getQName().getLocalPart();
+                String javaType = type.getName();
+                String serializerFactory;
+                String deserializerFactory;
+                String encodingStyle = "";
+                if (!hasLiteral) {
+                    encodingStyle = use.getEncoding();
+                }
+                if (javaType.endsWith("[]")) {
+                    if (SchemaUtils.isListWithItemType(type.getNode())) {
+                        serializerFactory =
+                                "org.apache.axis.encoding.ser.SimpleListSerializerFactory";
+                        deserializerFactory =
+                                "org.apache.axis.encoding.ser.SimpleListDeserializerFactory";
+                    } else {
+                        serializerFactory =
+                                "org.apache.axis.encoding.ser.ArraySerializerFactory";
+                        deserializerFactory =
+                                "org.apache.axis.encoding.ser.ArrayDeserializerFactory";
+                    }
+                } else if ((type.getNode() != null) && (Utils.getEnumerationBaseAndValues(type.getNode(), symbolTable) != null)) {
+                    serializerFactory =
+                            "org.apache.axis.encoding.ser.EnumSerializerFactory";
+                    deserializerFactory =
+                            "org.apache.axis.encoding.ser.EnumDeserializerFactory";
+                } else if (type.isSimpleType()) {
+                    serializerFactory =
+                            "org.apache.axis.encoding.ser.SimpleSerializerFactory";
+                    deserializerFactory =
+                            "org.apache.axis.encoding.ser.SimpleDeserializerFactory";
+                } else if (type.getBaseType() != null) {
+                    serializerFactory =
+                            "org.apache.axis.encoding.ser.SimpleSerializerFactory";
+                    deserializerFactory =
+                            "org.apache.axis.encoding.ser.SimpleDeserializerFactory";
+                } else {
+                    serializerFactory =
+                            "org.apache.axis.encoding.ser.BeanSerializerFactory";
+                    deserializerFactory =
+                            "org.apache.axis.encoding.ser.BeanDeserializerFactory";
+                }
+                writeTypeMapping(pw, namespaceURI, localPart, javaType,
+                        serializerFactory, deserializerFactory,
+                        encodingStyle);
+            }
+        }
+    }    // writeDeployTypes
+
+    /**
+     * Raw routine that writes out the typeMapping.
+     *
+     * @param pw
+     * @param namespaceURI
+     * @param localPart
+     * @param javaType
+     * @param serializerFactory
+     * @param deserializerFactory
+     * @param encodingStyle
+     * @throws IOException
+     */
+    protected void writeTypeMapping(PrintWriter pw, String namespaceURI, String localPart, String javaType, String serializerFactory, String deserializerFactory, String encodingStyle)
+            throws IOException {
+        pw.println("      <typeMapping");
+        pw.println("        xmlns:ns=\"" + namespaceURI + "\"");
+        pw.println("        qname=\"ns:" + localPart + '"');
+        pw.println("        type=\"java:" + javaType + '"');
+        pw.println("        serializer=\"" + serializerFactory + "\"");
+        pw.println("        deserializer=\"" + deserializerFactory + "\"");
+        pw.println("        encodingStyle=\"" + encodingStyle + "\"");
+        pw.println("      />");
+    }
+
+    /**
+     * Write out deployment and undeployment instructions for given WSDL port
+     *
+     * @param pw
+     * @param port
+     * @param service
+     * @param bEntry
+     * @throws IOException
+     */
+    protected void writeDeployPort(PrintWriter pw, Port port, Service service, BindingEntry bEntry)
+            throws IOException {
+        String serviceName = port.getName();
+        boolean hasLiteral = bEntry.hasLiteral();
+        boolean hasMIME = Utils.hasMIME(bEntry);
+        String prefix = WSDDConstants.NS_PREFIX_WSDD_JAVA;
+        String styleStr = "";
+        Use use = Use.DEFAULT;
+        Iterator iterator =
+                bEntry.getBinding().getExtensibilityElements().iterator();
+
+        //get the Name of the provider needed in the deploy.wsdd
+        String provider = null;
+        provider = GenerationConstants.WS4J2EE_PROVIDER;
+        while (iterator.hasNext()) {
+            Object obj = iterator.next();
+            if (obj instanceof SOAPBinding) {
+                use = Use.ENCODED;
+            } else if (obj instanceof UnknownExtensibilityElement) {
+                // TODO: After WSDL4J supports soap12, change this code
+                UnknownExtensibilityElement unkElement =
+                        (UnknownExtensibilityElement) obj;
+                QName name =
+                        unkElement.getElementType();
+                if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP)
+                        && name.getLocalPart().equals("binding")) {
+                    use = Use.ENCODED;
+                }
+            }
+        }
+        if (symbolTable.isWrapped()) {
+            styleStr = " style=\"" + Style.WRAPPED + "\"";
+            use = Use.LITERAL;
+        } else {
+            styleStr = " style=\"" + bEntry.getBindingStyle().getName() + "\"";
+            if (hasLiteral) {
+                use = Use.LITERAL;
+            }
+        }
+        String useStr = " use=\"" + use + "\"";
+//		if(provider!= null){
+//			pw.println("  <service name=\"" + serviceName + "\" provider=\""
+//					+ provider + "\"" + styleStr + useStr + ">");
+//			WSCFHandler[] handlers = wscontext.getMiscInfo().getHandlers();	
+//			for(int i = 0;i<handlers.length;i++){
+//				writeHandler(pw,handlers[i]);
+//			}	
+//		}else{
+//			pw.println("  <service name=\"" + serviceName + "\" provider=\""
+//					+ prefix + ":RPC" + "\"" + styleStr + useStr + ">");
+//		}
+        if (this.useProvider) {
+            String continer = wscontext.getMiscInfo().getTargetJ2EEContainer();
+            if (GenerationConstants.GERONIMO_CONTAINER.equals(continer)) {
+//                pw.println("    <service name=\"" + serviceName + "\" provider=\"java:geronimo\""
+//                        + styleStr + useStr + ">");
+                pw.println("    <service name=\"" + serviceName + "\" provider=\"Handler\""
+                        + styleStr + useStr + ">");
+                pw.println("      <parameter name=\"handlerClass\" value=\"org.apache.geronimo.axis.GeronimoProvider\"/>");
+            } else {
+//                pw.println("  <service name=\"" + serviceName + "\" provider=\"java:ews\""
+//                        + styleStr + useStr + ">");
+                pw.println("    <service name=\"" + serviceName + "\" provider=\"Handler\"" 
+                      + styleStr + useStr + ">");
+                pw.println("      <parameter name=\"handlerClass\" value=\"org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider\"/>");
+              //pw.println("        <java:provider  java:className=\"org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider\" java:isStatic=\"true\"/>\n");
+                        //
+                        //java:className
+            }
+        } else {
+            pw.println("  <service name=\"" + serviceName + "\" provider=\"java:j2ee\""
+                    + styleStr + useStr + ">");
+        }
+        EJBContext ejbcontext = wscontext.getEJBDDContext();
+        if (ejbcontext != null) {
+            pw.println("      <parameter name=\""+EWSProvider.OPTION_USE_EJB+"\" value=\"ejb\"/>");
+            if (ejbcontext.getEjbhomeInterface() != null) {
+                pw.println("      <parameter name=\""+EWSProvider.OPTION_HOMEINTERFACE_NAME+"\" value=\""
+                        + ejbcontext.getEjbhomeInterface() + "\"/>");
+            }
+            if (ejbcontext.getEjbRemoteInterface() != null) {
+                pw.println("      <parameter name=\""+EWSProvider.OPTION_REMOTEINTERFACE_NAME+"\" value=\""
+                        + ejbcontext.getEjbRemoteInterface() + "\"/>");
+            }
+            if (ejbcontext.getEjbLocalHomeInterfce() != null) {
+                pw.println("      <parameter name=\""+EWSProvider.OPTION_LOCALHOMEINTERFACE_NAME+"\" value=\""
+                        + ejbcontext.getEjbLocalHomeInterfce() + "\"/>");
+            }
+            if (ejbcontext.getEjbLocalInterface() != null) {
+                pw.println("      <parameter name=\""+EWSProvider.OPTION_LOCALINTERFACE_NAME+"\" value=\""
+                        + ejbcontext.getEjbLocalInterface() + "\"/>");
+            }
+            if (ejbcontext.getEjbRemoteInterface() != null) {
+                pw.println("      <parameter name=\""+EWSProvider.OPTION_HOMEINTERFACE_NAME+"\" value=\""
+                        + "ejb/" + ejbcontext.getEjbName() + "\"/>");
+            }
+            if (ejbcontext.getEjbRemoteInterface() != null) {
+                pw.println("      <parameter name=\""+EWSProvider.OPTION_EJB_NAME+"\" value=\""
+                        + ejbcontext.getEjbName() + "\"/>");
+            }
+        }else{
+            pw.println("      <parameter name=\""+EWSProvider.OPTION_USE_EJB+"\" value=\"web\"/>");
+        }
+        pw.println("      <parameter name=\"wsdlTargetNamespace\" value=\""
+                + service.getQName().getNamespaceURI() + "\"/>");
+        pw.println("      <parameter name=\"wsdlServiceElement\" value=\""
+                + service.getQName().getLocalPart() + "\"/>");
+        pw.println("      <parameter name=\"wsdlServicePort\" value=\""
+                + serviceName + "\"/>");
+
+        // MIME attachments don't work with multiref, so turn it off.
+        if (hasMIME) {
+            pw.println("      <parameter name=\"sendMultiRefs\" value=\"false\"/>");
+        }
+        writeDeployBinding(pw, bEntry);
+        writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME, use);
+        WSCFHandler[] handlers = this.wscontext.getMiscInfo().getHandlers();
+        if (handlers != null) {
+            for (int i = 0; i < handlers.length; i++) {
+                writeHandler(pw, handlers[i]);
+            }
+        }
+        pw.println("  </service>");
+    }    // writeDeployPort
+
+    /**
+     * Write out deployment instructions for given WSDL binding
+     *
+     * @param pw
+     * @param bEntry
+     * @throws IOException
+     */
+    protected void writeDeployBinding(PrintWriter pw, BindingEntry bEntry)
+            throws IOException {
+        Binding binding = bEntry.getBinding();
+        String className = bEntry.getName();
+        if (emitter.isSkeletonWanted()) {
+            className += "Skeleton";
+        } else {
+            className += "Impl";
+        }
+        if (this.useProvider) {
+            WebContext webContext = wscontext.getWebDDContext();
+            if (webContext != null) {
+                pw.println("      <parameter name=\"className\" value=\"" + webContext.getServletClass()
+                        + "\"/>");
+            }
+        } else {
+            pw.println("      <parameter name=\"className\" value=\"" + className
+                    + "\"/>");
+        }
+        pw.println("      <parameter name=\"wsdlPortType\" value=\""
+                + binding.getPortType().getQName().getLocalPart() + "\"/>");
+        HashSet allowedMethods = new HashSet();
+        if (!emitter.isSkeletonWanted()) {
+            Iterator operationsIterator =
+                    binding.getBindingOperations().iterator();
+            for (; operationsIterator.hasNext();) {
+                BindingOperation bindingOper =
+                        (BindingOperation) operationsIterator.next();
+                Operation operation = bindingOper.getOperation();
+                OperationType type = operation.getStyle();
+                String javaOperName =
+                        JavaUtils.xmlNameToJava(operation.getName());
+
+                // These operation types are not supported.  The signature
+                // will be a string stating that fact.
+                if ((type == OperationType.NOTIFICATION)
+                        || (type == OperationType.SOLICIT_RESPONSE)) {
+                    continue;
+                }
+                allowedMethods.add(javaOperName);
+
+                // We pass "" as the namespace argument because we're just
+                // interested in the return type for now.
+                Parameters params =
+                        symbolTable.getOperationParameters(operation, "", bEntry);
+                if (params != null) {
+                    // Get the operation QName
+                    QName elementQName = Utils.getOperationQName(bindingOper,
+                            bEntry, symbolTable);
+
+                    // Get the operation's return QName and type
+                    QName returnQName = null;
+                    QName returnType = null;
+                    if (params.returnParam != null) {
+                        returnQName = params.returnParam.getQName();
+                        returnType = Utils.getXSIType(params.returnParam);
+                    }
+
+                    // Get the operations faults
+                    Map faultMap = bEntry.getFaults();
+                    ArrayList faults = null;
+                    if (faultMap != null) {
+                        faults = (ArrayList) faultMap.get(bindingOper);
+                    }
+
+                    // Write the operation metadata
+                    writeOperation(pw, javaOperName, elementQName, returnQName,
+                            returnType, params, binding.getQName(),
+                            faults);
+                }
+            }
+        }
+        pw.print("      <parameter name=\"allowedMethods\" value=\"");
+        if (allowedMethods.isEmpty()) {
+            pw.println("*\"/>");
+        } else {
+            boolean first = true;
+            for (Iterator i = allowedMethods.iterator(); i.hasNext();) {
+                String method = (String) i.next();
+                if (first) {
+                    pw.print(method);
+                    first = false;
+                } else {
+                    pw.print(" " + method);
+                }
+            }
+            pw.println("\"/>");
+        }
+        Scope scope = emitter.getScope();
+        if (scope != null) {
+            pw.println("      <parameter name=\"scope\" value=\""
+                    + scope.getName() + "\"/>");
+        }
+    }    // writeDeployBinding
+
+    /**
+     * Raw routine that writes out the operation and parameters.
+     *
+     * @param pw
+     * @param javaOperName
+     * @param elementQName
+     * @param returnQName
+     * @param returnType
+     * @param params
+     * @param bindingQName
+     * @param faults
+     */
+    protected void writeOperation(PrintWriter pw, String javaOperName,
+                                  QName elementQName, QName returnQName,
+                                  QName returnType, Parameters params,
+                                  QName bindingQName, ArrayList faults) {
+        pw.print("      <operation name=\"" + javaOperName + "\"");
+        if (elementQName != null) {
+            pw.print(" qname=\""
+                    + Utils.genQNameAttributeString(elementQName, "operNS")
+                    + "\"");
+        }
+        if (returnQName != null) {
+            pw.print(" returnQName=\""
+                    + Utils.genQNameAttributeStringWithLastLocalPart(returnQName, "retNS")
+                    + "\"");
+        }
+        if (returnType != null) {
+            pw.print(" returnType=\""
+                    + Utils.genQNameAttributeString(returnType, "rtns")
+                    + "\"");
+        }
+        if ((params.returnParam != null) && params.returnParam.isOutHeader()) {
+            pw.print(" returnHeader=\"true\"");
+        }
+        pw.println(" >");
+        Vector paramList = params.list;
+        for (int i = 0; i < paramList.size(); i++) {
+            Parameter param = (Parameter) paramList.elementAt(i);
+
+            // Get the parameter name QName and type QName
+            QName paramQName = param.getQName();
+            QName paramType = Utils.getXSIType(param);
+            pw.print("        <parameter");
+            if ((paramQName == null)
+                    || "".equals(paramQName.getNamespaceURI())) {
+                pw.print(" name=\"" + param.getName() + "\"");
+            } else {
+                pw.print(" qname=\""
+                        + Utils.genQNameAttributeStringWithLastLocalPart(paramQName, "pns")
+                        + "\"");
+            }
+            pw.print(" type=\""
+                    + Utils.genQNameAttributeString(paramType, "tns") + "\"");
+
+            // Get the parameter mode
+            if (param.getMode() != Parameter.IN) {
+                pw.print(" mode=\"" + getModeString(param.getMode()) + "\"");
+            }
+
+            // Is this a header?
+            if (param.isInHeader()) {
+                pw.print(" inHeader=\"true\"");
+            }
+            if (param.isOutHeader()) {
+                pw.print(" outHeader=\"true\"");
+            }
+            pw.println("/>");
+        }
+        if (faults != null) {
+            for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
+                FaultInfo faultInfo = (FaultInfo) iterator.next();
+                QName faultQName = faultInfo.getQName();
+                if (faultQName != null) {
+                    String className =
+                            Utils.getFullExceptionName(faultInfo.getMessage(),
+                                    symbolTable);
+                    pw.print("        <fault");
+                    pw.print(" name=\"" + faultInfo.getName() + "\"");
+                    pw.print(" qname=\""
+                            + Utils.genQNameAttributeString(faultQName, "fns")
+                            + "\"");
+                    pw.print(" class=\"" + className + "\"");
+                    pw.print(" type=\""
+                            + Utils.genQNameAttributeString(faultInfo.getXMLType(), "tns") + "\"");
+                    pw.println("/>");
+                }
+            }
+        }
+        pw.println("      </operation>");
+    }
+
+    /**
+     * Method getModeString
+     *
+     * @param mode
+     * @return
+     */
+    public String getModeString(byte mode) {
+        if (mode == Parameter.IN) {
+            return "IN";
+        } else if (mode == Parameter.INOUT) {
+            return "INOUT";
+        } else {
+            return "OUT";
+        }
+    }
+
+    /**
+     * Method getPrintWriter
+     *
+     * @param filename
+     * @return
+     * @throws IOException
+     */
+    protected PrintWriter getPrintWriter(String filename) throws IOException {
+        File file = new File(filename);
+        File parent = new File(file.getParent());
+        parent.mkdirs();
+        FileOutputStream out = new FileOutputStream(file);
+        OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
+        return new PrintWriter(writer);
+    }
+
+    private void writeHandler(PrintWriter pw, WSCFHandler handler) {
+        pw.println("      <handler name=\"" + handler.getHandlerName() + "\"type=\"" + handler.getHandlerClass() + "\">");
+        WSCFInitParam[] param = handler.getInitParam();
+        for (int i = 0; i < param.length; i++) {
+            pw.println("      <parameter name=\"" + param[i].getParamName() + "\" value=\"" + param[i].getParamValue() + "\"/>");
+        }
+        //TODO handle soap role and soaphandlers 
+        pw.println("      </handler>");
+    }
+}    // class JavaDeployWriter

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeGeneratorFactory.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeGeneratorFactory.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeGeneratorFactory.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeGeneratorFactory.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,60 @@
+/*
+ * 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.ws;
+
+import org.apache.axis.wsdl.gen.Generator;
+import org.apache.axis.wsdl.symbolTable.BindingEntry;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.toJava.JavaDefinitionWriter;
+import org.apache.axis.wsdl.toJava.JavaUndeployWriter;
+import org.apache.ws.ews.mapper.J2eeEmitter;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class J2eeGeneratorFactory extends org.apache.ws.ews.mapper.J2eeGeneratorFactory {
+    /**
+     * 
+     */
+    public J2eeGeneratorFactory() {
+        super();
+    }
+
+    /**
+     * @param emitter
+     */
+    public J2eeGeneratorFactory(J2eeEmitter emitter) {
+        super(emitter);
+    }
+
+    protected void addDefinitionGenerators() {
+        addGenerator(Definition.class, JavaDefinitionWriter.class); // for faults
+        addGenerator(Definition.class, J2eeDeployWriter.class); // for deploy.wsdd
+        addGenerator(Definition.class, JavaUndeployWriter.class); // for undeploy.wsdd
+    }
+
+    public Generator getGenerator(Binding binding, SymbolTable symbolTable) {
+        Generator writer = new J2eeBindingWriter(emitter, binding, symbolTable);
+        BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
+        bindingWriters.addStuff(writer, bEntry, symbolTable);
+        return bindingWriters;
+    } // getGenerator
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ServerSideWsGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ServerSideWsGenerator.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ServerSideWsGenerator.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/ServerSideWsGenerator.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,100 @@
+/*
+ * 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.ws;
+
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.ews.mapper.J2eeEmitter;
+import org.apache.ws.ews.mapper.jaxrpc.JaxRpcMapper;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeFactory;
+
+/**
+ * <p>This genarated the Server side SEI and other classes required in the
+ * Axis.</p>
+ * <h3>Service Endpoint Interface</h3>
+ * <p>The JAX-RPC specification requires that a JAX-RPC service endpoint interface must
+ * follow the following rules:</p>
+ * <ol>
+ * <li>Service endpoint interface must extend java.rmi.Remote either directly or indirectly</li>
+ * <li>All methods in the interface must throw java.rmi.RemoteException. Methods may
+ * throw service specific exceptions in addition to the RemoteException.</li>
+ * <li>Method parameters and return types must be the JAX-RPC supported Java types
+ * (refer to the section 5.1, �JAX-RPC Supported Java Types�). At runtime, values of a
+ * supported Java type must be serializable to and from the corresponding XML
+ * representation.
+ * </li>
+ * <li>Holder classes may be used as method parameters. These Holder classes are either
+ * generated or those packaged in the standard javax.xml.rpc.holders package.</li>
+ * <li>Service endpoint interface must not include constant (as public final static)
+ * declarations. WSDL 1.1 specification does not define any standard representation for
+ * constants in a wsdl:portType definition.</li>
+ * </ol>
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class ServerSideWsGenerator implements Generator {
+    private J2EEWebServiceContext j2eewscontext;
+    private Ws4J2eeFactory factory;
+    protected static Log log =
+            LogFactory.getLog(ServerSideWsGenerator.class.getName());
+
+    public ServerSideWsGenerator(J2EEWebServiceContext j2eewscontext) {
+        this.j2eewscontext = j2eewscontext;
+        factory = j2eewscontext.getFactory();
+    }
+
+    public void generate() throws GenerationFault {
+        try {
+            String mappingfile =
+                    j2eewscontext.getMiscInfo().getJaxrpcfile().fileName();
+            String wsdlfile =
+                    j2eewscontext.getMiscInfo().getWsdlFile().fileName();
+			
+//            J2eeEmitter j2ee = new J2eeEmitter(true,
+//            	!j2eewscontext.getMiscInfo().isSEIExists(),j2eewscontext);
+            J2eeGeneratorFactory genFac = new J2eeGeneratorFactory();
+            J2eeEmitter j2ee = new J2eeEmitter(j2eewscontext, genFac);
+            if (j2eewscontext.getMiscInfo().isVerbose()) {
+                log.info("wsdl file = " + wsdlfile);
+                log.info("jaxrpc mapping file = " + mappingfile);
+                log.info("calling the jaxrpcmapper >> ");
+            }
+            j2ee.setMappingFilePath(mappingfile);
+            j2ee.setOutputDir(j2eewscontext.getMiscInfo().getOutPutPath());
+            j2ee.setServerSide(true);
+            j2ee.setVerbose(j2eewscontext.getMiscInfo().isVerbose());
+            //j2ee.setUsedbyws4j2ee(true);
+            j2ee.setHelperWanted(true);
+            j2ee.runServerSide(wsdlfile);
+            SymbolTable axisSymboltable = j2ee.getSymbolTable();
+            j2eewscontext.setWSDLContext(factory.getContextFactory().createWSDLContext(axisSymboltable));
+            JaxRpcMapper mapper = j2ee.getJaxRpcMapper();
+            j2eewscontext.setJAXRPCMappingContext(factory.getContextFactory().createJaxRpcMapperContext(mapper, j2ee));
+        } catch (Exception e) {
+            if (e instanceof RuntimeException) {
+                throw (RuntimeException) e;
+            } else {
+                e.printStackTrace();
+                throw GenerationFault.createGenerationFault(e);
+            }
+        }
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/WSDLOnlyClientSideWsGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/WSDLOnlyClientSideWsGenerator.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/WSDLOnlyClientSideWsGenerator.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/ws/WSDLOnlyClientSideWsGenerator.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,106 @@
+/*
+ * 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.ws;
+
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.toJava.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.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeFactory;
+
+/**
+ * <p>This genarated the Client side SEI and other classes required in the
+ * Axis.</p>
+ * * <h3>Service Endpoint Interface</h3>
+ * <p>The JAX-RPC specification requires that a JAX-RPC service endpoint interface must
+ * follow the following rules:</p>
+ * <ol>
+ * <li>Service endpoint interface must extend java.rmi.Remote either directly or indirectly</li>
+ * <li>All methods in the interface must throw java.rmi.RemoteException. Methods may
+ * throw service specific exceptions in addition to the RemoteException.</li>
+ * <li>Method parameters and return types must be the JAX-RPC supported Java types
+ * (refer to the section 5.1, ?JAX-RPC Supported Java Types?). At runtime, values of a
+ * supported Java type must be serializable to and from the corresponding XML
+ * representation.
+ * </li>
+ * <li>Holder classes may be used as method parameters. These Holder classes are either
+ * generated or those packaged in the standard javax.xml.rpc.holders package.</li>
+ * <li>Service endpoint interface must not include constant (as public final static)
+ * declarations. WSDL 1.1 specification does not define any standard representation for
+ * constants in a wsdl:portType definition.</li>
+ * </ol>
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class WSDLOnlyClientSideWsGenerator implements Generator {
+    protected static Log log =
+            LogFactory.getLog(ServerSideWsGenerator.class.getName());
+    private J2EEWebServiceContext j2eewscontext;
+    private Ws4J2eeFactory factory;
+
+    private String wsdlfile;
+    private String outputDir;
+    private boolean verbose;
+
+    public WSDLOnlyClientSideWsGenerator(J2EEWebServiceContext j2eewscontext) throws GenerationFault {
+        this.j2eewscontext = j2eewscontext;
+        this.wsdlfile = j2eewscontext.getMiscInfo().getWsdlFile().fileName();
+        this.outputDir = j2eewscontext.getMiscInfo().getOutPutPath();
+        verbose = j2eewscontext.getMiscInfo().isVerbose();
+        factory = j2eewscontext.getFactory();
+    }
+
+    public WSDLOnlyClientSideWsGenerator(String wsdlFile, String outputDir) throws GenerationFault {
+        this.wsdlfile = wsdlFile;
+        this.outputDir = outputDir;
+    }
+
+    public void generate() throws GenerationFault {
+        try {
+            Emitter emitter = new Emitter();
+            if (verbose) {
+                log.info("wsdl file = " + wsdlfile);
+                log.info("calling the WSDL2Java >> ");
+            }
+            emitter.setOutputDir(outputDir);
+            emitter.setServerSide(false);
+            emitter.setVerbose(verbose);
+            emitter.setHelperWanted(true);
+            emitter.setTestCaseWanted(true);
+            emitter.run(wsdlfile);
+            if (j2eewscontext != null) {
+                SymbolTable axisSymboltable = emitter.getSymbolTable();
+                j2eewscontext.setWSDLContext(factory.getContextFactory().createWSDLContext(axisSymboltable));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    public static void main(String[] args) throws GenerationFault {
+        if (args.length < 2) {
+            System.out.println("the input should be\n WSDLOnlyClientSideWsGenerator wsdlfile ourputdir");
+        }
+        WSDLOnlyClientSideWsGenerator gen
+                = new WSDLOnlyClientSideWsGenerator(args[0], args[1]);
+        gen.generate();
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/wsdl/WSDLGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/wsdl/WSDLGenerator.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/wsdl/WSDLGenerator.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/toWs/wsdl/WSDLGenerator.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.wsdl;
+
+import org.apache.axis.utils.ClassUtils;
+import org.apache.axis.wsdl.Java2WSDL;
+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.ContextValidator;
+import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
+import org.apache.geronimo.ews.ws4j2ee.context.impl.AxisEmitterBasedJaxRpcMapperContext;
+import org.apache.geronimo.ews.ws4j2ee.context.wsdl.impl.AxisEmitterBasedWSDLContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeDeployContext;
+import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
+
+/**
+ * <p>This genarated theWrapper WS required in the
+ * Axis.</p>
+ *
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class WSDLGenerator extends Java2WSDL implements Generator {
+    private J2EEWebServiceContext wscontext;
+    private Ws4J2eeDeployContext clparser;
+    private Emitter emitter;
+    private String wsdlFile;
+    private boolean verbose;
+
+    protected static Log log =
+            LogFactory.getLog(WSDLGenerator.class.getName());
+
+    public WSDLGenerator(J2EEWebServiceContext wscontext,
+                         Emitter emitter,
+                         Ws4J2eeDeployContext clparser) throws GenerationFault {
+        this.wscontext = wscontext;
+        this.emitter = emitter;
+        this.clparser = clparser;
+        this.wsdlFile = wscontext.getMiscInfo().getWsdlFile().fileName();
+    }
+
+    public void generate() throws GenerationFault {
+        try {
+            if (verbose)
+                log.info("calling Java2WSDL to genarated wsdl ...........");
+            //generate the wsdl file
+            ClassUtils.setDefaultClassLoader(wscontext.getMiscInfo().getClassloader());
+            emitter.setLocationUrl("http://localhost:8080/ws/" + wscontext.getWSCFContext().getWscfport().getPortComponentName());
+            emitter.setServicePortName(wscontext.getWSCFContext().getWscfport().getWsdlPort().getLocalpart());
+            int mode = Emitter.MODE_ALL;
+            mode = clparser.getMode();
+			
+            // Find the class using the name
+            String seiName = wscontext.getMiscInfo().getJaxrpcSEI();
+            emitter.setCls(seiName);
+            // Generate a full wsdl, or interface & implementation wsdls
+            Utils.prepareTheDir(wsdlFile);
+            if (wsdlImplFilename == null) {
+                emitter.emit(wsdlFile, mode);
+            } else {
+                emitter.emit(wsdlFile, wsdlImplFilename);
+            }
+//			//initiate the wsdlContext
+            this.wscontext.setWSDLContext(new AxisEmitterBasedWSDLContext(emitter.getWSDL()));
+            //parse the ejb-jar.xml here
+            ContextValidator validator = new ContextValidator(wscontext);
+            //initiate the mapper context
+            this.wscontext.setJAXRPCMappingContext(new AxisEmitterBasedJaxRpcMapperContext(emitter, wscontext));
+//			//initiate the wscf context 
+//			this.wscontext.setWSCFContext( new AxisEmitterBasedWSCFContext(emitter, wscontext));
+            //validate the j2ee context
+            validator.validateWithOutWSDL(emitter);
+        } catch (Exception e) {
+            log.error(e);
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntDeployContext.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntDeployContext.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntDeployContext.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntDeployContext.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,45 @@
+/*
+ * 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.utils;
+
+import java.util.HashMap;
+
+import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeDeployContext;
+import org.apache.geronimo.ews.ws4j2ee.toWs.impl.Ws4J2eeDeployContextImpl;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class AntDeployContext extends Ws4J2eeDeployContextImpl implements Ws4J2eeDeployContext {
+    public AntDeployContext(String moduleLocation,
+                            String outputLocation,
+                            ClassLoader parentCL,
+                            String implStyle,
+                            String j2eeContiner) {
+        super(moduleLocation,
+                outputLocation,
+                parentCL,
+                implStyle,
+                j2eeContiner,new HashMap());
+    }
+    public AntDeployContext(String moduleLocation,
+                            String outputLocation,
+                            ClassLoader parentCL) {
+          super(moduleLocation,outputLocation,parentCL);
+
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntExecuter.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntExecuter.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntExecuter.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/AntExecuter.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,220 @@
+/*
+ * 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.utils;
+
+import java.io.File;
+import java.util.jar.JarOutputStream;
+
+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.toWs.GenerationFault;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Ant;
+
+/**
+ * <p>To call this Class and execute a ant task the $JAVA_HOME/lib/tool.jar need
+ * to be in the class path. And so far I use the commnad line to call the Ant.
+ * It should be replaced by call to the Project class.</p>
+ *
+ * @author hemapani
+ */
+public class AntExecuter {
+    private J2EEWebServiceContext wscontext;
+    private JarOutputStream jarFile;
+
+    protected static Log log =
+            LogFactory.getLog(AntExecuter.class.getName());
+
+    public AntExecuter(J2EEWebServiceContext wscontext) {
+        this.wscontext = wscontext;
+    }
+
+    public void execute(String buildFile) throws GenerationFault {
+        //wait till the ant jar added
+        try {
+            Class.forName("com.sun.tools.javac.Main");
+            Project project = new Project();
+            project.setCoreLoader(Thread.currentThread().getContextClassLoader());
+            project.init();
+            Ant ant = new Ant();
+            ant.setProject(project);
+            ant.init();
+            ant.setInheritAll(true);
+            ant.setInheritRefs(true);
+            File file = new File(buildFile);
+            ant.setAntfile(file.getAbsolutePath());
+            ant.setDir(file.getParentFile());
+            ant.execute();
+        } catch (ClassNotFoundException e) {
+            System.out.println("Ant file will not be run programatcally as the " +
+                    "$JAVA_HOME/lib/tool.jar is not in the class path. To run the ant " +
+                    "prgramatically add that jar to classpath");
+//NOW as the code is used by Geronimo we can not afford to let the build
+//failure tests beside if you use maven it works fine. it will find your maven 
+//repository itself :) 
+//        }catch(BuildException e){
+//			System.out.println(e.getMessage() +
+//			"if it is a compile error you may not have set the maven reposiroty " +
+//			"directory in the conf/ws4j2ee.propertites Build fill ignore the faliure");
+        }
+    }
+
+//    public void execute() throws GenerationFault {
+//        try {
+//            Class.forName("com.sun.tools.javac.Main");
+//            File outDir = new File(wscontext.getMiscInfo().getOutPutPath());
+//            File dest = new File(outDir, "build/classes");
+//            compile(outDir, dest);
+//            createModule(outDir, dest);
+//        } catch (IOException e) {
+//            log.error(e);
+//            throw GenerationFault.createGenerationFault(e);
+//        } catch (ClassNotFoundException e) {
+//            System.out.println("Ant file will not be run programatcally as the " +
+//                    "$JAVA_HOME/lib/tool.jar is not in the class path. To run the ant " +
+//                    "prgramatically add that jar to classpath");
+//NOW as the code is used by Geronimo we can not afford to let the build
+//failure tests beside if you use maven it works fine. it will find your maven 
+//repository itself :) 
+//        }catch(BuildException e){
+//          System.out.println(e.getMessage() +
+//          "if it is a compile error you may not have set the maven reposiroty " +
+//          "directory in the conf/ws4j2ee.propertites Build fill ignore the faliure");
+//        }
+//    }
+//
+//    private void createModule(File outDir, File dest) throws IOException {
+//        String jarName = wscontext.getWSDLContext().getTargetPortType().getName().toLowerCase();
+//        int index = jarName.lastIndexOf(".");
+//        if (index > 0) {
+//            jarName = jarName.substring(index + 1);
+//        }
+//        ModulePackager module = new ModulePackager(new File(outDir, jarName + "-ewsImpl.jar"));
+//        module.addClassFiles(dest);
+//        ArrayList classpathelements = wscontext.getMiscInfo().getClasspathElements();
+//        if (classpathelements != null) {
+//            for (int i = 0; i < classpathelements.size(); i++) {
+//                module.addJarFile((File) classpathelements.get(i));
+//            }
+//        }
+//        File dir = outDir;
+//        File[] files = dir.listFiles();
+//        if (files != null) {
+//            for (int i = 0; i < files.length; i++) {
+//                String file = files[i].getName();
+//                if (files[i].isFile() &&
+//                        !(file.endsWith(".jar") ||
+//                        file.endsWith(".zip") ||
+//                        file.endsWith(".war") ||
+//                        file.endsWith(".ear") ||
+//                        file.endsWith(".java"))
+//                ) {
+//                    module.addFileToJar(file, files[i]);
+//                }
+//            }
+//        }
+//        dir = new File(outDir, "META-INF");
+//        files = dir.listFiles();
+//        if (files != null) {
+//            for (int i = 0; i < files.length; i++) {
+//                String file = files[i].getName();
+//                if (files[i].isFile() &&
+//                        !(file.endsWith(".jar") ||
+//                        file.endsWith(".zip") ||
+//                        file.endsWith(".war") ||
+//                        file.endsWith(".ear") ||
+//                        file.endsWith(".java"))
+//                ) {
+//                    module.addFileToJar("META-INF/" + file, files[i]);
+//                }
+//            }
+//        }
+//        module.finalizeJar();
+//    }
+//
+//    private void compile(File outDir, File destDir) throws IOException {
+//        Project project = new Project();
+//        project.init();
+//        project.setCoreLoader(Thread.currentThread().getContextClassLoader());
+//        Javac comp = new Javac();
+//        comp.setProject(project);
+//        destDir.mkdirs();
+//        comp.setDestdir(destDir);
+//        Path path = new Path(project);
+//        path.setLocation(outDir);
+//        comp.setSrcdir(path);
+//        File repository = findMavenRepository();
+//        if (repository != null) {
+//            Path compileClasspath = new Path(project);
+//            FileSet fileset = new FileSet();
+//            fileset.setDir(repository);
+//            fileset.setIncludes("axis/**/*.jar");
+//            fileset.setIncludes("geronimo-spec/**/*.jar");
+//            fileset.setIncludes("geronimo/**/*.jar");
+//            fileset.setIncludes("sec/**/*.jar");
+//            fileset.setIncludes("dom4j/**/*.jar");
+//            fileset.setIncludes("jaxb-ri/**/*.jar");
+//            fileset.setIncludes("xerces/**/*.jar");
+//            fileset.setIncludes("ews/**/*.jar");
+//            fileset.setIncludes("openejb/**/*.jar");
+//            compileClasspath.addFileset(fileset);
+//            comp.setClasspath(compileClasspath);
+//        } else {
+//        }
+//        comp.init();
+//        comp.execute();
+//    }
+//
+//    private File findMavenRepository() throws IOException {
+//        Properties pro = new Properties();
+//        InputStream prpertyIn = null;
+//        File file = new File(GenerationConstants.WS4J2EE_PROPERTY_FILE);
+//        if (file.exists()) {
+//            prpertyIn = new FileInputStream(file);
+//        } else {
+//            file = new File("modules/axis/target/" + GenerationConstants.WS4J2EE_PROPERTY_FILE);
+//            if (file.exists()) {
+//                prpertyIn = new FileInputStream(file);
+//            } else {
+//                file = new File("target/" + GenerationConstants.WS4J2EE_PROPERTY_FILE);
+//                if (file.exists()) {
+//                    prpertyIn = new FileInputStream(file);
+//                } else {
+//                    prpertyIn = getClass().getClassLoader().getResourceAsStream(GenerationConstants.WS4J2EE_PROPERTY_FILE);
+//                }
+//            }
+//        }
+//        if (prpertyIn != null) {
+//            String location = null;
+//            try {
+//                pro.load(prpertyIn);
+//                location = pro.getProperty(GenerationConstants.MAVEN_LOCAL_REPOSITARY);
+//            } finally {
+//                prpertyIn.close();
+//            }
+//            if (location != null) {
+//                File locationFile = new File(location);
+//                if (locationFile.exists()) {
+//                    return locationFile;
+//                }
+//            }
+//        }
+//        return null;
+//    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSTask.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSTask.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSTask.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSTask.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,187 @@
+/*
+ * 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.utils;
+
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
+import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2ee;
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class EWSTask extends Task {
+    private String outDir = ".";
+    private String module = null;
+    private Path classpath;
+    private File root;
+    private boolean compile = false;
+    private String implStyle = GenerationConstants.USE_INTERNALS;
+    private String j2eeContainer = GenerationConstants.GERONIMO_CONTAINER;
+
+    public void execute() throws BuildException {
+        try {
+            if (module == null) {
+                throw new BuildException("the module name not specifed");
+            }
+            root = project.getBaseDir();
+            File moduleFile = new File(root, module);
+            File outDirFile = new File(root, outDir);
+            AntClassLoader cl = new AntClassLoader(getClass().getClassLoader(),
+                    project,
+                    classpath,
+                    true);
+            Thread.currentThread().setContextClassLoader(cl);
+            AntDeployContext deployContext
+                    = new AntDeployContext(moduleFile.getAbsolutePath(),
+                            outDirFile.getAbsolutePath(), cl, implStyle, j2eeContainer);
+            Ws4J2ee ws4j2ee = new Ws4J2ee(deployContext, null);
+            ws4j2ee.generate();
+        } catch (Throwable e) {
+            try {
+                File errorDump = new File(root, "ews.log");
+                PrintWriter pw = new PrintWriter(new FileWriter(errorDump));
+                e.printStackTrace(pw);
+                pw.close();
+                System.out.println(classpath);
+                System.out.println("ERROR .. dump to " + errorDump.getAbsolutePath());
+            } catch (IOException e1) {
+            }
+            throw new BuildException(e);
+        }
+    }
+
+    public Location getLocation() {
+        return super.getLocation();
+    }
+
+    public String getTaskName() {
+        return super.getTaskName();
+    }
+
+    public void init() throws BuildException {
+        super.init();
+    }
+
+    public void setLocation(Location arg0) {
+        super.setLocation(arg0);
+    }
+
+    public void setTaskName(String arg0) {
+        super.setTaskName(arg0);
+    }
+
+    /**
+     * @return
+     */
+    public Path getClasspath() {
+        return classpath;
+    }
+
+    /**
+     * @return
+     */
+    public String getModule() {
+        return module;
+    }
+
+    /**
+     * @return
+     */
+    public String getOutDir() {
+        return outDir;
+    }
+
+    /**
+     * @param path
+     */
+    public void setClasspath(Path path) {
+        classpath = path;
+    }
+
+    /**
+     * @param string
+     */
+    public void setModule(String string) {
+        module = string;
+    }
+
+    /**
+     * @param string
+     */
+    public void setOutDir(String string) {
+        outDir = string;
+    }
+
+    public Path createClasspath() {
+        if (classpath == null) {
+            classpath = new Path(project);
+        }
+        return classpath.createPath();
+    }
+
+    /**
+     * @return
+     */
+    public boolean isCompile() {
+        return compile;
+    }
+
+    /**
+     * @param b
+     */
+    public void setCompile(boolean b) {
+        compile = b;
+    }
+
+    /**
+     * @return
+     */
+    public String getImplStyle() {
+        return implStyle;
+    }
+
+    /**
+     * @return
+     */
+    public String getJ2eeContainer() {
+        return j2eeContainer;
+    }
+
+    /**
+     * @param string
+     */
+    public void setImplStyle(String string) {
+        implStyle = string;
+    }
+
+    /**
+     * @param string
+     */
+    public void setJ2eeContainer(String string) {
+        j2eeContainer = string;
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSUtils.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSUtils.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSUtils.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/EWSUtils.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,70 @@
+/*
+ * 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.utils;
+
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class EWSUtils {
+    protected static Log log =
+            LogFactory.getLog(EWSUtils.class.getName());
+    public static Document createDocument(InputStream in) throws GenerationFault {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setNamespaceAware(true);
+            dbf.setValidating(false);
+            dbf.setExpandEntityReferences(false);
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            EntityResolver er = new EntityResolver() {
+                public InputSource resolveEntity(String publicId,
+                                                 String systemId)
+                        throws SAXException, IOException {
+                    InputStream is = null;
+                    if ("http://java.sun.com/dtd/ejb-jar_2_0.dtd".equalsIgnoreCase(systemId)) {
+                        return getInputSource(EWSUtils.class.getClassLoader().getResourceAsStream("ejb-jar_2_0.dtd"));
+                    } else if ("http://java.sun.com/dtd/web-app_2_3.dtd".equalsIgnoreCase(systemId))
+                        return getInputSource(EWSUtils.class.getClassLoader().getResourceAsStream("web-app_2_3.dtd"));
+                    return null;
+                }
+
+                private InputSource getInputSource(InputStream is) throws IOException {
+                    if (is == null)
+                        throw new IOException("error at the project set up can not find entity");
+                    return new InputSource(is);
+                }
+            };
+            db.setEntityResolver(er);
+            return db.parse(in);
+        } catch (Exception e) {
+            log.error(e);
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/FileUtils.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/FileUtils.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/FileUtils.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/FileUtils.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2003,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.utils;
+
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * @author Srinath Perera (hemapani@opensource.lk)
+ */
+public class FileUtils {
+    protected static Log log =
+            LogFactory.getLog(FileUtils.class.getName());
+            
+    public static void copyFile(File in, File out) throws GenerationFault {
+        try {
+            FileInputStream ins = new FileInputStream(in);
+            FileOutputStream outs = new FileOutputStream(out);
+            copyFile(ins, outs);
+            ins.close();
+            outs.close();
+        } catch (Exception e) {
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+    
+                
+    public static void copyFile(InputStream in, OutputStream out) throws GenerationFault {
+        try {
+            byte[] buf = new byte[1024];
+            int val = in.read(buf);
+            while (val > 0) {
+                out.write(buf, 0, val);
+                val = in.read(buf);
+            }
+            out.close();
+            in.close();
+        } catch (Exception e) {
+            log.error(e);
+            throw GenerationFault.createGenerationFault(e);
+        }
+    }
+
+    public static int configCount = 0;
+    private JarFile ajar;
+    private static byte[] data = new byte[10 * 1024];
+    private String dir;
+
+    public static ArrayList uncompressWar(File outDir, File WarFile) throws IOException {
+        ArrayList urls = new ArrayList();
+        ZipFile zippedWar = new ZipFile(WarFile);
+        Enumeration enties = zippedWar.entries();
+        File classesDir = new File(outDir, "WEB-INF/classes");
+        classesDir.mkdirs();
+        urls.add(classesDir);
+        while (enties.hasMoreElements()) {
+            ZipEntry entry = (ZipEntry) enties.nextElement();
+            if (entry.isDirectory()) {
+            } else {
+                if (entry.getName().startsWith("WEB-INF/classes")) {
+                    File out = new File(outDir, entry.getName());
+                    out.getParentFile().mkdirs();
+                    uncompressFile(zippedWar.getInputStream(entry), out);
+                }
+                if (entry.getName().startsWith("WEB-INF/lib")) {
+                    File outJar = new File(outDir, entry.getName());
+                    uncompressFile(zippedWar.getInputStream(entry), outJar);
+                    urls.add(outJar);
+                }
+            }
+        }
+        return urls;
+    }
+
+    public static void uncompressFile(InputStream is, File outFile) throws IOException {
+        outFile.getParentFile().mkdirs();
+        OutputStream os = new FileOutputStream(outFile);
+        int val = 1;
+        while (true) {
+            val = is.read(data, 0, 1024);
+            if (val < 0 || val == 0)
+                break;
+            os.write(data, 0, val);
+        }
+        is.close();
+        os.close();
+    }
+
+}

Added: webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/MiscFactory.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/MiscFactory.java?rev=230793&view=auto
==============================================================================
--- webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/MiscFactory.java (added)
+++ webservices/ews/trunk/ws4j2ee/src/java/org/apache/geronimo/ews/ws4j2ee/utils/MiscFactory.java Mon Aug  8 05:40:25 2005
@@ -0,0 +1,41 @@
+/*
+ * 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.utils;
+
+import org.apache.geronimo.ews.ws4j2ee.context.InputOutputFile;
+import org.apache.geronimo.ews.ws4j2ee.context.impl.InputOutputFileImpl;
+import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
+
+import java.io.InputStream;
+
+/**
+ * @author hemapani@opensource.lk
+ */
+public class MiscFactory {
+    public static InputOutputFile getInputFile(String fileName,
+                                               InputStream instream) {
+        return new InputOutputFileImpl(fileName, instream);
+    }
+
+    public static InputOutputFile getInputFile(String fileName) throws GenerationFault {
+        return new InputOutputFileImpl(fileName);
+    }
+
+    public static InputOutputFile getInputFile(InputStream instream) {
+        return new InputOutputFileImpl(instream);
+    }
+}



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