You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/03/28 17:35:29 UTC
svn commit: r642284 [5/8] - in /incubator/cxf/branches/2.0.x-fixes:
benchmark/performance/soap_http_doc_lit/
benchmark/performance/soap_http_doc_lit/src/org/apache/cxf/performance/complex_type/client/
benchmark/performance/soap_http_doc_lit/src/org/apa...
Modified: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java?rev=642284&r1=642283&r2=642284&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java Fri Mar 28 09:33:52 2008
@@ -1,133 +1,133 @@
-/**
- * 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.java2ws;
-
-import java.util.HashSet;
-import java.util.logging.Logger;
-
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.tools.common.AbstractCXFToolContainer;
-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.toolspec.ToolSpec;
-import org.apache.cxf.tools.common.toolspec.parser.BadUsageException;
-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.internal.jaxws.JAXWSFrontEndProcessor;
-import org.apache.cxf.tools.java2wsdl.processor.internal.simple.SimpleFrontEndProcessor;
-import org.apache.cxf.tools.util.AnnotationUtil;
-
-public class JavaToWSContainer extends AbstractCXFToolContainer {
- private static final Logger LOG = LogUtils.getL7dLogger(JavaToWSContainer.class);
- private static final String TOOL_NAME = "java2ws";
-
- public JavaToWSContainer(ToolSpec toolspec) throws Exception {
- super(TOOL_NAME, toolspec);
- }
-
- public void execute(boolean exitOnFinish) throws ToolException {
- Processor processor = null;
- ErrorVisitor errors = new ErrorVisitor();
- try {
- super.execute(exitOnFinish);
- checkParams(errors);
- if (!hasInfoOption()) {
- ToolContext env = new ToolContext();
- env.setParameters(getParametersMap(new HashSet()));
- if (isVerboseOn()) {
- env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
- }
- processor = new JavaToWSDLProcessor();
- processor.setEnvironment(env);
- processor.process();
- String ft = (String)env.get(ToolConstants.CFG_FRONTEND);
- if (ft == null || "jaxws".equals(ft.toLowerCase())) {
- ft = "jaxws";
- env.put(ToolConstants.CFG_FRONTEND, "jaxws");
- if (env.optionSet(ToolConstants.CFG_SERVER) || env.optionSet(ToolConstants.CFG_CLIENT)) {
- processor = new JAXWSFrontEndProcessor();
- processor.setEnvironment(env);
- processor.process();
- }
- } else {
- ft = "simple";
- env.put(ToolConstants.CFG_FRONTEND, "simple");
- processor = new SimpleFrontEndProcessor();
- processor.setEnvironment(env);
- processor.process();
- }
- }
- } catch (ToolException ex) {
- if (ex.getCause() instanceof BadUsageException) {
- printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
- if (isVerboseOn()) {
- ex.printStackTrace();
- }
- }
- throw ex;
- } catch (Exception ex) {
- System.err.println("Error: " + ex.getMessage());
- System.err.println();
- if (isVerboseOn()) {
- ex.printStackTrace();
- }
-
- throw new ToolException(ex.getMessage(), ex.getCause());
- } finally {
- tearDown();
- }
- }
-
- public Class getServiceClass(ToolContext context) {
- return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME), getClass()
- .getClassLoader());
- }
-
- public void checkParams(ErrorVisitor errs) throws ToolException {
-
- CommandDocument doc = super.getCommandDocument();
-
- if (doc.hasParameter("frontend")) {
- String ft = doc.getParameter("frontend");
- if (!"simple".equalsIgnoreCase(ft) && !"jaxws".equalsIgnoreCase(ft)) {
- Message msg = new Message("INVALID_FORNTEND", LOG, new Object[]{ft});
- errs.add(new ErrorVisitor.UserError(msg.toString()));
- }
- }
-
-
- if (doc.hasParameter("wrapperbean")) {
- String ft = doc.getParameter("frontend");
- if (ft != null && !"jaxws".equalsIgnoreCase(ft)) {
- Message msg = new Message("CANT_GEN_WRAPPERBEAN", LOG);
- errs.add(new ErrorVisitor.UserError(msg.toString()));
- }
- }
-
- if (errs.getErrors().size() > 0) {
- Message msg = new Message("PARAMETER_MISSING", LOG);
- throw new ToolException(msg, new BadUsageException(getUsage(), errs));
- }
-
- }
-}
+/**
+ * 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.java2ws;
+
+import java.util.HashSet;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.tools.common.AbstractCXFToolContainer;
+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.toolspec.ToolSpec;
+import org.apache.cxf.tools.common.toolspec.parser.BadUsageException;
+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.internal.jaxws.JAXWSFrontEndProcessor;
+import org.apache.cxf.tools.java2wsdl.processor.internal.simple.SimpleFrontEndProcessor;
+import org.apache.cxf.tools.util.AnnotationUtil;
+
+public class JavaToWSContainer extends AbstractCXFToolContainer {
+ private static final Logger LOG = LogUtils.getL7dLogger(JavaToWSContainer.class);
+ private static final String TOOL_NAME = "java2ws";
+
+ public JavaToWSContainer(ToolSpec toolspec) throws Exception {
+ super(TOOL_NAME, toolspec);
+ }
+
+ public void execute(boolean exitOnFinish) throws ToolException {
+ Processor processor = null;
+ ErrorVisitor errors = new ErrorVisitor();
+ try {
+ super.execute(exitOnFinish);
+ checkParams(errors);
+ if (!hasInfoOption()) {
+ ToolContext env = new ToolContext();
+ env.setParameters(getParametersMap(new HashSet()));
+ if (isVerboseOn()) {
+ env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
+ }
+ processor = new JavaToWSDLProcessor();
+ processor.setEnvironment(env);
+ processor.process();
+ String ft = (String)env.get(ToolConstants.CFG_FRONTEND);
+ if (ft == null || "jaxws".equals(ft.toLowerCase())) {
+ ft = "jaxws";
+ env.put(ToolConstants.CFG_FRONTEND, "jaxws");
+ if (env.optionSet(ToolConstants.CFG_SERVER) || env.optionSet(ToolConstants.CFG_CLIENT)) {
+ processor = new JAXWSFrontEndProcessor();
+ processor.setEnvironment(env);
+ processor.process();
+ }
+ } else {
+ ft = "simple";
+ env.put(ToolConstants.CFG_FRONTEND, "simple");
+ processor = new SimpleFrontEndProcessor();
+ processor.setEnvironment(env);
+ processor.process();
+ }
+ }
+ } catch (ToolException ex) {
+ if (ex.getCause() instanceof BadUsageException) {
+ printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
+ if (isVerboseOn()) {
+ ex.printStackTrace();
+ }
+ }
+ throw ex;
+ } catch (Exception ex) {
+ System.err.println("Error: " + ex.getMessage());
+ System.err.println();
+ if (isVerboseOn()) {
+ ex.printStackTrace();
+ }
+
+ throw new ToolException(ex.getMessage(), ex.getCause());
+ } finally {
+ tearDown();
+ }
+ }
+
+ public Class getServiceClass(ToolContext context) {
+ return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME), getClass()
+ .getClassLoader());
+ }
+
+ public void checkParams(ErrorVisitor errs) throws ToolException {
+
+ CommandDocument doc = super.getCommandDocument();
+
+ if (doc.hasParameter("frontend")) {
+ String ft = doc.getParameter("frontend");
+ if (!"simple".equalsIgnoreCase(ft) && !"jaxws".equalsIgnoreCase(ft)) {
+ Message msg = new Message("INVALID_FORNTEND", LOG, new Object[]{ft});
+ errs.add(new ErrorVisitor.UserError(msg.toString()));
+ }
+ }
+
+
+ if (doc.hasParameter("wrapperbean")) {
+ String ft = doc.getParameter("frontend");
+ if (ft != null && !"jaxws".equalsIgnoreCase(ft)) {
+ Message msg = new Message("CANT_GEN_WRAPPERBEAN", LOG);
+ errs.add(new ErrorVisitor.UserError(msg.toString()));
+ }
+ }
+
+ if (errs.getErrors().size() > 0) {
+ Message msg = new Message("PARAMETER_MISSING", LOG);
+ throw new ToolException(msg, new BadUsageException(getUsage(), errs));
+ }
+
+ }
+}
Propchange: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties?rev=642284&r1=642283&r2=642284&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties Fri Mar 28 09:33:52 2008
@@ -1,28 +1,28 @@
-#
-#
-# 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 or not valid
-INVALID_FORNTEND = \ "{0}" is not a valid frontend, java2ws only supports jaxws and simple frontend.
-CANT_GEN_WRAPPERBEAN = Wrapperbean only needs to be generated for jaxws front end.
-
+#
+#
+# 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 or not valid
+INVALID_FORNTEND = \ "{0}" is not a valid frontend, java2ws only supports jaxws and simple frontend.
+CANT_GEN_WRAPPERBEAN = Wrapperbean only needs to be generated for jaxws front end.
+
Propchange: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml?rev=642284&r1=642283&r2=642284&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml Fri Mar 28 09:33:52 2008
@@ -1,221 +1,221 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<!-- The xhtml namespace is for usage documentation -->
-<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
- xsi:schemaLocation="http://cxf.apache.org/Xutil/ToolSpecification http://cxf.apache.org/schema/xutil/tool-specification.xsd"
- xmlns="http://cxf.apache.org/Xutil/ToolSpecification"
- xmlns:ts="http://cxf.apache.org/Xutil/ToolSpecification">
-
- <annotation>
- Examples :
-
- java2ws org.apache.hello_world_soap_http.Greeter java2ws -cp
- ./tmp org.apache.hello_world_soap_http.Greeter java2ws -o
- hello.wsdl org.apache.hello_world_soap_http.Greeter java2ws -o
- hello.wsdl -t http://cxf.apache.org
- org.apache.hello_world_soap_http.Greeter
- </annotation>
- <usage>
-
- <optionGroup id="options">
- <option id="frontend" maxOccurs="1">
- <annotation>specify which frontend should be use, support jaxws and simple frontend.</annotation>
- <switch>frontend</switch>
- <associatedArgument placement="afterSpace">
- <annotation>jaxws-or-simple</annotation>
- </associatedArgument>
- </option>
-
- <option id="wrapperbean" maxOccurs="1">
- <annotation>Specify to genearte wrapper and fault bean</annotation>
- <switch>wrapperbean</switch>
- </option>
-
- <option id="client" maxOccurs="1">
- <annotation>Specify to genearte client side code</annotation>
- <switch>client</switch>
- </option>
-
- <option id="server" maxOccurs="1">
- <annotation>Specify to genearte server side code</annotation>
- <switch>server</switch>
- </option>
-
- <option id="impl" maxOccurs="1">
- <annotation>Specify to generate impl class when "-server" flag is specified</annotation>
- <switch>impl</switch>
- </option>
-
- <option id="wsdl" maxOccurs="1">
- <annotation>Specify generating wsdl</annotation>
- <switch>wsdl</switch>
- </option>
-
- <option id="outputfile" maxOccurs="1">
- <annotation>
- Specify the output wsdl file name
- </annotation>
- <switch>o</switch>
- <associatedArgument placement="afterSpace">
- <annotation>output-file</annotation>
- </associatedArgument>
- </option>
-
- <option id="outputdir" maxOccurs="1">
- <annotation>
- The directory in which the output files are placed
- </annotation>
- <switch>d</switch>
- <associatedArgument placement="afterSpace">
- <annotation>output-directory</annotation>
- </associatedArgument>
- </option>
-
- <option id="sourcedir" maxOccurs="1">
- <annotation>
- The directory in which the generated source files
- are placed
- </annotation>
- <switch>s</switch>
- <associatedArgument placement="afterSpace">
- <annotation>source-directory</annotation>
- </associatedArgument>
- </option>
- <option id="classdir" maxOccurs="1">
- <annotation>
- The directory in which the generated sources are
- compiled into. If not specified, the files are not
- compiled.
- </annotation>
- <switch>classdir</switch>
- <associatedArgument placement="afterSpace">
- <annotation>compile-classes-directory</annotation>
- </associatedArgument>
- </option>
-
- <option id="classpath" maxOccurs="1">
- <annotation>
- Specify the SEI and types class search path of
- directories and zip/jar files
- </annotation>
- <switch>cp</switch>
- <associatedArgument placement="afterSpace">
- <annotation>class-path</annotation>
- </associatedArgument>
- </option>
-
- <option id="soap12" maxOccurs="1">
- <annotation>
- Specify to generate SOAP 1.2 binding
- </annotation>
- <switch>soap12</switch>
- </option>
-
- <option id="tns" maxOccurs="1">
- <annotation>
- Specify the target namespace to use in the wsdl
- </annotation>
- <switch>t</switch>
- <associatedArgument placement="afterSpace">
- <annotation>target-namespace</annotation>
- </associatedArgument>
- </option>
-
- <option id="servicename" maxOccurs="1">
- <annotation>
- Specify the service name to use in the generated
- wsdl
- </annotation>
- <switch>servicename</switch>
- <associatedArgument placement="afterSpace">
- <annotation>service-name</annotation>
- </associatedArgument>
- </option>
-
- <option id="port" maxOccurs="1">
- <annotation>
- Specify the port name to use in the generated wsdl
- </annotation>
- <switch>portname</switch>
- <associatedArgument placement="afterSpace">
- <annotation>port-name</annotation>
- </associatedArgument>
- </option>
-
- <option id="address" maxOccurs="1">
- <annotation>
- Specify the port address
- </annotation>
- <switch>address</switch>
- <associatedArgument placement="afterSpace">
- <annotation>address</annotation>
- </associatedArgument>
- </option>
-
-
- <option id="createxsdimports" maxOccurs="1">
- <annotation>
- Output schemas to separate files and use imports to
- load them instead of inlining them into the wsdl.
- </annotation>
- <switch>createxsdimports</switch>
- </option>
-
- </optionGroup>
-
- <optionGroup id="common_options">
- <option id="help" maxOccurs="1">
- <annotation>
- Display detailed information for options.
- </annotation>
- <switch>h</switch>
- <switch>?</switch>
- <switch>help</switch>
- </option>
-
- <option id="version">
- <annotation>
- Display the version of the tool.
- </annotation>
- <switch>v</switch>
- </option>
-
- <option id="verbose">
- <annotation>Verbose mode</annotation>
- <switch>verbose</switch>
- <switch>V</switch>
- </option>
-
- <option id="quiet">
- <annotation>Quiet mode</annotation>
- <switch>quiet</switch>
- <switch>q</switch>
- </option>
-
-
- </optionGroup>
-
- <argument id="classname" minOccurs="1" maxOccurs="1">
- <annotation>SEI class name</annotation>
- </argument>
- </usage>
-</toolspec>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- The xhtml namespace is for usage documentation -->
+<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
+ xsi:schemaLocation="http://cxf.apache.org/Xutil/ToolSpecification http://cxf.apache.org/schema/xutil/tool-specification.xsd"
+ xmlns="http://cxf.apache.org/Xutil/ToolSpecification"
+ xmlns:ts="http://cxf.apache.org/Xutil/ToolSpecification">
+
+ <annotation>
+ Examples :
+
+ java2ws org.apache.hello_world_soap_http.Greeter java2ws -cp
+ ./tmp org.apache.hello_world_soap_http.Greeter java2ws -o
+ hello.wsdl org.apache.hello_world_soap_http.Greeter java2ws -o
+ hello.wsdl -t http://cxf.apache.org
+ org.apache.hello_world_soap_http.Greeter
+ </annotation>
+ <usage>
+
+ <optionGroup id="options">
+ <option id="frontend" maxOccurs="1">
+ <annotation>specify which frontend should be use, support jaxws and simple frontend.</annotation>
+ <switch>frontend</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>jaxws-or-simple</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="wrapperbean" maxOccurs="1">
+ <annotation>Specify to genearte wrapper and fault bean</annotation>
+ <switch>wrapperbean</switch>
+ </option>
+
+ <option id="client" maxOccurs="1">
+ <annotation>Specify to genearte client side code</annotation>
+ <switch>client</switch>
+ </option>
+
+ <option id="server" maxOccurs="1">
+ <annotation>Specify to genearte server side code</annotation>
+ <switch>server</switch>
+ </option>
+
+ <option id="impl" maxOccurs="1">
+ <annotation>Specify to generate impl class when "-server" flag is specified</annotation>
+ <switch>impl</switch>
+ </option>
+
+ <option id="wsdl" maxOccurs="1">
+ <annotation>Specify generating wsdl</annotation>
+ <switch>wsdl</switch>
+ </option>
+
+ <option id="outputfile" maxOccurs="1">
+ <annotation>
+ Specify the output wsdl file name
+ </annotation>
+ <switch>o</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>output-file</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="outputdir" maxOccurs="1">
+ <annotation>
+ The directory in which the output files are placed
+ </annotation>
+ <switch>d</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>output-directory</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="sourcedir" maxOccurs="1">
+ <annotation>
+ The directory in which the generated source files
+ are placed
+ </annotation>
+ <switch>s</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>source-directory</annotation>
+ </associatedArgument>
+ </option>
+ <option id="classdir" maxOccurs="1">
+ <annotation>
+ The directory in which the generated sources are
+ compiled into. If not specified, the files are not
+ compiled.
+ </annotation>
+ <switch>classdir</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>compile-classes-directory</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="classpath" maxOccurs="1">
+ <annotation>
+ Specify the SEI and types class search path of
+ directories and zip/jar files
+ </annotation>
+ <switch>cp</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>class-path</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="soap12" maxOccurs="1">
+ <annotation>
+ Specify to generate SOAP 1.2 binding
+ </annotation>
+ <switch>soap12</switch>
+ </option>
+
+ <option id="tns" maxOccurs="1">
+ <annotation>
+ Specify the target namespace to use in the wsdl
+ </annotation>
+ <switch>t</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>target-namespace</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="servicename" maxOccurs="1">
+ <annotation>
+ Specify the service name to use in the generated
+ wsdl
+ </annotation>
+ <switch>servicename</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>service-name</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="port" maxOccurs="1">
+ <annotation>
+ Specify the port name to use in the generated wsdl
+ </annotation>
+ <switch>portname</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>port-name</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="address" maxOccurs="1">
+ <annotation>
+ Specify the port address
+ </annotation>
+ <switch>address</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>address</annotation>
+ </associatedArgument>
+ </option>
+
+
+ <option id="createxsdimports" maxOccurs="1">
+ <annotation>
+ Output schemas to separate files and use imports to
+ load them instead of inlining them into the wsdl.
+ </annotation>
+ <switch>createxsdimports</switch>
+ </option>
+
+ </optionGroup>
+
+ <optionGroup id="common_options">
+ <option id="help" maxOccurs="1">
+ <annotation>
+ Display detailed information for options.
+ </annotation>
+ <switch>h</switch>
+ <switch>?</switch>
+ <switch>help</switch>
+ </option>
+
+ <option id="version">
+ <annotation>
+ Display the version of the tool.
+ </annotation>
+ <switch>v</switch>
+ </option>
+
+ <option id="verbose">
+ <annotation>Verbose mode</annotation>
+ <switch>verbose</switch>
+ <switch>V</switch>
+ </option>
+
+ <option id="quiet">
+ <annotation>Quiet mode</annotation>
+ <switch>quiet</switch>
+ <switch>q</switch>
+ </option>
+
+
+ </optionGroup>
+
+ <argument id="classname" minOccurs="1" maxOccurs="1">
+ <annotation>SEI class name</annotation>
+ </argument>
+ </usage>
+</toolspec>
Propchange: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java?rev=642284&r1=642283&r2=642284&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java Fri Mar 28 09:33:52 2008
@@ -1,97 +1,97 @@
-/**
- * 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.java2ws.util;
-
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-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.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.JavaParameter;
-import org.apache.cxf.tools.common.model.JavaReturn;
-import org.apache.cxf.tools.common.model.JavaType.Style;
-
-public final class JavaFirstUtil {
- private JavaFirstUtil() {
-
- }
- public static 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 static 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 "";
- }
-
-}
+/**
+ * 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.java2ws.util;
+
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+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.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.JavaParameter;
+import org.apache.cxf.tools.common.model.JavaReturn;
+import org.apache.cxf.tools.common.model.JavaType.Style;
+
+public final class JavaFirstUtil {
+ private JavaFirstUtil() {
+
+ }
+ public static 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 static 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 "";
+ }
+
+}
Propchange: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java?rev=642284&r1=642283&r2=642284&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java Fri Mar 28 09:33:52 2008
@@ -1,298 +1,298 @@
-/**
- * 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<AbstractGenerator> generators = new ArrayList<AbstractGenerator>();
-
- 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));
- }
- EndpointInfo endpointInfo = service.getEndpoints().iterator().next();
- String address = ToolConstants.DEFAULT_ADDRESS + "/" + endpointInfo.getName().getLocalPart();
- if (context.get(ToolConstants.CFG_ADDRESS) != null) {
- address = (String)context.get(ToolConstants.CFG_ADDRESS);
- }
- endpointInfo.setAddress(address);
- context.put(ToolConstants.CFG_ADDRESS, address);
-
- }
-
- public void process() throws ToolException {
- String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
- LOG.log(Level.FINE, "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.FINE, "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<ServiceInfo> serviceList = new ArrayList<ServiceInfo>();
- serviceList.add(service);
- context.put(ToolConstants.SERVICE_LIST, serviceList);
- System.setProperty(JAVA_CLASS_PATH, oldClassPath);
- LOG.log(Level.FINE, "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);
- context.put(ToolConstants.SEI_CLASS, clz.getName());
- } else {
- context.put(ToolConstants.IMPL_CLASS, clz.getName());
- if (clz.getInterfaces().length == 1) {
- context.put(ToolConstants.SEI_CLASS, clz.getInterfaces()[0].getName());
- }
- 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),
- Thread.currentThread().getContextClassLoader());
- }
-
- 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;
- }
-
-}
+/**
+ * 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<AbstractGenerator> generators = new ArrayList<AbstractGenerator>();
+
+ 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));
+ }
+ EndpointInfo endpointInfo = service.getEndpoints().iterator().next();
+ String address = ToolConstants.DEFAULT_ADDRESS + "/" + endpointInfo.getName().getLocalPart();
+ if (context.get(ToolConstants.CFG_ADDRESS) != null) {
+ address = (String)context.get(ToolConstants.CFG_ADDRESS);
+ }
+ endpointInfo.setAddress(address);
+ context.put(ToolConstants.CFG_ADDRESS, address);
+
+ }
+
+ public void process() throws ToolException {
+ String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
+ LOG.log(Level.FINE, "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.FINE, "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<ServiceInfo> serviceList = new ArrayList<ServiceInfo>();
+ serviceList.add(service);
+ context.put(ToolConstants.SERVICE_LIST, serviceList);
+ System.setProperty(JAVA_CLASS_PATH, oldClassPath);
+ LOG.log(Level.FINE, "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);
+ context.put(ToolConstants.SEI_CLASS, clz.getName());
+ } else {
+ context.put(ToolConstants.IMPL_CLASS, clz.getName());
+ if (clz.getInterfaces().length == 1) {
+ context.put(ToolConstants.SEI_CLASS, clz.getInterfaces()[0].getName());
+ }
+ 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),
+ Thread.currentThread().getContextClassLoader());
+ }
+
+ 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;
+ }
+
+}
Propchange: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JAXWSFrontEndProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JAXWSFrontEndProcessor.java?rev=642284&r1=642283&r2=642284&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JAXWSFrontEndProcessor.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JAXWSFrontEndProcessor.java Fri Mar 28 09:33:52 2008
@@ -1,195 +1,195 @@
-/**
- * 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.lang.reflect.GenericArrayType;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.jws.WebService;
-
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
-import org.apache.cxf.service.model.EndpointInfo;
-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.java2ws.util.JavaFirstUtil;
-import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.AbstractJaxwsGenerator;
-import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsClientGenerator;
-import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsImplGenerator;
-import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsSEIGenerator;
-import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsServerGenerator;
-
-public class JAXWSFrontEndProcessor implements Processor {
- private static final Logger LOG = LogUtils.getL7dLogger(JAXWSFrontEndProcessor.class);
- private ToolContext context;
- private List<AbstractJaxwsGenerator> generators = new ArrayList<AbstractJaxwsGenerator>();
- private List<String> infList = new ArrayList<String>();
-
- @SuppressWarnings("unchecked")
- public void process() throws ToolException {
- checkJaxwsClass();
- List<ServiceInfo> services = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
- ServiceInfo serviceInfo = services.get(0);
- JavaInterface jinf = JavaFirstUtil.serviceInfo2JavaInf(serviceInfo);
- JavaModel jm = new JavaModel();
- jm.addInterface("inf", jinf);
- jinf.setJavaModel(jm);
- context.put(JavaModel.class, jm);
- context.put(ToolConstants.SERVICE_NAME, serviceInfo.getName());
- EndpointInfo endpointInfo = serviceInfo.getEndpoints().iterator().next();
- context.put(ToolConstants.PORT_NAME, endpointInfo.getName());
- generators.add(new JaxwsSEIGenerator());
- generators.add(new JaxwsImplGenerator());
- generators.add(new JaxwsServerGenerator());
- generators.add(new JaxwsClientGenerator());
-
- for (AbstractJaxwsGenerator generator : generators) {
- generator.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 "";
- }
-
- public void checkJaxwsClass() {
- Class<?> clz = context.get(Class.class);
- WebService webServiceAnno = (WebService)clz.getAnnotation(WebService.class);
- if (webServiceAnno == null) {
- Message msg = new Message("CLASS_DOESNOT_CARRY_WEBSERVICE_ANNO", LOG, clz.getName());
- LOG.log(Level.WARNING, msg.toString());
- throw new ToolException(msg);
- }
- if (isImplRmiRemote(clz)) {
- Message msg = new Message("PARA_OR_RETURN_IMPL_REMOTE", LOG, clz.getName());
- LOG.log(Level.WARNING, msg.toString());
- throw new ToolException(msg);
- }
- }
-
-
- private boolean isImplRmiRemote(Class claz) {
- for (Method method : claz.getMethods()) {
- if (Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers())
- && !method.getDeclaringClass().getName().equals("java.lang.Object")) {
- Class[] paraClasses = method.getParameterTypes();
- for (Class clz : paraClasses) {
- getInfClass(clz);
- }
- Class returnClass = method.getReturnType();
- getInfClass(returnClass);
- }
- }
- if (infList.contains("java.rmi.Remote")) {
- return true;
- }
- return false;
- }
-
-
- private void getInfClass(Class claz) {
- for (Class inf : claz.getInterfaces()) {
- getInfClass(inf);
- }
- if (claz.getSuperclass() != null) {
- getInfClass(claz.getSuperclass());
- }
- if (claz.isInterface()) {
- infList.add(claz.getName());
- }
- }
-
-}
+/**
+ * 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.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.EndpointInfo;
+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.java2ws.util.JavaFirstUtil;
+import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.AbstractJaxwsGenerator;
+import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsClientGenerator;
+import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsImplGenerator;
+import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsSEIGenerator;
+import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.generator.JaxwsServerGenerator;
+
+public class JAXWSFrontEndProcessor implements Processor {
+ private static final Logger LOG = LogUtils.getL7dLogger(JAXWSFrontEndProcessor.class);
+ private ToolContext context;
+ private List<AbstractJaxwsGenerator> generators = new ArrayList<AbstractJaxwsGenerator>();
+ private List<String> infList = new ArrayList<String>();
+
+ @SuppressWarnings("unchecked")
+ public void process() throws ToolException {
+ checkJaxwsClass();
+ List<ServiceInfo> services = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
+ ServiceInfo serviceInfo = services.get(0);
+ JavaInterface jinf = JavaFirstUtil.serviceInfo2JavaInf(serviceInfo);
+ JavaModel jm = new JavaModel();
+ jm.addInterface("inf", jinf);
+ jinf.setJavaModel(jm);
+ context.put(JavaModel.class, jm);
+ context.put(ToolConstants.SERVICE_NAME, serviceInfo.getName());
+ EndpointInfo endpointInfo = serviceInfo.getEndpoints().iterator().next();
+ context.put(ToolConstants.PORT_NAME, endpointInfo.getName());
+ generators.add(new JaxwsSEIGenerator());
+ generators.add(new JaxwsImplGenerator());
+ generators.add(new JaxwsServerGenerator());
+ generators.add(new JaxwsClientGenerator());
+
+ for (AbstractJaxwsGenerator generator : generators) {
+ generator.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 "";
+ }
+
+ public void checkJaxwsClass() {
+ Class<?> clz = context.get(Class.class);
+ WebService webServiceAnno = (WebService)clz.getAnnotation(WebService.class);
+ if (webServiceAnno == null) {
+ Message msg = new Message("CLASS_DOESNOT_CARRY_WEBSERVICE_ANNO", LOG, clz.getName());
+ LOG.log(Level.WARNING, msg.toString());
+ throw new ToolException(msg);
+ }
+ if (isImplRmiRemote(clz)) {
+ Message msg = new Message("PARA_OR_RETURN_IMPL_REMOTE", LOG, clz.getName());
+ LOG.log(Level.WARNING, msg.toString());
+ throw new ToolException(msg);
+ }
+ }
+
+
+ private boolean isImplRmiRemote(Class claz) {
+ for (Method method : claz.getMethods()) {
+ if (Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers())
+ && !method.getDeclaringClass().getName().equals("java.lang.Object")) {
+ Class[] paraClasses = method.getParameterTypes();
+ for (Class clz : paraClasses) {
+ getInfClass(clz);
+ }
+ Class returnClass = method.getReturnType();
+ getInfClass(returnClass);
+ }
+ }
+ if (infList.contains("java.rmi.Remote")) {
+ return true;
+ }
+ return false;
+ }
+
+
+ private void getInfClass(Class claz) {
+ for (Class inf : claz.getInterfaces()) {
+ getInfClass(inf);
+ }
+ if (claz.getSuperclass() != null) {
+ getInfClass(claz.getSuperclass());
+ }
+ if (claz.isInterface()) {
+ infList.add(claz.getName());
+ }
+ }
+
+}
Propchange: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JAXWSFrontEndProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java?rev=642284&r1=642283&r2=642284&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java Fri Mar 28 09:33:52 2008
@@ -1,42 +1,42 @@
-/**
- * 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.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 AbstractJaxwsGenerator extends AbstractGenerator {
- protected static final Logger LOG = LogUtils.getL7dLogger(AbstractJaxwsGenerator.class);
- protected static final String TEMPLATE_BASE = "org/apache/cxf/tools"
- + "/java2wsdl/processor/internal/jaxws/generator/template";
-
- public abstract boolean passthrough();
-
- public abstract void generate(ToolContext penv) throws ToolException;
- public void register(final ClassCollector collector, String packageName, String fileName) {
-
- }
-
-}
-
+/**
+ * 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.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 AbstractJaxwsGenerator extends AbstractGenerator {
+ protected static final Logger LOG = LogUtils.getL7dLogger(AbstractJaxwsGenerator.class);
+ protected static final String TEMPLATE_BASE = "org/apache/cxf/tools"
+ + "/java2wsdl/processor/internal/jaxws/generator/template";
+
+ public abstract boolean passthrough();
+
+ public abstract void generate(ToolContext penv) throws ToolException;
+ public void register(final ClassCollector collector, String packageName, String fileName) {
+
+ }
+
+}
+
Propchange: incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native