1 package org.codehaus.xfire.annotations.backport175;
2
3 import java.lang.reflect.Method;
4
5 import org.codehaus.backport175.reader.Annotations;
6 import org.codehaus.xfire.annotations.HandlerChainAnnotation;
7 import org.codehaus.xfire.annotations.WebAnnotations;
8 import org.codehaus.xfire.annotations.WebMethodAnnotation;
9 import org.codehaus.xfire.annotations.WebParamAnnotation;
10 import org.codehaus.xfire.annotations.WebResultAnnotation;
11 import org.codehaus.xfire.annotations.WebServiceAnnotation;
12 import org.codehaus.xfire.annotations.backport175.soap.SOAPBinding;
13 import org.codehaus.xfire.annotations.soap.SOAPBindingAnnotation;
14
15 /***
16 * Implementation of the {@link WebAnnotations} facade for backport175.
17 *
18 * @author Arjen Poutsma
19 */
20 public class Backport175WebAnnotations
21 implements WebAnnotations
22 {
23 public boolean hasWebServiceAnnotation(Class aClass)
24 {
25 return Annotations.isAnnotationPresent(WebService.class, aClass);
26 }
27
28 public WebServiceAnnotation getWebServiceAnnotation(Class aClass)
29 {
30 WebService webService = (WebService) Annotations.getAnnotation(WebService.class, aClass);
31 WebServiceAnnotation annotation = null;
32 if (webService != null)
33 {
34 annotation = new WebServiceAnnotation();
35 annotation.setEndpointInterface(webService.endpointInterface());
36 annotation.setName(webService.name());
37 annotation.setServiceName(webService.serviceName());
38 annotation.setTargetNamespace(webService.targetNamespace());
39 }
40 return annotation;
41 }
42
43 public boolean hasWebMethodAnnotation(Method method)
44 {
45 return Annotations.isAnnotationPresent(WebMethod.class, method);
46 }
47
48 public WebMethodAnnotation getWebMethodAnnotation(Method method)
49 {
50 WebMethod webMethod = (WebMethod) Annotations.getAnnotation(WebMethod.class, method);
51 WebMethodAnnotation annotation = null;
52 if (webMethod != null)
53 {
54 annotation = new WebMethodAnnotation();
55 annotation.setAction(webMethod.action());
56 annotation.setOperationName(webMethod.operationName());
57 }
58 return annotation;
59 }
60
61 public boolean hasWebResultAnnotation(Method method)
62 {
63 return Annotations.isAnnotationPresent(WebResult.class, method);
64 }
65
66 public WebResultAnnotation getWebResultAnnotation(Method method)
67 {
68 WebResult webResult = (WebResult) Annotations.getAnnotation(WebResult.class, method);
69 WebResultAnnotation annotation = null;
70 if (webResult != null)
71 {
72 annotation = new WebResultAnnotation();
73 annotation.setName(webResult.name());
74 annotation.setTargetNamespace(webResult.targetNameSpace());
75 }
76 return annotation;
77 }
78
79 public boolean hasWebParamAnnotation(Method method, int parameter)
80 {
81
82 return false;
83 }
84
85 public WebParamAnnotation getWebParamAnnotation(Method method, int parameter)
86 {
87
88 return null;
89 }
90
91 public boolean hasOnewayAnnotation(Method method)
92 {
93 return Annotations.isAnnotationPresent(Oneway.class, method);
94 }
95
96 public boolean hasSOAPBindingAnnotation(Class aClass)
97 {
98 return Annotations.isAnnotationPresent(SOAPBinding.class, aClass);
99 }
100
101 public SOAPBindingAnnotation getSOAPBindingAnnotation(Class aClass)
102 {
103 SOAPBinding soapBinding = (SOAPBinding) Annotations.getAnnotation(SOAPBinding.class, aClass);
104 SOAPBindingAnnotation annotation = null;
105 if (soapBinding != null)
106 {
107 annotation = new SOAPBindingAnnotation();
108 annotation.setStyle(soapBinding.style());
109 annotation.setUse(soapBinding.use());
110 annotation.setParameterStyle(soapBinding.parameterStyle());
111 }
112 return annotation;
113 }
114
115 public boolean hasHandlerChainAnnotation(Class aClass)
116 {
117 return Annotations.isAnnotationPresent(HandlerChain.class, aClass);
118 }
119
120 public HandlerChainAnnotation getHandlerChainAnnotation(Class aClass)
121 {
122 HandlerChain handlerChain = (HandlerChain) Annotations.getAnnotation(HandlerChain.class, aClass);
123 HandlerChainAnnotation annotation = null;
124 if (handlerChain != null)
125 {
126 annotation = new HandlerChainAnnotation(handlerChain.file(), handlerChain.name());
127 }
128 return annotation;
129 }
130 }