[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[stp-dev] patch for bug 169268
|
Hi,
I have implemented class/interface differentiation.
In the plugin.xml, attributes were added to specify class/interface
only annotations. When getting available annotations for a class/interface,
this attribute is used as a filter to determine if an annotation
is suitable for a class/interface.
Please find attached the patch file.
Regards,
Frank
### Eclipse Workspace Patch 1.0
#P org.eclipse.stp.sc.jaxws
Index: plugin.xml
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.sc.jaxws/plugin.xml,v
retrieving revision 1.11
diff -u -r1.11 plugin.xml
--- plugin.xml 26 Dec 2006 10:21:55 -0000 1.11
+++ plugin.xml 15 Jan 2007 07:54:12 -0000
@@ -335,14 +335,59 @@
nature="org.eclipse.stp.sc.jaxws.nature"/>
<annotation
annotationClass="javax.xml.ws.RequestWrapper"
- initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.CoreAnnotationInitializer"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
name="RequestWrapper"
nature="org.eclipse.stp.sc.jaxws.nature"/>
<annotation
annotationClass="javax.xml.ws.ResponseWrapper"
- initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.CoreAnnotationInitializer"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
name="ResponseWrapper"
nature="org.eclipse.stp.sc.jaxws.nature"/>
+ <annotation
+ annotationClass="javax.xml.ws.ServiceMode"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="ServiceMode"
+ nature="org.eclipse.stp.sc.jaxws.nature"
+ classOnly="true"/>
+ <annotation
+ annotationClass="javax.xml.ws.WebFault"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="WebFault"
+ nature="org.eclipse.stp.sc.jaxws.nature"/>
+ <annotation
+ annotationClass="javax.xml.ws.WebServiceClient"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="WebServiceClient"
+ nature="org.eclipse.stp.sc.jaxws.nature"
+ classOnly="true"/>
+ <annotation
+ annotationClass="javax.xml.ws.WebEndpoint"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="WebEndpoint"
+ nature="org.eclipse.stp.sc.jaxws.nature"
+ classOnly="true"/>
+ <annotation
+ annotationClass="javax.xml.ws.WebServiceProvider"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="WebServiceProvider"
+ nature="org.eclipse.stp.sc.jaxws.nature"
+ classOnly="true"/>
+ <annotation
+ annotationClass="javax.xml.ws.BindingType"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="BindingType"
+ nature="org.eclipse.stp.sc.jaxws.nature"
+ classOnly="true"/>
+ <annotation
+ annotationClass="javax.xml.ws.WebServiceRef"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="WebServiceRef"
+ nature="org.eclipse.stp.sc.jaxws.nature"/>
+ <annotation
+ annotationClass="javax.xml.ws.WebServiceRefs"
+ initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+ name="WebServiceRefs"
+ nature="org.eclipse.stp.sc.jaxws.nature"/>
</extension>
<extension
point="org.eclipse.ui.propertyPages">
Index: src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.sc.jaxws/src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java,v
retrieving revision 1.16
diff -u -r1.16 CoreAnnotationInitializer.java
--- src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java 25 Dec 2006 06:30:06 -0000 1.16
+++ src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java 15 Jan 2007 07:54:16 -0000
@@ -21,8 +21,6 @@
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
-import javax.xml.ws.RequestWrapper;
-import javax.xml.ws.ResponseWrapper;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
@@ -41,15 +39,25 @@
SingleVariableDeclaration jdtMemberParam) {
List<MemberValuePair> annotValues = null;
- if (annotationClass.equals(WebMethod.class)) {
-
- /* sample output for a method : < String sayHi() >
- @WebMethod(action="",
- operationName="sayHi",
- exclude=false)
- */
- annotValues = new ArrayList<MemberValuePair>();
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ if (annotationClass.equals(WebMethod.class)) {
+ /*
+ * @Target(value=METHOD)
+ * @Retention(value=RUNTIME)
+ * public @interface WebMethod
+ * String action
+ * boolean exclude
+ * String operationName
+ *
+ * sample output for a method: <String sayHi()>
+ *
+ * @WebMethod(action="",
+ * operationName="sayHi",
+ * exclude=false)
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
"operationName",
jdtMember.getElementName()));
@@ -57,15 +65,28 @@
"exclude",
false));
- } else if (annotationClass.equals(WebService.class)) {
- /* sample output for a class < org.apache.hello_world_soap_http.Greeter >
- @javax.jws.WebService(name = "Greeter",
- targetNamespace = "http://apache.org.hello_world_soap_http")
- wsdlLocation=""
-
+ } else if (annotationClass.equals(WebService.class)) {
+ /*
+ * @Target(value=TYPE)
+ * @Retention(value=RUNTIME)
+ * public @interface WebService
+ * String endpointInterface
+ * String name
+ * String portName
+ * String serviceName
+ * String targetNamespace
+ * String wsdlLocation
+ *
+ * sample output for a class: <iona.com.helloworld.HelloWorld>
+ *
+ * @javax.jws.WebService(name="HelloWorld",
+ * targetNamespace="http://helloworld.iona.com/",
+ * wsdlLocation="")
*/
- annotValues = new ArrayList<MemberValuePair>();
- IType type = (IType)jdtMember;
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ IType type = (IType)jdtMember;
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
"name",
@@ -81,119 +102,156 @@
type.getElementName() + "Service"));
*/
- //String fullyQualifiedName = type.getFullyQualifiedName();
String packageName = type.getPackageFragment().getElementName();
+
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
"targetNamespace",
JDTUtils.getNamespace(packageName.toLowerCase())));
/*
+ String fullyQualifiedName = type.getFullyQualifiedName();
+
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
"endpointInterface",
fullyQualifiedName));
*/
- } else if (annotationClass.equals(RequestWrapper.class)) {
- /* sample output for a method : < String sayHi() > of the class < com.iona.helloworld.HelloWorld >
- @RequestWrapper(targetNamespace = "http://om.iona.helloworld.helloworld/",
- className = "com.iona.helloworld.helloworld.SayHiRequest",
- localName = "SayHiRequest").
- */
-
- annotValues = new ArrayList<MemberValuePair>();
-
- IMethod method = (IMethod)jdtMember;
- IType type = method.getDeclaringType();
+ } else if (annotationClass.equals(SOAPBinding.class)) {
+ /*
+ * @Target(value={TYPE,METHOD})
+ * @Retention(value=RUNTIME)
+ * public @interface SOAPBinding
+ * SOAPBinding.ParameterStyle parameterStyle
+ * SOAPBinding.Style style
+ * SOAPBinding.Use use
+ *
+ * sample output for a method or a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @SOAPBinding(parameterStyle=javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED,
+ * style=javax.jws.soap.SOAPBinding.Style.DOCUMENT,
+ * use=javax.jws.soap.SOAPBinding.Use.LITERAL)
+ */
- String packageName = type.getPackageFragment().getElementName();
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "targetNamespace",
- JDTUtils.getNamespace(packageName.toLowerCase())));
+ annotValues = new ArrayList<MemberValuePair>();
-
- String className = method.getElementName().substring(0, 1).toUpperCase()
- + method.getElementName().substring(1);
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "className",
- packageName + "." + className));
-
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "localName",
- method.getElementName()));
-
- } else if (annotationClass.equals(ResponseWrapper.class)) {
- /* sample output for a method : < String sayHi() > of the class < com.iona.helloworld.HelloWorld >
- @ResponseWrapper(targetNamespace = "http://com.iona.helloworld.helloworld/",
- className = "com.iona.helloworld.helloworld.SayHiResponse",
- localName = "SayHiResponse")
+ /*
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "parameterStyle",
+ javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED));
*/
-
- annotValues = new ArrayList<MemberValuePair>();
-
- IMethod method = (IMethod)jdtMember;
- IType type = method.getDeclaringType();
- String packageName = type.getPackageFragment().getElementName();
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "targetNamespace",
- JDTUtils.getNamespace(packageName)));
-
-
- String className = method.getElementName().substring(0, 1).toUpperCase()
- + method.getElementName().substring(1)
- + "Response";
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "className",
- packageName + "." + className));
- String localName = method.getElementName() + "Response";
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "localName",
- localName));
-
- } else if (annotationClass.equals(SOAPBinding.class)) {
- annotValues = new ArrayList<MemberValuePair>();
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "style", SOAPBinding.Style.RPC));
+ "style",
+ SOAPBinding.Style.RPC));
+
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "use", SOAPBinding.Use.LITERAL));
-
+ "use",
+ SOAPBinding.Use.LITERAL));
- } else if (annotationClass.equals(WebResult.class)) {
- annotValues = new ArrayList<MemberValuePair>();
+ } else if (annotationClass.equals(WebResult.class)) {
+ /*
+ * @Target(value=METHOD)
+ * @Retention(value=RUNTIME)
+ * public @interface WebResult
+ * boolean header
+ * String name
+ * String partName
+ * String targetNamespace
+ *
+ * sample output for a method: <String sayHi()> of a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @WebResult(header=false,
+ * name="SayHiResult",
+ * partName="SayHiPart",
+ * targetNamespace="http://helloworld.iona.com/")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
IMethod method = (IMethod)jdtMember;
IType type = method.getDeclaringType();
String packageName = type.getPackageFragment().getElementName();
+
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
"targetNamespace",
JDTUtils.getNamespace(packageName)));
+
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "name", "return"));
- annotValues.add(JDTUtils.newMemberValuePair(astRoot,
- "partName", "return"));
+ "name",
+ "return"));
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "partName",
+ "return"));
- } else if (annotationClass.equals(WebParam.class)) {
+ } else if (annotationClass.equals(WebParam.class)) {
+ /*
+ * @Target(value=PARAMETER)
+ * @Retention(value=RUNTIME)
+ * public @interface WebParam
+ * boolean header
+ * WebParam.Mode mode
+ * String name
+ * String partName
+ * String targetNamespace
+ *
+ * sample output for a parameter in a method: <String sayHi(String name)> of a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @WebParam(header=false,
+ * mode=javax.jws.WebParam.Mode.IN,
+ * name="SayHiParamName",
+ * partName="SayHiParamPart",
+ * targetNamespace="http://helloworld.iona.com/")
+ *
+ */
annotValues = new ArrayList<MemberValuePair>();
+
IMethod method = (IMethod)jdtMember;
IType type = method.getDeclaringType();
String packageName = type.getPackageFragment().getElementName();
+
annotValues.add(JDTUtils.newMemberValuePair(astRoot,
"targetNamespace",
JDTUtils.getNamespace(packageName)));
- } else if (annotationClass.equals(Oneway.class)) {
-
- } else if (annotationClass.equals(HandlerChain.class)) {
- // TODO (pull data from preferences?)
-
- }
+ } else if (annotationClass.equals(Oneway.class)) {
+ /*
+ * @Target(value=METHOD)
+ * @Retention(value=RUNTIME)
+ * public @interface Oneway
+ *
+ * sample output for a method: <String sayHi()>
+ *
+ * @Oneway
+ */
+
+ } else if (annotationClass.equals(HandlerChain.class)) {
+ /*
+ * @Target(value={TYPE,METHOD,FIELD})
+ * @Retention(value=RUNTIME)
+ * public @interface HandlerChain
+ * String file
+ * String name
+ *
+ * sample output for a method: <String sayHi()>
+ *
+ * @HandlerChain(file="",
+ * name="")
+ */
- return annotValues;
+ annotValues = new ArrayList<MemberValuePair>();
- }
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "file",
+ "<specify file here>"));
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "name",
+ "<specify name here>"));
+ }
+ return annotValues;
+ }
}
Index: src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java
===================================================================
RCS file: src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java
diff -N src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,454 @@
+/*******************************************************************************
+* Copyright (c) 2006 IONA Technologies PLC
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* IONA Technologies PLC - initial API and implementation
+*******************************************************************************/
+package org.eclipse.stp.sc.jaxws.utils.ext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import java.lang.annotation.Annotation;
+
+import javax.xml.ws.soap.SOAPBinding;
+
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebFault;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.ArrayInitializer;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+
+import org.eclipse.stp.sc.common.annotations.ext.IAnnotationInitializer;
+
+import org.eclipse.stp.common.utils.JDTUtils;
+
+public class JAXWSAnnotationInitializer implements IAnnotationInitializer {
+
+ @SuppressWarnings("unchecked")
+ public List<MemberValuePair> getDefaultAttributes(Class<? extends Annotation> annotationClass,
+ CompilationUnit astRoot,
+ IMember jdtMember,
+ SingleVariableDeclaration jdtMemberParam) {
+ List<MemberValuePair> annotValues = null;
+
+ if (annotationClass.equals(RequestWrapper.class)) {
+ /*
+ * @Target(value=METHOD)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface RequestWrapper
+ * String className
+ * string localName
+ * String targetNamespace
+ *
+ * sample output for a method: <String sayHi()> of the class <com.iona.helloworld.HelloWorld>
+ *
+ * @RequestWrapper(className="com.iona.helloworld.SayHiRequest",
+ * localName="SayHiRequest",
+ * targetNamespace="http://helloworld.iona.com/")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ IMethod method = (IMethod)jdtMember;
+ IType type = method.getDeclaringType();
+
+ String packageName = type.getPackageFragment().getElementName();
+
+ String className = method.getElementName().substring(0, 1).toUpperCase() +
+ method.getElementName().substring(1) + "Request";
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "className",
+ packageName + "." + className));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "localName",
+ className));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "targetNamespace",
+ JDTUtils.getNamespace(packageName)));
+
+ } else if (annotationClass.equals(ResponseWrapper.class)) {
+ /*
+ * @Target(value=METHOD)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface ResponseWrapper
+ * String className
+ * string localName
+ * String targetNamespace
+ *
+ * sample output for a method: <String sayHi()> of the class <com.iona.helloworld.HelloWorld>
+ *
+ * @ResponseWrapper(className="com.iona.helloworld.SayHiResponse",
+ * localName="SayHiResponse",
+ * targetNamespace="http://helloworld.iona.com/")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ IMethod method = (IMethod)jdtMember;
+ IType type = method.getDeclaringType();
+
+ String packageName = type.getPackageFragment().getElementName();
+
+ String className = method.getElementName().substring(0, 1).toUpperCase() +
+ method.getElementName().substring(1) + "Response";
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "className",
+ packageName + "." + className));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "localName",
+ className));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "targetNamespace",
+ JDTUtils.getNamespace(packageName)));
+
+ } else if (annotationClass.equals(ServiceMode.class)) {
+ /*
+ * @Target(value=TYPE)
+ * @Retention(value=RUNTIME)
+ * @Inherited
+ * @Documented
+ * public @interface ServiceMode
+ * Service.Mode value
+ *
+ * sample output for a class: <com.iona.helloworld.HelloWorld>
+ *
+ * ServiceMode(value=javax.xml.ws.Service.Mode.PAYLOAD)
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "value",
+ javax.xml.ws.Service.Mode.PAYLOAD));
+
+ } else if (annotationClass.equals(WebFault.class)) {
+ /*
+ * @Target(value=TYPE)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface WebFault
+ * String faultBean
+ * String name
+ * String targetNamespace
+ *
+ * sample output for a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @WebFault(faultBean="com.iona.helloworld.HelloWorldFaultBean",
+ * name="HelloWorldFault",
+ * targetNamespace = "http://helloworld.iona.com/")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ IType type = (IType)jdtMember;
+
+ String typeName = type.getElementName();
+ String packageName = type.getPackageFragment().getElementName();
+
+ String faultPostfix = "Fault";
+ String faultBeanPostfix = "FaultBean";
+ String[] faultPostfixes = { "Error", "Fault", "Exception" };
+
+ String shortName = type.getElementName();
+
+ for (String postfix : faultPostfixes) {
+ if (typeName.endsWith(postfix)) {
+ shortName = typeName.substring(0, typeName.length() - postfix.length());
+ break;
+ }
+ }
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "faultBean",
+ packageName + "." + shortName.concat(faultBeanPostfix)));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "name",
+ typeName.equals(shortName) ? shortName.concat(faultPostfix) : typeName));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "targetNamespace",
+ JDTUtils.getNamespace(packageName)));
+
+ } else if (annotationClass.equals(WebServiceClient.class)) {
+ /*
+ * @Target(value=TYPE)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface WebServiceClient
+ * String name
+ * string targetNamespace
+ * String wsdlLocation
+ *
+ * sample output for a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @WebServiceClient(name="HelloWorld",
+ * targetNamespace="http://helloworld.iona.com/",
+ * wsdlLocation="http://helloworld.iona.com/helloworld.wsdl")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ IType type = (IType)jdtMember;
+
+ String packageName = type.getPackageFragment().getElementName();
+ String targetNamespace = JDTUtils.getNamespace(packageName);
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "name",
+ packageName + "." + type.getElementName()));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "targetNamespace",
+ JDTUtils.getNamespace(packageName)));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "wsdlLocation",
+ targetNamespace + type.getElementName().toLowerCase() + "." + "wsdl"));
+
+
+ } else if (annotationClass.equals(WebEndpoint.class)) {
+ /*
+ * @Target(value=METHOD)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface WebEndpoint
+ * String name
+ *
+ * sample output for a method: <String sayHi()> of the class <com.iona.helloworld.HelloWorld>
+ *
+ * @WebEndpoint(name="HelloWorldHTTPPort")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ IMethod method = (IMethod)jdtMember;
+ IType type = method.getDeclaringType();
+ String typeName = type.getElementName();
+
+ String typePostfix = "Service";
+ String portPostfix = "HTTPPort";
+ String endpoint = typeName.endsWith(typePostfix) ? typeName.substring(0, typeName.length() - typePostfix.length()) : typeName;
+ endpoint = endpoint.concat(portPostfix);
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "name",
+ endpoint));
+
+ } else if (annotationClass.equals(WebServiceProvider.class)) {
+ /*
+ * @Target(value=TYPE)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface WebServiceProvider
+ * String portName
+ * String serviceName
+ * String targetNamespace
+ * String wsdlLocation
+ *
+ * sample output for a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @WebServiceProvider(portName="HelloWorldPort",
+ * serviceName="HelloWorldService",
+ * targetNamespace="http://helloworld.iona.com/",
+ * wsdlLocation="http://helloworld.iona.com/helloworld.wsdl")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ IType type = (IType)jdtMember;
+ String typeName = type.getElementName();
+
+ String packageName = type.getPackageFragment().getElementName();
+ String targetNamespace = JDTUtils.getNamespace(packageName);
+
+ String portPostfix = "Port";
+ String servicePostfix = "Service";
+ String shortName = typeName.endsWith(servicePostfix) ? typeName.substring(0, typeName.length() - servicePostfix.length()) : typeName;
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "portName",
+ shortName + portPostfix));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "serviceName",
+ shortName + servicePostfix));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "targetNamespace",
+ JDTUtils.getNamespace(packageName)));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "wsdlLocation",
+ targetNamespace + type.getElementName().toLowerCase() + "." + "wsdl"));
+
+ } else if (annotationClass.equals(BindingType.class)) {
+ /*
+ * @Target(value=TYPE)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface BindingType
+ * String value
+ *
+ * sample output for a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @BindingType(value="http://schemas.xmlsoap.org/wsdl/soap/http")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "value",
+ SOAPBinding.SOAP11HTTP_BINDING));
+
+ } else if (annotationClass.equals(WebServiceRef.class)) {
+ /*
+ * @Target(value={TYPE,METHOD,FIELD})
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface WebServiceRef
+ * String mappedName
+ * String name
+ * Class type
+ * Class value
+ * String wsdlLocation
+ *
+ * sample output for a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @WebServiceRef(mappedName="",
+ * name="<specify name here>",
+ * type=java.lang.Object.class,
+ * value=java.lang.Object.class,
+ * wsdlLocation="http://helloworld.iona.com/helloworld.wsdl")
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ /*
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "mappedName",
+ ""));
+ */
+
+ if (!(jdtMember instanceof IField)) {
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "name",
+ "<specify name here>"));
+ }
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "type",
+ java.lang.Object.class));
+
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "value",
+ java.lang.Object.class));
+
+ /*
+ annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+ "wsdlLocation",
+ ""));
+ */
+
+ } else if (annotationClass.equals(WebServiceRefs.class)) {
+ /*
+ * @Target(value=TYPE)
+ * @Retention(value=RUNTIME)
+ * @Documented
+ * public @interface WebServiceRefs
+ * WebServiceRef[] value
+ *
+ * sample output for a class: <com.iona.helloworld.HelloWorld>
+ *
+ * @WebServiceRefs({@WebServiceRef(mappedName="",
+ * name="<specify name here>",
+ * type=java.lang.Object.class,
+ * value=java.lang.Object.class,
+ * wsdlLocation=""),
+ * @WebServiceRef(mappedName="",
+ * name="<specify name here>",
+ * type=java.lang.Object.class,
+ * value=java.lang.Object.class,
+ * wsdlLocation="")})
+ */
+
+ annotValues = new ArrayList<MemberValuePair>();
+
+ @WebServiceRef(mappedName="",
+ name="<specify name here>",
+ type=java.lang.Object.class,
+ value=java.lang.Object.class,
+ wsdlLocation="")
+ class DummyClass {};
+
+ Annotation[] annos = DummyClass.class.getAnnotations();
+ WebServiceRef[] refs = {(WebServiceRef)annos[0]};
+
+ ArrayInitializer arrayInit = astRoot.getAST().newArrayInitializer();
+ List<NormalAnnotation> expList = arrayInit.expressions();
+
+ for (WebServiceRef ref : refs) {
+ NormalAnnotation anno = astRoot.getAST().newNormalAnnotation();
+ anno.setTypeName(astRoot.getAST().newName("WebServiceRef"));
+ List<MemberValuePair> pairList = anno.values();
+ if (ref.mappedName() != null && ref.mappedName().length() > 0) {
+ pairList.add(JDTUtils.newMemberValuePair(astRoot,
+ "mappedName",
+ ref.mappedName()));
+ }
+ if (ref.name() != null && ref.name().length() > 0) {
+ pairList.add(JDTUtils.newMemberValuePair(astRoot,
+ "name",
+ ref.name()));
+ }
+ pairList.add(JDTUtils.newMemberValuePair(astRoot,
+ "type",
+ ref.type()));
+ pairList.add(JDTUtils.newMemberValuePair(astRoot,
+ "value",
+ ref.value()));
+ if (ref.wsdlLocation() != null && ref.wsdlLocation().length() > 0) {
+ pairList.add(JDTUtils.newMemberValuePair(astRoot,
+ "wsdlLocation",
+ ref.wsdlLocation()));
+ }
+ expList.add(anno);
+ }
+
+ MemberValuePair pair = astRoot.getAST().newMemberValuePair();
+ pair.setName(astRoot.getAST().newSimpleName("value"));
+ pair.setValue(arrayInit);
+ annotValues.add(pair);
+ }
+
+ return annotValues;
+ }
+}