Author: ema
Date: Tue Sep 4 02:06:59 2007
New Revision: 572586
URL: http://svn.apache.org/viewvc?rev=572586&view=rev
Log:
* Added processor and generators for jaxws frontend to generate codes directly
from sei or impl class
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsClientGenerator.java
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsSEIGenerator.java
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsServerGenerator.java
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/Messages.properties
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-client.vm
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-sei.vm
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-server.vm
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
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/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/SimpleClientGenerator.java
incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=572586&r1=572585&r2=572586&view=diff
==============================================================================
---
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
(original)
+++
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
Tue Sep 4 02:06:59 2007
@@ -216,4 +216,6 @@
//For Simple FrontEnd
public static final String SEI_CLASS = "seiClass";
public static final String IMPL_CLASS = "implClass";
+ public static final String SERVICE_NAME = "serviceName";
+ public static final String PORT_NAME = "portName";
}
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=572586&r1=572585&r2=572586&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
Tue Sep 4 02:06:59 2007
@@ -33,7 +33,7 @@
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.ServiceInfoToJavaProcessor;
+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;
@@ -65,7 +65,7 @@
ft = "jaxws";
env.put(ToolConstants.CFG_FRONTEND, "jaxws");
if (env.optionSet(ToolConstants.CFG_SERVER) ||
env.optionSet(ToolConstants.CFG_CLIENT)) {
- processor = new ServiceInfoToJavaProcessor();
+ processor = new JAXWSFrontEndProcessor();
processor.setEnvironment(env);
processor.process();
}
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/util/JavaFirstUtil.java
Tue Sep 4 02:06:59 2007
@@ -0,0 +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 "";
+ }
+
+}
Modified:
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=572586&r1=572585&r2=572586&view=diff
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ServiceInfoToJavaProcessor.java
(original)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ServiceInfoToJavaProcessor.java
Tue Sep 4 02:06:59 2007
@@ -32,6 +32,7 @@
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"));
Added:
incubator/cxf/trunk/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/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/AbstractJaxwsGenerator.java
Tue Sep 4 02:06:59 2007
@@ -0,0 +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) {
+
+ }
+
+}
+
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsClientGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsClientGenerator.java?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsClientGenerator.java
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsClientGenerator.java
Tue Sep 4 02:06:59 2007
@@ -0,0 +1,70 @@
+/**
+ * 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.Map;
+
+import javax.xml.namespace.QName;
+
+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;
+
+public class JaxwsClientGenerator extends AbstractJaxwsGenerator {
+
+ private static final String CLIENT_TEMPLATE = TEMPLATE_BASE +
"/javafirst-client.vm";
+
+ public JaxwsClientGenerator() {
+ this.name = ToolConstants.CLT_GENERATOR;
+ }
+
+ public boolean passthrough() {
+ if (env.optionSet(ToolConstants.CFG_CLIENT)) {
+ return false;
+ }
+ return true;
+ }
+
+ public void generate(ToolContext penv) throws ToolException {
+ this.env = penv;
+ JavaModel javaModel = env.get(JavaModel.class);
+
+ if (passthrough()) {
+ return;
+ }
+
+ Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
+ QName service = (QName)env.get(ToolConstants.SERVICE_NAME);
+ QName port = (QName)env.get(ToolConstants.PORT_NAME);
+ for (JavaInterface intf : interfaces.values()) {
+ clearAttributes();
+ setAttributes("intf", intf);
+ setAttributes("service", service);
+ setAttributes("port", port);
+ setAttributes("address", "http://localhost:9090/hello");
+ setAttributes("seiClass",
((Class)env.get(ToolConstants.SEI_CLASS)).getName());
+ setCommonAttributes();
+ doWrite(CLIENT_TEMPLATE, parseOutputName(intf.getPackageName(),
intf.getName() + "Client"));
+
+ }
+ }
+}
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
Tue Sep 4 02:06:59 2007
@@ -0,0 +1,67 @@
+/**
+ * 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.Map;
+
+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;
+
+public class JaxwsImplGenerator extends AbstractJaxwsGenerator {
+
+ private static final String IMPL_TEMPLATE = TEMPLATE_BASE +
"/javafirst-impl.vm";
+
+ public JaxwsImplGenerator() {
+ this.name = ToolConstants.IMPL_GENERATOR;
+ }
+
+ public boolean passthrough() {
+ Boolean genFromSei = (Boolean)env.get(ToolConstants.GEN_FROM_SEI);
+ if (genFromSei && env.optionSet(ToolConstants.CFG_SERVER)
+ && (!env.optionSet(ToolConstants.IMPL_CLASS))) {
+ return false;
+ }
+
+ return true;
+
+ }
+
+ public void generate(ToolContext penv) throws ToolException {
+ this.env = penv;
+ JavaModel javaModel = env.get(JavaModel.class);
+
+ if (passthrough()) {
+ return;
+ }
+
+ Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
+
+ for (JavaInterface intf : interfaces.values()) {
+ clearAttributes();
+ setAttributes("intf", intf);
+ setCommonAttributes();
+
+ doWrite(IMPL_TEMPLATE, parseOutputName(intf.getPackageName(),
intf.getName() + "Impl"));
+ env.put(ToolConstants.IMPL_CLASS, intf.getFullClassName() +
"Impl");
+ }
+ }
+}
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsSEIGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsSEIGenerator.java?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsSEIGenerator.java
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsSEIGenerator.java
Tue Sep 4 02:06:59 2007
@@ -0,0 +1,70 @@
+/**
+ * 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.Map;
+
+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;
+
+public class JaxwsSEIGenerator extends AbstractJaxwsGenerator {
+
+ private static final String SEI_TEMPLATE = TEMPLATE_BASE +
"/javafirst-sei.vm";
+
+ public JaxwsSEIGenerator() {
+ this.name = ToolConstants.SEI_GENERATOR;
+ }
+
+ public boolean passthrough() {
+ Boolean genFromSei = (Boolean)env.get(ToolConstants.GEN_FROM_SEI);
+ if (!genFromSei && env.optionSet(ToolConstants.CFG_CLIENT)
+ && (!env.optionSet(ToolConstants.SEI_CLASS))) {
+ return false;
+ }
+ return true;
+
+ }
+
+
+ public void generate(ToolContext penv) throws ToolException {
+ this.env = penv;
+ JavaModel javaModel = env.get(JavaModel.class);
+
+ if (passthrough()) {
+ return;
+ }
+
+ Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
+
+ for (JavaInterface intf : interfaces.values()) {
+ clearAttributes();
+ setAttributes("intf", intf);
+ setCommonAttributes();
+
+ doWrite(SEI_TEMPLATE, parseOutputName(intf.getPackageName(),
intf.getName()));
+ env.put(ToolConstants.SEI_CLASS, intf.getFullClassName());
+ }
+ }
+
+
+}
\ No newline at end of file
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsServerGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsServerGenerator.java?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsServerGenerator.java
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsServerGenerator.java
Tue Sep 4 02:06:59 2007
@@ -0,0 +1,69 @@
+/**
+ * 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.Map;
+
+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;
+
+/**
+ *
+ */
+public class JaxwsServerGenerator extends AbstractJaxwsGenerator {
+
+ private static final String SERVER_TEMPLATE = TEMPLATE_BASE +
"/javafirst-server.vm";
+
+ public JaxwsServerGenerator() {
+ this.name = ToolConstants.SVR_GENERATOR;
+ }
+
+ public boolean passthrough() {
+ if (env.optionSet(ToolConstants.CFG_SERVER)) {
+ return false;
+ }
+ return true;
+ }
+
+ public void generate(ToolContext penv) throws ToolException {
+
+ this.env = penv;
+ JavaModel javaModel = env.get(JavaModel.class);
+
+ if (passthrough()) {
+ return;
+ }
+
+ Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
+
+ for (JavaInterface intf : interfaces.values()) {
+ clearAttributes();
+ setAttributes("intf", intf);
+ setAttributes("address", "http://localhost:9090/hello");
+ setAttributes("implClass",
(String)env.get(ToolConstants.IMPL_CLASS));
+ setCommonAttributes();
+ doWrite(SERVER_TEMPLATE, parseOutputName(intf.getPackageName(),
intf.getName() + "Server"));
+ }
+ }
+
+}
\ No newline at end of file
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/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/jaxws/generator/Messages.properties?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/Messages.properties
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/Messages.properties
Tue Sep 4 02:06:59 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/jaxws/generator/template/javafirst-client.vm
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-client.vm?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-client.vm
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-client.vm
Tue Sep 4 02:06:59 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 javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+/**
+ * This class was generated by the CXF $version
+ * $currentdate
+ * Generated source version: $version
+ *
+ */
+ public class ${intf.Name}Client {
+ public static void main(String[] args) {
+ QName serviceName = new QName("${service.NamespaceURI}",
"${service.LocalPart}");
+ QName portName = new QName("${port.NamespaceURI}",
"${port.LocalPart}");
+
+ Service service = Service.create(serviceName);
+ service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
+ "${address}");
+ ${intf.FullClassName} client = service.getPort(portName,
${intf.FullClassName}.class);
+
+ }
+ }
\ No newline at end of file
Added:
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
Tue Sep 4 02:06:59 2007
@@ -0,0 +1,64 @@
+## 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 javax.jws.WebService;
+
+/**
+ * This cla ss was generated by the CXF $version
+ * $currentdate
+ * Generated source version: $version
+ *
+ */
[EMAIL PROTECTED](endpointInterface = "${intf.FullClassName}")
+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/jaxws/generator/template/javafirst-sei.vm
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-sei.vm?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-sei.vm
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-sei.vm
Tue Sep 4 02:06:59 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
+ *
+ */
+
[EMAIL PROTECTED]
+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/jaxws/generator/template/javafirst-server.vm
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-server.vm?rev=572586&view=auto
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-server.vm
(added)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-server.vm
Tue Sep 4 02:06:59 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.xml.ws.Endpoint;
+
+/**
+ * This class was generated by the CXF $version
+ * $currentdate
+ * Generated source version: $version
+ *
+ */
+
+public class ${intf.Name}Server{
+
+ protected ${intf.Name}Server() throws Exception {
+ System.out.println("Starting Server");
+ Object implementor = new ${implClass}();
+ String address = "${address}";
+ Endpoint.publish(address, implementor);
+ }
+
+ public static void main(String args[]) throws Exception {
+ new ${intf.Name}Server();
+ System.out.println("Server ready...");
+
+ Thread.sleep(5 * 60 * 1000);
+ System.out.println("Server exitting");
+ System.exit(0);
+ }
+}
+
+
\ No newline at end of file
Modified:
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=572586&r1=572585&r2=572586&view=diff
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/SimpleFrontEndProcessor.java
(original)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/SimpleFrontEndProcessor.java
Tue Sep 4 02:06:59 2007
@@ -18,28 +18,17 @@
*/
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.ArrayList;
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.java2ws.util.JavaFirstUtil;
import
org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator.AbstractSimpleGenerator;
import
org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator.SimpleClientGenerator;
import
org.apache.cxf.tools.java2wsdl.processor.internal.simple.generator.SimpleImplGenerator;
@@ -53,11 +42,14 @@
public void process() throws ToolException {
List<ServiceInfo> services =
(List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
ServiceInfo serviceInfo = services.get(0);
- JavaInterface jinf = serviceInfo2JavaInf(serviceInfo);
+
+ JavaInterface jinf = JavaFirstUtil.serviceInfo2JavaInf(serviceInfo);
JavaModel jm = new JavaModel();
jm.addInterface("inf", jinf);
jinf.setJavaModel(jm);
context.put(JavaModel.class, jm);
+
+
generators.add(new SimpleSEIGenerator());
generators.add(new SimpleImplGenerator());
generators.add(new SimpleServerGenerator());
@@ -71,64 +63,5 @@
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 "";
- }
-
+ }
}
Modified:
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=572586&r1=572585&r2=572586&view=diff
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java
(original)
+++
incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java
Tue Sep 4 02:06:59 2007
@@ -39,7 +39,6 @@
return false;
}
return true;
-
}
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=572586&r1=572585&r2=572586&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
Tue Sep 4 02:06:59 2007
@@ -73,8 +73,8 @@
public void testSimple() throws Exception {
String[] args = new String[] {"-wsdl", "-o", output.getPath() +
"/tmp.wsdl", "-verbose",
"-d", output.getPath(),
- "-frontend", "simple",
- "-client",
+ "-frontend", "jaxws",
+ "-client", "-server",
"org.apache.hello_world_doc_lit.Greeter"};
JavaToWS.main(args);
File wsdlFile = new File(output.getPath() + "/tmp.wsdl");