1 package org.codehaus.xfire.annotations.commons;
2
3 import java.lang.reflect.Method;
4
5 import org.apache.commons.attributes.Attributes;
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.commons.soap.SOAPBinding;
13 import org.codehaus.xfire.annotations.soap.SOAPBindingAnnotation;
14
15 /***
16 * Implementation of the {@link WebAnnotations} facade for Commons Attributes.
17 *
18 * @author <a href="mailto:poutsma@mac.com">Arjen Poutsma</a>
19 */
20 public class CommonsWebAttributes
21 implements WebAnnotations
22 {
23
24 public boolean hasWebServiceAnnotation(Class aClass)
25 {
26 return Attributes.hasAttributeType(aClass, WebService.class);
27 }
28
29 public WebServiceAnnotation getWebServiceAnnotation(Class aClass)
30 {
31 return (WebServiceAnnotation) Attributes.getAttribute(aClass, WebService.class);
32 }
33
34 public boolean hasWebMethodAnnotation(Method method)
35 {
36 return Attributes.hasAttributeType(method, WebMethod.class);
37 }
38
39 public WebMethodAnnotation getWebMethodAnnotation(Method method)
40 {
41 return (WebMethodAnnotation) Attributes.getAttribute(method, WebMethod.class);
42 }
43
44 public boolean hasWebResultAnnotation(Method method)
45 {
46 return Attributes.hasReturnAttributeType(method, WebResult.class);
47 }
48
49 public WebResultAnnotation getWebResultAnnotation(Method method)
50 {
51 return (WebResultAnnotation) Attributes.getReturnAttribute(method, WebResult.class);
52 }
53
54 public boolean hasWebParamAnnotation(Method method, int parameter)
55 {
56 return Attributes.hasParameterAttributeType(method, parameter, WebParam.class);
57 }
58
59 public WebParamAnnotation getWebParamAnnotation(Method method, int parameter)
60 {
61 return (WebParamAnnotation) Attributes.getParameterAttribute(method, parameter, WebParam.class);
62 }
63
64 public boolean hasOnewayAnnotation(Method method)
65 {
66 return Attributes.hasAttributeType(method, Oneway.class);
67 }
68
69 public boolean hasSOAPBindingAnnotation(Class aClass)
70 {
71 return Attributes.hasAttributeType(aClass, SOAPBinding.class);
72 }
73
74 public SOAPBindingAnnotation getSOAPBindingAnnotation(Class aClass)
75 {
76 return (SOAPBindingAnnotation) Attributes.getAttribute(aClass, SOAPBinding.class);
77 }
78
79 public boolean hasHandlerChainAnnotation(Class aClass)
80 {
81 return Attributes.hasAttributeType(aClass, HandlerChain.class);
82 }
83
84 public HandlerChainAnnotation getHandlerChainAnnotation(Class aClass)
85 {
86 return (HandlerChainAnnotation) Attributes.getAttribute(aClass, HandlerChain.class);
87 }
88 }