1 package org.apache.beehive.wsm.model.jsr181; 2 3 20 21 import java.lang.annotation.Annotation ; 22 import java.util.Collection ; 23 24 import javax.jws.WebParam; 25 26 import javax.xml.namespace.QName ; 28 import org.apache.beehive.wsm.model.BeehiveWsParameterMetadata; 29 import org.apache.beehive.wsm.model.ValidationException; 30 import org.apache.beehive.wsm.model.java.JavaParameterInfo; 31 32 public class Jsr181ParameterMetadataImpl implements BeehiveWsParameterMetadata, java.io.Serializable { 33 34 private static final long serialVersionUID = 1L; 35 36 private String wpName; 37 private String wpTargetNamespace; 38 private WebParam.Mode wpMode; 39 private boolean wpHeader; 40 private Class javaType; 41 private QName mXMLType; 42 43 44 public void validate() throws ValidationException { 45 return; } 47 48 public Jsr181ParameterMetadataImpl() { 49 } 50 51 public Jsr181ParameterMetadataImpl(JavaParameterInfo jp) { 54 55 if (null == jp) { 57 jp.logError("illegal java parameter info: <null>"); 58 return; 59 } 60 61 javaType = jp.getType(); 62 63 setWpName(jp.getName()); 65 setWpMode(WebParam.Mode.IN); 66 67 Collection <Annotation > annotations = jp.getAnnotations(); 69 if (null != annotations) { 70 for (Annotation a : annotations) { 71 if (a.annotationType() == WebParam.class) { 72 initFromAnnotation((WebParam) a); 73 } 74 else { 75 } 77 } 78 } 79 } 80 81 public boolean isWpHeader() { 82 return wpHeader; 83 } 84 85 public void setWpHeader(boolean wpHeader) { 86 this.wpHeader = wpHeader; 87 } 88 89 public WebParam.Mode getWpMode() { 90 return wpMode; 91 } 92 93 public void setWpMode(WebParam.Mode wpMode) { 94 this.wpMode = wpMode; 95 } 96 97 public String getWpName() { 98 return wpName; 99 } 100 101 public void setWpName(String wpName) { 102 this.wpName = wpName; 103 } 104 105 public String getWpTargetNamespace() { 106 return wpTargetNamespace; 107 } 108 109 public void setWpTargetNamespace(String wpTargetNamespace) { 110 this.wpTargetNamespace = wpTargetNamespace; 111 } 112 113 public Class getJavaType() { 114 return javaType; 115 } 116 117 public void setJavaType(Class javaType) { 118 this.javaType = javaType; 119 } 120 121 private void initFromAnnotation(WebParam annotation) { 122 if (null != annotation) { 123 if (0 < annotation.name().length()) { 124 setWpName(annotation.name()); 125 } 126 setWpTargetNamespace(annotation.targetNamespace()); 127 setWpMode(annotation.mode()); 128 setWpHeader(annotation.header()); 129 } 130 } 131 132 138 public String getJavaTypeFullName() { 139 return getClassName(getJavaType()); 140 141 } 142 private String getClassName(Class cls) { 143 if (cls.isArray()) { 144 return getClassName(cls.getComponentType()) + "[]"; 145 } 146 else { 147 return cls.getName().replace('$', '.'); 148 } 149 } 150 151 public QName getXmlType() { 152 return mXMLType; 153 } 154 155 public void setXmlType(QName xmlType) { 156 mXMLType = xmlType; 157 } 158 } 159 | Popular Tags |