Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 60073 invoked from network); 29 Aug 2007 09:14:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Aug 2007 09:14:28 -0000 Received: (qmail 39410 invoked by uid 500); 29 Aug 2007 09:14:23 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 39342 invoked by uid 500); 29 Aug 2007 09:14:23 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 39333 invoked by uid 99); 29 Aug 2007 09:14:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2007 02:14:22 -0700 X-ASF-Spam-Status: No, hits=-98.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2007 09:14:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CD4271A9832; Wed, 29 Aug 2007 02:13:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r570718 - in /incubator/cxf/trunk/tools: common/src/main/java/org/apache/cxf/tools/common/model/ javato/ws/ javato/ws/src/main/java/org/apache/cxf/tools/java2ws/ javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/ javato/ws/sr... Date: Wed, 29 Aug 2007 09:13:38 -0000 To: cxf-commits@incubator.apache.org From: ema@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070829091353.CD4271A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ema Date: Wed Aug 29 02:13:32 2007 New Revision: 570718 URL: http://svn.apache.org/viewvc?rev=570718&view=rev Log: [CXF-894]Initial commit for generating simple frontend server ,client and wsdl Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ServiceInfoToJavaProcessor.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/SimpleFrontEndProcessor.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/AbstractSimpleGenerator.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/Messages.properties incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleImplGenerator.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleSEIGenerator.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/client.vm incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/impl.vm incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/sei.vm incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/server.vm Removed: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/ServiceInfoToJavaProcessor.java Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java incubator/cxf/trunk/tools/javato/ws/pom.xml incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java?rev=570718&r1=570717&r2=570718&view=diff ============================================================================== --- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java (original) +++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java Wed Aug 29 02:13:32 2007 @@ -266,7 +266,7 @@ StringBuffer sb = new StringBuffer(); for (int i = 0; i < parameters.size(); i++) { JavaParameter parameter = parameters.get(i); - if (includeAnnotation) { + if (includeAnnotation && parameter.getAnnotation() != null) { list.add(parameter.getAnnotation().toString()); } sb.setLength(0); Modified: incubator/cxf/trunk/tools/javato/ws/pom.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/pom.xml?rev=570718&r1=570717&r2=570718&view=diff ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/pom.xml (original) +++ incubator/cxf/trunk/tools/javato/ws/pom.xml Wed Aug 29 02:13:32 2007 @@ -46,6 +46,13 @@ ${project.version} + + org.apache.cxf + cxf-rt-frontend-simple + ${project.version} + + + org.apache.cxf Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java?rev=570718&r1=570717&r2=570718&view=diff ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java (original) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java Wed Aug 29 02:13:32 2007 @@ -33,7 +33,8 @@ import org.apache.cxf.tools.common.toolspec.parser.CommandDocument; import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor; import org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor; -import org.apache.cxf.tools.java2wsdl.processor.ServiceInfoToJavaProcessor; +import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.ServiceInfoToJavaProcessor; +import org.apache.cxf.tools.java2wsdl.processor.internal.simple.SimpleFrontEndProcessor; import org.apache.cxf.tools.util.AnnotationUtil; public class JavaToWSContainer extends AbstractCXFToolContainer { @@ -69,6 +70,9 @@ } } else { ft = "simple"; + processor = new SimpleFrontEndProcessor(); + processor.setEnvironment(env); + processor.process(); } } } catch (ToolException ex) { Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,283 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.tools.java2wsdl.processor; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.xml.namespace.QName; +import javax.xml.ws.BindingType; +import javax.xml.ws.soap.SOAPBinding; + +import org.apache.cxf.Bus; +import org.apache.cxf.BusFactory; +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.common.util.StringUtils; +import org.apache.cxf.service.ServiceBuilder; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.tools.common.Processor; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.java2wsdl.generator.AbstractGenerator; +import org.apache.cxf.tools.java2wsdl.generator.WSDLGeneratorFactory; +import org.apache.cxf.tools.java2wsdl.generator.wsdl11.FaultBeanGenerator; +import org.apache.cxf.tools.java2wsdl.generator.wsdl11.WrapperBeanGenerator; +import org.apache.cxf.tools.java2wsdl.processor.internal.ServiceBuilderFactory; +import org.apache.cxf.tools.util.AnnotationUtil; +import org.apache.cxf.wsdl.WSDLConstants; + +public class JavaToWSDLProcessor implements Processor { + private static final Logger LOG = LogUtils.getL7dLogger(JavaToWSDLProcessor.class); + private static final String DEFAULT_ADDRESS = "http://localhost:9090/hello"; + private static final String JAVA_CLASS_PATH = "java.class.path"; + private ToolContext context; + private final List generators = new ArrayList(); + + private void customize(ServiceInfo service) { + if (context.containsKey(ToolConstants.CFG_TNS)) { + String ns = (String)context.get(ToolConstants.CFG_TNS); + service.setTargetNamespace(ns); + } + + if (context.containsKey(ToolConstants.CFG_PORT)) { + String portName = (String)context.get(ToolConstants.CFG_PORT); + EndpointInfo einfo = service.getEndpoints().iterator().next(); + QName qn = new QName(einfo.getName().getNamespaceURI(), portName); + einfo.setName(qn); + } + + if (context.containsKey(ToolConstants.CFG_SERVICENAME)) { + String svName = getServiceName(); + service.setName(new QName(service.getName().getNamespaceURI(), svName)); + } + } + + public void process() throws ToolException { + String oldClassPath = System.getProperty(JAVA_CLASS_PATH); + LOG.log(Level.INFO, "OLD_CP", oldClassPath); + if (context.get(ToolConstants.CFG_CLASSPATH) != null) { + String newCp = (String)context.get(ToolConstants.CFG_CLASSPATH); + System.setProperty(JAVA_CLASS_PATH, newCp + File.pathSeparator + oldClassPath); + LOG.log(Level.INFO, "NEW_CP", newCp); + } + + ServiceBuilder builder = getServiceBuilder(); + ServiceInfo service = builder.createService(); + + customize(service); + + File wsdlFile = getOutputFile(builder.getOutputFile(), + service.getName().getLocalPart() + ".wsdl"); + + File outputDir = getOutputDir(wsdlFile); + if (context.containsKey(ToolConstants.CFG_WSDL)) { + generators.add(getWSDLGenerator(wsdlFile)); + } + if (context.containsKey(ToolConstants.CFG_WRAPPERBEAN)) { + generators.add(getWrapperBeanGenerator()); + generators.add(getFaultBeanGenerator()); + } + generate(service, outputDir); + List serviceList = new ArrayList(); + serviceList.add(service); + context.put(ToolConstants.SERVICE_LIST, serviceList); + System.setProperty(JAVA_CLASS_PATH, oldClassPath); + LOG.log(Level.INFO, "RESUME_CP", oldClassPath); + } + + private AbstractGenerator getWrapperBeanGenerator() { + WrapperBeanGenerator generator = new WrapperBeanGenerator(); + generator.setOutputBase(getSourceDir()); + generator.setCompileToDir(getClassesDir()); + return generator; + } + + private AbstractGenerator getFaultBeanGenerator() { + FaultBeanGenerator generator = new FaultBeanGenerator(); + generator.setOutputBase(getSourceDir()); + generator.setCompileToDir(getClassesDir()); + return generator; + } + + private AbstractGenerator getWSDLGenerator(final File wsdlFile) { + WSDLGeneratorFactory factory = new WSDLGeneratorFactory(); + factory.setWSDLVersion(getWSDLVersion()); + + AbstractGenerator generator = factory.newGenerator(); + generator.setAllowImports(context.containsKey(ToolConstants.CFG_CREATE_XSD_IMPORTS)); + generator.setOutputBase(wsdlFile); + return generator; + } + + public void generate(ServiceInfo service, File output) throws ToolException { + for (AbstractGenerator generator : generators) { + generator.setServiceModel(service); + generator.setBus(getBus()); + generator.generate(output); + } + } + + public ServiceBuilder getServiceBuilder() throws ToolException { + + ServiceBuilderFactory builderFactory = ServiceBuilderFactory.getInstance(); + Class clz = getServiceClass(); + context.put(Class.class, clz); + if (clz.isInterface()) { + context.put(ToolConstants.GEN_FROM_SEI, Boolean.TRUE); + } else { + context.put(ToolConstants.GEN_FROM_SEI, Boolean.FALSE); + } + builderFactory.setServiceClass(clz); + // TODO check if user specify the style from cli arguments + // builderFactory.setStyle(style/from/command/line); + ServiceBuilder builder = builderFactory.newBuilder(); + + builder.validate(); + + if (context.get(ToolConstants.CFG_ADDRESS) != null) { + String address = (String)context.get(ToolConstants.CFG_ADDRESS); + builder.setAddress(address); + } else { + builder.setAddress(DEFAULT_ADDRESS); + } + builder.setTransportId(getTransportId()); + builder.setBus(getBus()); + builder.setBindingId(getBindingId()); + + return builder; + } + + protected String getTransportId() { + if (isSOAP12()) { + return WSDLConstants.SOAP12_NAMESPACE; + } + return WSDLConstants.SOAP11_NAMESPACE; + } + + protected String getBindingId() { + if (isSOAP12()) { + return WSDLConstants.SOAP12_NAMESPACE; + } else { + return WSDLConstants.SOAP11_NAMESPACE; + } + } + + protected boolean isSOAP12() { + if (!this.context.optionSet(ToolConstants.CFG_SOAP12)) { + BindingType bType = getServiceClass().getAnnotation(BindingType.class); + if (bType != null) { + return SOAPBinding.SOAP12HTTP_BINDING.equals(bType.value()); + } + return false; + } + return true; + } + + protected File getOutputDir(File wsdlLocation) { + String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR); + if (dir == null) { + if (wsdlLocation == null) { + dir = "./"; + } else { + dir = wsdlLocation.getParent(); + } + } + return new File(dir); + } + + protected File getOutputFile(File nameFromClz, String defaultOutputFile) { + String output = (String) context.get(ToolConstants.CFG_OUTPUTFILE); + String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR); + if (dir == null) { + dir = "./"; + } + + File result; + if (output != null) { + result = new File(output); + if (!result.isAbsolute()) { + result = new File(new File(dir), output); + } + } else { + result = new File(new File(dir), defaultOutputFile); + } + if (nameFromClz != null) { + result = nameFromClz; + } + + // rename the exising wsdl file + if (result.exists() + && !result.renameTo(new File(result.getParent(), result.getName()))) { + throw new ToolException(new Message("OUTFILE_EXISTS", LOG)); + } + return result; + } + + public Class getServiceClass() { + return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME), + getClass().getClassLoader()); + } + + public WSDLConstants.WSDLVersion getWSDLVersion() { + String version = (String) context.get(ToolConstants.CFG_WSDL_VERSION); + WSDLConstants.WSDLVersion wsVersion = WSDLConstants.getVersion(version); + if (wsVersion == WSDLConstants.WSDLVersion.UNKNOWN) { + wsVersion = WSDLConstants.WSDLVersion.WSDL11; + } + return wsVersion; + } + + public String getServiceName() { + return (String) this.context.get(ToolConstants.CFG_SERVICENAME); + } + + File getSourceDir() { + String dir = (String) this.context.get(ToolConstants.CFG_SOURCEDIR); + if (StringUtils.isEmpty(dir)) { + return null; + } + return new File(dir); + } + File getClassesDir() { + String dir = (String) this.context.get(ToolConstants.CFG_CLASSDIR); + if (StringUtils.isEmpty(dir)) { + return null; + } + return new File(dir); + } + + public Bus getBus() { + return BusFactory.getDefaultBus(); + } + + public void setEnvironment(ToolContext env) { + this.context = env; + } + + public ToolContext getEnvironment() { + return this.context; + } + +} Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties?rev=570718&r1=570717&r2=570718&view=diff ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties (original) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/Messages.properties Wed Aug 29 02:13:32 2007 @@ -17,27 +17,4 @@ # specific language governing permissions and limitations # under the License. # -# -FAIL_TO_CREATE_WSDL_DEFINITION = Fail to create wsdl definition -CREATE_JAXBRICONTEXT_EXCEPTION = Fail to create jaxbRIContext -PART_ALREADY_EXIST = Following part already exist : {0} -ENCODED_USE_NOT_SUPPORTED = Encoded use is not supported in java2wsdl tool -CANNOT_CREATE_SCHEMA_FILE = Can not create schema file -SOAPUSESTYLE_PARAMETERSTYLE_ERROR = {0} : soapbinding use-style and parameter style should be doc-lit-wrapped/rpc-lit/doc-lit-bare -SEI_CLASS_NO_WEBSERVICE_ANNOTATED = SEI class should must annotated with @Webservice -SEI_INTERFACE_NO_WEBSERVICE_ANNOTATED = SEI interface must be annotated with @Webservice -SEI_CLASS_HASNO_PACKAGE = SEI class must be in a package -DOC_BARE_METHOD_CRITERIA1 = Method {0} : must have at most one in or in/out non_header in Doc_bare method -DOC_BARE_METHOD_CRITERIA2 = Method {0} : has a return type of void it must have at most one in/out or out-header parameter in Doc_bare method -DOC_BARE_METHOD_CRITERIA3 = Method {0} : if it has a return type of void it must have at most one in/out or out-header parameter in Doc_bare method -FAIL_TO_BUILD_WSDLMODEL = Fail to build wsdl model -GENERATE_TYPES_ERROR = Generate types error -LOAD_REQUEST_WRAPPER_CLASS_ERROR = Can not load the request wrapper class {0}, please check the @RequestWrapper annotation and see if the class is in your classpath -LOAD_RESPONSE_WRAPPER_CLASS_ERROR = Can not load the response wrapper class {0}, please check the @ResponseWrapper annotation and see if the class is in your classpath - - -OUTFILE_EXISTS = The file [{0}] you are going to generate already exists, please rename - -OLD_CP = Classpath before Java2Wsdl: {0} -NEW_CP = Classpath during Java2Wsdl: {0} -RESUME_CP = Classpath after Java2Wsdl: {0} \ No newline at end of file +# \ No newline at end of file Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ServiceInfoToJavaProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ServiceInfoToJavaProcessor.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ServiceInfoToJavaProcessor.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ServiceInfoToJavaProcessor.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,77 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws; + +import java.util.List; + +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.tools.common.Processor; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.wsdlto.WSDLToJavaContainer; +import org.apache.cxf.tools.wsdlto.core.DataBindingProfile; +import org.apache.cxf.tools.wsdlto.core.FrontEndProfile; +import org.apache.cxf.tools.wsdlto.core.PluginLoader; + +public class ServiceInfoToJavaProcessor implements Processor { + private ToolContext env; + public void process() { + env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws")); + env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb")); + + if (env.optionSet(ToolConstants.CFG_CLIENT)) { + env.put(ToolConstants.CFG_GEN_SERVICE, ToolConstants.CFG_GEN_SERVICE); + env.put(ToolConstants.CFG_GEN_CLIENT, ToolConstants.CFG_GEN_CLIENT); + } + + if (env.optionSet(ToolConstants.CFG_SERVER)) { + env.put(ToolConstants.CFG_GEN_SERVER, ToolConstants.CFG_GEN_SERVER); + Boolean fromSEI = (Boolean)env.get(ToolConstants.GEN_FROM_SEI); + if (env.optionSet(ToolConstants.CFG_IMPL) && fromSEI) { + env.put(ToolConstants.CFG_GEN_IMPL, ToolConstants.CFG_GEN_IMPL); + } + } + + List services = (List)env.get(ToolConstants.SERVICE_LIST); + ServiceInfo serviceInfo = services.get(0); + if (serviceInfo.getEndpoints().iterator().hasNext()) { + EndpointInfo endpointInfo = serviceInfo.getEndpoints().iterator().next(); + env.put(ToolConstants.CFG_WSDLURL, endpointInfo.getAddress() + "?wsdl"); + } else { + env.put(ToolConstants.CFG_WSDLURL, "dummy"); + } + try { + WSDLToJavaContainer w2j = new WSDLToJavaContainer("wsdl2java", null); + w2j.setContext(env); + w2j.execute(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void setEnvironment(ToolContext arg) { + this.env = arg; + } + + + +} Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/SimpleFrontEndProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/SimpleFrontEndProcessor.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/SimpleFrontEndProcessor.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/SimpleFrontEndProcessor.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,130 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2wsdl.processor.internal.simple; + +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; + +import org.apache.cxf.service.factory.ReflectionServiceFactoryBean; +import org.apache.cxf.service.model.InterfaceInfo; +import org.apache.cxf.service.model.OperationInfo; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.tools.common.Processor; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.common.model.JavaException; +import org.apache.cxf.tools.common.model.JavaInterface; +import org.apache.cxf.tools.common.model.JavaMethod; +import org.apache.cxf.tools.common.model.JavaModel; +import org.apache.cxf.tools.common.model.JavaParameter; +import org.apache.cxf.tools.common.model.JavaReturn; +import org.apache.cxf.tools.common.model.JavaType.Style; +import org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator.SimpleClientGenerator; +import org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator.SimpleImplGenerator; +import org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator.SimpleSEIGenerator; +import org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator.SimpleServerGenerator; + +public class SimpleFrontEndProcessor implements Processor { + private ToolContext context; + @SuppressWarnings("unchecked") + public void process() throws ToolException { + List services = (List)context.get(ToolConstants.SERVICE_LIST); + ServiceInfo serviceInfo = services.get(0); + JavaInterface jinf = serviceInfo2JavaInf(serviceInfo); + JavaModel jm = new JavaModel(); + jm.addInterface("inf", jinf); + jinf.setJavaModel(jm); + context.put(JavaModel.class, jm); + SimpleSEIGenerator seiGenerator = new SimpleSEIGenerator(); + seiGenerator.generate(context); + SimpleImplGenerator implGenerator = new SimpleImplGenerator(); + implGenerator.generate(context); + SimpleServerGenerator svrGenerator = new SimpleServerGenerator(); + svrGenerator.generate(context); + SimpleClientGenerator clientGenerator = new SimpleClientGenerator(); + clientGenerator.generate(context); + } + + public void setEnvironment(ToolContext env) { + this.context = env; + } + + public JavaInterface serviceInfo2JavaInf(ServiceInfo service) { + JavaInterface javaInf = new JavaInterface(); + InterfaceInfo inf = service.getInterface(); + for (OperationInfo op : inf.getOperations()) { + JavaMethod jm = new JavaMethod(); + Method m = (Method)op.getProperty(ReflectionServiceFactoryBean.METHOD); + jm.setName(m.getName()); + int i = 0; + for (Type type : m.getGenericParameterTypes()) { + JavaParameter jp = new JavaParameter(); + jp.setClassName(getClassName(type)); + jp.setStyle(Style.IN); + jp.setName("arg" + i++); + jm.addParameter(jp); + } + + for (Type type : m.getGenericExceptionTypes()) { + JavaException jex = new JavaException(); + String className = getClassName(type); + jex.setClassName(className); + jex.setName(className); + jm.addException(jex); + } + + JavaReturn jreturn = new JavaReturn(); + jreturn.setClassName(getClassName(m.getGenericReturnType())); + jreturn.setStyle(Style.OUT); + jm.setReturn(jreturn); + + javaInf.setPackageName(m.getDeclaringClass().getPackage().getName()); + javaInf.addMethod(jm); + javaInf.setName(inf.getName().getLocalPart()); + + jm.getParameterList(); + + + } + return javaInf; + } + + + public String getClassName(Type type) { + if (type instanceof Class) { + Class clz = (Class)type; + if (clz.isArray()) { + return clz.getComponentType().getName() + "[]"; + } else { + return clz.getName(); + } + } else if (type instanceof ParameterizedType) { + return type.toString(); + } else if (type instanceof GenericArrayType) { + return type.toString(); + } + + return ""; + } + +} Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/AbstractSimpleGenerator.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/AbstractSimpleGenerator.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/AbstractSimpleGenerator.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/AbstractSimpleGenerator.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,41 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator; + +import java.util.logging.Logger; + +import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.util.ClassCollector; +import org.apache.cxf.tools.wsdlto.core.AbstractGenerator; + +public abstract class AbstractSimpleGenerator extends AbstractGenerator { + protected static final Logger LOG = LogUtils.getL7dLogger(AbstractSimpleGenerator.class); + protected static final String TEMPLATE_BASE = "org/apache/cxf/tools" + + "/java2wsdl/processor/internal/simple/generator/template"; + + public abstract boolean passthrough(); + + public abstract void generate(ToolContext penv) throws ToolException; + + public void register(final ClassCollector collector, String packageName, String fileName) { + // do nothing + } +} Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/Messages.properties?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/Messages.properties (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/Messages.properties Wed Aug 29 02:13:32 2007 @@ -0,0 +1,32 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# +DIRECTORY_NOT_EXIST = Directory: {0} does not exist +NOT_A_DIRECTORY = {0} is not a directory +FILE_NOT_EXIST = File does not exist +NOT_A_FILE = {0} is not a file +PARAMETER_MISSING = Required parameter is missing + + +FAIL_TO_INITIALIZE_VELOCITY_ENGINE = Failed to initialize velocity engine +TEMPLATE_MISSING = Could not find Velocity template file: {0} +VELOCITY_ENGINE_WRITE_ERRORS = Velocity engine write errors +FAIL_TO_WRITE_FILE = Failed to write file: {0} +FAIL_TO_COMPILE_GENERATE_CODES = Failed to compile generated code Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator; + +import java.util.Map; + +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.common.model.JavaInterface; +import org.apache.cxf.tools.common.model.JavaModel; +import org.apache.cxf.tools.util.ClassCollector; + +public class SimpleClientGenerator extends AbstractSimpleGenerator { + + private static final String CLIENT_TEMPLATE = TEMPLATE_BASE + "/client.vm"; + + public SimpleClientGenerator() { + this.name = ToolConstants.CLT_GENERATOR; + } + + public boolean passthrough() { + /*if (env.optionSet(ToolConstants.CFG_GEN_SEI) || env.optionSet(ToolConstants.CFG_ALL)) { + return false; + } + if (env.optionSet(ToolConstants.CFG_GEN_ANT) || env.optionSet(ToolConstants.CFG_GEN_TYPES) + || env.optionSet(ToolConstants.CFG_GEN_CLIENT) || env.optionSet(ToolConstants.CFG_GEN_IMPL) + || env.optionSet(ToolConstants.CFG_GEN_SERVER) || env.optionSet(ToolConstants.CFG_GEN_SERVICE) + || env.optionSet(ToolConstants.CFG_GEN_FAULT)) { + return true; + }*/ + + return false; + + } + + + public void generate(ToolContext penv) throws ToolException { + this.env = penv; + JavaModel javaModel = env.get(JavaModel.class); + + if (passthrough()) { + return; + } + + Map interfaces = javaModel.getInterfaces(); + + if (interfaces.size() == 0) { + ServiceInfo serviceInfo = (ServiceInfo)env.get(ServiceInfo.class); + String wsdl = serviceInfo.getDescription().getBaseURI(); + Message msg = new Message("CAN_NOT_GEN_SEI", LOG, wsdl); + if (penv.isVerbose()) { + System.out.println(msg.toString()); + } + return; + } + for (JavaInterface intf : interfaces.values()) { + clearAttributes(); + setAttributes("intf", intf); + setCommonAttributes(); + + doWrite(CLIENT_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName() + "Client")); + + } + } + + public void register(final ClassCollector collector, String packageName, String fileName) { + + } +} \ No newline at end of file Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleImplGenerator.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleImplGenerator.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleImplGenerator.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleImplGenerator.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator; + +import java.util.Map; + +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.common.model.JavaInterface; +import org.apache.cxf.tools.common.model.JavaModel; +import org.apache.cxf.tools.util.ClassCollector; + +public class SimpleImplGenerator extends AbstractSimpleGenerator { + + private static final String IMPL_TEMPLATE = TEMPLATE_BASE + "/impl.vm"; + + public SimpleImplGenerator() { + this.name = ToolConstants.IMPL_GENERATOR; + } + + public boolean passthrough() { + /*if (env.optionSet(ToolConstants.CFG_GEN_SEI) || env.optionSet(ToolConstants.CFG_ALL)) { + return false; + } + if (env.optionSet(ToolConstants.CFG_GEN_ANT) || env.optionSet(ToolConstants.CFG_GEN_TYPES) + || env.optionSet(ToolConstants.CFG_GEN_CLIENT) || env.optionSet(ToolConstants.CFG_GEN_IMPL) + || env.optionSet(ToolConstants.CFG_GEN_SERVER) || env.optionSet(ToolConstants.CFG_GEN_SERVICE) + || env.optionSet(ToolConstants.CFG_GEN_FAULT)) { + return true; + }*/ + + return false; + + } + + + public void generate(ToolContext penv) throws ToolException { + this.env = penv; + JavaModel javaModel = env.get(JavaModel.class); + + if (passthrough()) { + return; + } + + Map interfaces = javaModel.getInterfaces(); + + if (interfaces.size() == 0) { + ServiceInfo serviceInfo = (ServiceInfo)env.get(ServiceInfo.class); + String wsdl = serviceInfo.getDescription().getBaseURI(); + Message msg = new Message("CAN_NOT_GEN_SEI", LOG, wsdl); + if (penv.isVerbose()) { + System.out.println(msg.toString()); + } + return; + } + for (JavaInterface intf : interfaces.values()) { + clearAttributes(); + setAttributes("intf", intf); + setCommonAttributes(); + + doWrite(IMPL_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName() + "Impl")); + + } + } + + public void register(final ClassCollector collector, String packageName, String fileName) { + + } +} \ No newline at end of file Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleSEIGenerator.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleSEIGenerator.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleSEIGenerator.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleSEIGenerator.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator; + +import java.util.Map; + +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.common.model.JavaInterface; +import org.apache.cxf.tools.common.model.JavaModel; +import org.apache.cxf.tools.util.ClassCollector; + +public class SimpleSEIGenerator extends AbstractSimpleGenerator { + + private static final String SEI_TEMPLATE = TEMPLATE_BASE + "/sei.vm"; + + public SimpleSEIGenerator() { + this.name = ToolConstants.SEI_GENERATOR; + } + + public boolean passthrough() { + /*if (env.optionSet(ToolConstants.CFG_GEN_SEI) || env.optionSet(ToolConstants.CFG_ALL)) { + return false; + } + if (env.optionSet(ToolConstants.CFG_GEN_ANT) || env.optionSet(ToolConstants.CFG_GEN_TYPES) + || env.optionSet(ToolConstants.CFG_GEN_CLIENT) || env.optionSet(ToolConstants.CFG_GEN_IMPL) + || env.optionSet(ToolConstants.CFG_GEN_SERVER) || env.optionSet(ToolConstants.CFG_GEN_SERVICE) + || env.optionSet(ToolConstants.CFG_GEN_FAULT)) { + return true; + }*/ + + return false; + + } + + + public void generate(ToolContext penv) throws ToolException { + this.env = penv; + JavaModel javaModel = env.get(JavaModel.class); + + if (passthrough()) { + return; + } + + Map interfaces = javaModel.getInterfaces(); + + if (interfaces.size() == 0) { + ServiceInfo serviceInfo = (ServiceInfo)env.get(ServiceInfo.class); + String wsdl = serviceInfo.getDescription().getBaseURI(); + Message msg = new Message("CAN_NOT_GEN_SEI", LOG, wsdl); + if (penv.isVerbose()) { + System.out.println(msg.toString()); + } + return; + } + for (JavaInterface intf : interfaces.values()) { + clearAttributes(); + setAttributes("intf", intf); + setCommonAttributes(); + + doWrite(SEI_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName())); + + } + } + + public void register(final ClassCollector collector, String packageName, String fileName) { + + } +} \ No newline at end of file Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java Wed Aug 29 02:13:32 2007 @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator; + +import java.util.Map; + +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.common.model.JavaInterface; +import org.apache.cxf.tools.common.model.JavaModel; +import org.apache.cxf.tools.util.ClassCollector; + +/** + * + */ +public class SimpleServerGenerator extends AbstractSimpleGenerator { + + private static final String SERVER_TEMPLATE = TEMPLATE_BASE + "/server.vm"; + + public SimpleServerGenerator() { + this.name = ToolConstants.SVR_GENERATOR; + } + + public boolean passthrough() { + /*if (env.optionSet(ToolConstants.CFG_GEN_SEI) || env.optionSet(ToolConstants.CFG_ALL)) { + return false; + } + if (env.optionSet(ToolConstants.CFG_GEN_ANT) || env.optionSet(ToolConstants.CFG_GEN_TYPES) + || env.optionSet(ToolConstants.CFG_GEN_CLIENT) || env.optionSet(ToolConstants.CFG_GEN_IMPL) + || env.optionSet(ToolConstants.CFG_GEN_SERVER) || env.optionSet(ToolConstants.CFG_GEN_SERVICE) + || env.optionSet(ToolConstants.CFG_GEN_FAULT)) { + return true; + }*/ + + return false; + + } + + + public void generate(ToolContext penv) throws ToolException { + this.env = penv; + JavaModel javaModel = env.get(JavaModel.class); + + if (passthrough()) { + return; + } + + Map interfaces = javaModel.getInterfaces(); + + if (interfaces.size() == 0) { + ServiceInfo serviceInfo = (ServiceInfo)env.get(ServiceInfo.class); + String wsdl = serviceInfo.getDescription().getBaseURI(); + Message msg = new Message("CAN_NOT_GEN_SEI", LOG, wsdl); + if (penv.isVerbose()) { + System.out.println(msg.toString()); + } + return; + } + for (JavaInterface intf : interfaces.values()) { + clearAttributes(); + setAttributes("intf", intf); + setAttributes("implClass", intf.getFullClassName() + "Impl"); + setCommonAttributes(); + + doWrite(SERVER_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName() + "Server")); + + } + } + + public void register(final ClassCollector collector, String packageName, String fileName) { + + } +} \ No newline at end of file Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/client.vm URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/client.vm?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/client.vm (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/client.vm Wed Aug 29 02:13:32 2007 @@ -0,0 +1,45 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. + +/** + * Please modify this class to meet your needs + * This class is not complete + */ + +package $intf.PackageName; +import org.apache.cxf.bus.CXFBusFactory; +import org.apache.cxf.frontend.ServerFactoryBean; +import org.apache.cxf.aegis.databinding.AegisDatabinding; + +/** + * This cla ss was generated by the CXF $version + * $curr entdate + * Generated source version: $version + * + */ + public class ${intf.Name}Client { + public static void main(String[] args) { + ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean(); + ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean(); + clientBean.setAddress("http://localhost:8088/Hello"); + clientBean.setBus(CXFBusFactory.getDefaultBus()); + clientBean.setTransportId("http://schemas.xmlsoap.org/wsdl/http/"); + clientBean.setServiceClass(${inf.ClassName}.class); + proxyFactory.getServiceFactory().setDataBinding(new AegisDatabinding()); + ${intf.FullClassName} client = (${intf.FullClassName})proxyFactory.create(); + } + } \ No newline at end of file Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/impl.vm URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/impl.vm?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/impl.vm (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/impl.vm Wed Aug 29 02:13:32 2007 @@ -0,0 +1,63 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. + +/** + * Please modify this class to meet your needs + * This class is not complete + */ + +package $intf.PackageName; + +/** + * This cla ss was generated by the CXF $version + * $curr entdate + * Generated source version: $version + * + */ + +public class ${intf.Name}Impl implements $intf.Name { +#foreach ($method in $intf.Methods) + public $method.return.ClassName ${method.Name}(#if($method.ParameterList.size() == 0))#end#if($method.ParameterList.size() != 0)#foreach ($param in ${method.ParameterList})$param#end)#end#if($method.Exceptions.size() > 0) throws#foreach($exception in $method.Exceptions) $exception.ClassName#if($method.Exceptions.size() != $velocityCount),#end#end#end { +#foreach ($parameter in $method.Parameters) +#if ($parameter.Style.toString() == "IN") + System.out.println($parameter.Name);#end#end + #foreach ($parameter in $method.Parameter) + #if ($parameter.Style.toString() == "OUT") + #set($paramValueName = "${parameter.Name}Value") + ${parameter.writeDefaultValue(${out}, " ", ${method.Name}, ${paramValueName})} + ${parameter.Name}.value = ${paramValueName}; + #end + #end + + #if ($method.return.ClassName != "void")try { + ${method.return.writeDefaultValue(${out}, " ", ${method.Name}, "_return")} + return _return; + } catch (Exception ex) { + ex.printStackTrace(); + throw new RuntimeException(ex); + } + #end + +#if ($method.Exceptions.size() > 0) +#foreach($exception in $method.Exceptions) + //throw new ${exception.ClassName}("${exception.Name}..."); +#end +#end + } + +#end +} \ No newline at end of file Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/sei.vm URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/sei.vm?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/sei.vm (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/sei.vm Wed Aug 29 02:13:32 2007 @@ -0,0 +1,48 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. + +package $intf.PackageName; + +import javax.jws.WebParam.Mode; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding.Style; +import javax.jws.soap.SOAPBinding; +#foreach ($import in $intf.Imports) +import ${import}; +#end + +/** + * This class was generated by the CXF $version + * $currentdate + * Generated source version: $version + * + */ + + +public interface $intf.Name { +#foreach ($method in $intf.Methods) + + public $method.return.ClassName ${method.Name}(#if($method.ParameterList.size() == 0))#end +#if($method.ParameterList.size() != 0) + +#foreach ($param in ${method.ParameterList}) + $param +#end + )#end#if($method.Exceptions.size() > 0) throws#foreach($exception in $method.Exceptions) $exception.ClassName#if($method.Exceptions.size() != $velocityCount),#end#end#end; +#end +} Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/server.vm URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/server.vm?rev=570718&view=auto ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/server.vm (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/template/server.vm Wed Aug 29 02:13:32 2007 @@ -0,0 +1,47 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. + +/** + * Please modify this class to meet your needs + * This class is not complete + */ + +package $intf.PackageName; +import org.apache.cxf.bus.CXFBusFactory; +import org.apache.cxf.frontend.ServerFactoryBean; +import org.apache.cxf.aegis.databinding.AegisDatabinding; + +/** + * This cla ss was generated by the CXF $version + * $curr entdate + * Generated source version: $version + * + */ + public class ${intf.Name}Server { + public static void main(String[] args) { + ServerFactoryBean svrBean = new ServerFactoryBean(); + svrBean.setBus(CXFBusFactory.getDefaultBus()); + svrBean.setAddress("http://localhost:8080/Hello"); + svrBean.setTransportId("http://schemas.xmlsoap.org/wsdl/http/"); + svrBean.setBindingId("http://schemas.xmlsoap.org/soap/"); + svrBean.setServiceBean(new ${implClass}()); + svrBean.getServiceFactory().setDataBinding(new AegisDatabinding()); + svrBean.setStart(true); + svrBean.create(); + System.out.println("Server started"); + } + } \ No newline at end of file Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=570718&r1=570717&r2=570718&view=diff ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java (original) +++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java Wed Aug 29 02:13:32 2007 @@ -69,6 +69,18 @@ assertTrue("wsdl is not generated", wsdlFile.exists()); } + @Test + public void testSimple() throws Exception { + String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/tmp.wsdl", "-verbose", + "-d", output.getPath(), + "-frontend", "simple", + "org.apache.hello_world_doc_lit.Greeter"}; + JavaToWS.main(args); + File wsdlFile = new File(output.getPath() + "/tmp.wsdl"); + assertTrue("wsdl is not generated", wsdlFile.exists()); + } + + @Ignore @@ -106,7 +118,7 @@ assertTrue("GreeterImpl.java is not generated", impl.exists()); } - @Test + @Ignore public void testGenWrapperBean() throws Exception { String[] args = new String[] {"-d", output.getPath(), "-wrapperbean",