Tue, 06 Mar 2012 16:09:35 -0800
7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.internal.ws.processor.modeler.annotation;
28 import com.sun.codemodel.internal.CodeWriter;
29 import com.sun.codemodel.internal.JAnnotationArrayMember;
30 import com.sun.codemodel.internal.JAnnotationUse;
31 import com.sun.codemodel.internal.JBlock;
32 import com.sun.codemodel.internal.JCodeModel;
33 import com.sun.codemodel.internal.JCommentPart;
34 import com.sun.codemodel.internal.JDefinedClass;
35 import com.sun.codemodel.internal.JDocComment;
36 import com.sun.codemodel.internal.JExpr;
37 import com.sun.codemodel.internal.JFieldVar;
38 import com.sun.codemodel.internal.JMethod;
39 import com.sun.codemodel.internal.JMod;
40 import com.sun.codemodel.internal.JType;
41 import com.sun.codemodel.internal.JVar;
42 import com.sun.codemodel.internal.writer.ProgressCodeWriter;
43 import com.sun.tools.internal.jxc.ap.InlineAnnotationReaderImpl;
44 import com.sun.tools.internal.jxc.model.nav.ApNavigator;
45 import com.sun.tools.internal.ws.ToolVersion;
46 import com.sun.tools.internal.ws.processor.generator.GeneratorBase;
47 import com.sun.tools.internal.ws.processor.generator.GeneratorConstants;
48 import com.sun.tools.internal.ws.processor.generator.Names;
49 import com.sun.tools.internal.ws.processor.modeler.ModelerException;
50 import com.sun.tools.internal.ws.processor.util.DirectoryUtil;
51 import com.sun.tools.internal.ws.resources.WebserviceapMessages;
52 import com.sun.tools.internal.ws.util.ClassNameInfo;
53 import com.sun.tools.internal.ws.wscompile.FilerCodeWriter;
54 import com.sun.tools.internal.ws.wscompile.WsgenOptions;
55 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
56 import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader;
57 import com.sun.xml.internal.bind.v2.model.nav.Navigator;
58 import com.sun.xml.internal.ws.model.AbstractWrapperBeanGenerator;
59 import com.sun.xml.internal.ws.spi.db.BindingHelper;
60 import com.sun.xml.internal.ws.util.StringUtils;
62 import javax.jws.Oneway;
63 import javax.jws.WebMethod;
64 import javax.jws.WebService;
65 import javax.lang.model.element.ExecutableElement;
66 import javax.lang.model.element.Name;
67 import javax.lang.model.element.TypeElement;
68 import javax.lang.model.type.DeclaredType;
69 import javax.lang.model.type.MirroredTypeException;
70 import javax.lang.model.type.TypeKind;
71 import javax.lang.model.type.TypeMirror;
72 import javax.xml.bind.annotation.XmlAccessType;
73 import javax.xml.bind.annotation.XmlAccessorType;
74 import javax.xml.bind.annotation.XmlAttachmentRef;
75 import javax.xml.bind.annotation.XmlElement;
76 import javax.xml.bind.annotation.XmlList;
77 import javax.xml.bind.annotation.XmlMimeType;
78 import javax.xml.bind.annotation.XmlRootElement;
79 import javax.xml.bind.annotation.XmlType;
80 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
81 import javax.xml.namespace.QName;
82 import javax.xml.ws.RequestWrapper;
83 import javax.xml.ws.ResponseWrapper;
84 import javax.xml.ws.WebFault;
85 import javax.xml.ws.WebServiceException;
86 import java.io.File;
87 import java.io.IOException;
88 import java.lang.annotation.Annotation;
89 import java.util.Collection;
90 import java.util.HashSet;
91 import java.util.List;
92 import java.util.Set;
94 import static com.sun.codemodel.internal.ClassType.CLASS;
95 import static com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceConstants.BEAN;
96 import static com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceConstants.FAULT_INFO;
97 import static com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceConstants.JAXWS_PACKAGE_PD;
98 import static com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceConstants.PD_JAXWS_PACKAGE_PD;
99 import static com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceConstants.RESPONSE;
101 /**
102 * This class generates the request/response and Exception Beans
103 * used by the JAX-WS runtime.
104 *
105 * @author WS Development Team
106 */
107 public class WebServiceWrapperGenerator extends WebServiceVisitor {
108 private Set<String> wrapperNames;
109 private Set<String> processedExceptions;
110 private JCodeModel cm;
111 private final MakeSafeTypeVisitor makeSafeVisitor;
113 private static final FieldFactory FIELD_FACTORY = new FieldFactory();
115 private final AbstractWrapperBeanGenerator ap_generator =
116 new ApWrapperBeanGenerator(InlineAnnotationReaderImpl.theInstance,
117 new ApNavigator(builder.getProcessingEnvironment()), FIELD_FACTORY);
119 private final class ApWrapperBeanGenerator extends AbstractWrapperBeanGenerator<TypeMirror, TypeElement, ExecutableElement, MemberInfo> {
121 protected ApWrapperBeanGenerator(
122 AnnotationReader<TypeMirror, TypeElement, ?, ExecutableElement> annReader,
123 Navigator<TypeMirror, TypeElement, ?, ExecutableElement> nav, BeanMemberFactory<TypeMirror, MemberInfo> beanMemberFactory) {
124 super(annReader, nav, beanMemberFactory);
125 }
127 protected TypeMirror getSafeType(TypeMirror type) {
128 return WebServiceWrapperGenerator.this.getSafeType(type);
129 }
131 protected TypeMirror getHolderValueType(TypeMirror paramType) {
132 return builder.getHolderValueType(paramType);
133 }
135 protected boolean isVoidType(TypeMirror type) {
136 return type != null && type.getKind().equals(TypeKind.VOID);
137 }
139 }
141 private static final class FieldFactory implements AbstractWrapperBeanGenerator.BeanMemberFactory<TypeMirror, MemberInfo> {
143 public MemberInfo createWrapperBeanMember(TypeMirror paramType,
144 String paramName, List<Annotation> jaxb) {
145 return new MemberInfo(paramType, paramName, jaxb);
146 }
147 }
149 public WebServiceWrapperGenerator(ModelBuilder builder, AnnotationProcessorContext context) {
150 super(builder, context);
151 makeSafeVisitor = new MakeSafeTypeVisitor(builder.getProcessingEnvironment());
152 }
154 protected void processWebService(WebService webService, TypeElement d) {
155 cm = new JCodeModel();
156 wrapperNames = new HashSet<String>();
157 processedExceptions = new HashSet<String>();
158 }
160 protected void postProcessWebService(WebService webService, TypeElement d) {
161 super.postProcessWebService(webService, d);
162 doPostProcessWebService(webService, d);
163 }
165 protected void doPostProcessWebService(WebService webService, TypeElement d) {
166 if (cm != null) {
167 File sourceDir = builder.getSourceDir();
168 assert(sourceDir != null);
169 WsgenOptions options = builder.getOptions();
170 try {
171 CodeWriter cw = new FilerCodeWriter(sourceDir, options);
172 if(options.verbose)
173 cw = new ProgressCodeWriter(cw, System.out);
174 cm.build(cw);
175 } catch (IOException e) {
176 e.printStackTrace();
177 }
178 }
179 }
181 protected void processMethod(ExecutableElement method, WebMethod webMethod) {
182 builder.log("WrapperGen - method: "+method);
183 builder.log("method.getDeclaringType(): " + method.asType());
184 if (wrapped && soapStyle.equals(SOAPStyle.DOCUMENT)) {
185 generateWrappers(method, webMethod);
186 }
187 generateExceptionBeans(method);
188 }
190 private boolean generateExceptionBeans(ExecutableElement method) {
191 String beanPackage = packageName + PD_JAXWS_PACKAGE_PD.getValue();
192 if (packageName.length() == 0)
193 beanPackage = JAXWS_PACKAGE_PD.getValue();
194 boolean beanGenerated = false;
195 for (TypeMirror thrownType : method.getThrownTypes()) {
196 TypeElement typeDecl = (TypeElement) ((DeclaredType) thrownType).asElement();
197 if (typeDecl == null) {
198 builder.processError(WebserviceapMessages.WEBSERVICEAP_COULD_NOT_FIND_TYPEDECL(
199 thrownType.toString(), context.getRound()));
200 return false;
201 }
202 boolean tmp = generateExceptionBean(typeDecl, beanPackage);
203 beanGenerated = beanGenerated || tmp;
204 }
205 return beanGenerated;
206 }
208 private boolean duplicateName(String name) {
209 for (String str : wrapperNames) {
210 if (str.equalsIgnoreCase(name))
211 return true;
212 }
213 wrapperNames.add(name);
214 return false;
215 }
217 private boolean generateWrappers(ExecutableElement method, WebMethod webMethod) {
218 boolean isOneway = method.getAnnotation(Oneway.class) != null;
219 String beanPackage = packageName + PD_JAXWS_PACKAGE_PD.getValue();
220 if (packageName.length() == 0)
221 beanPackage = JAXWS_PACKAGE_PD.getValue();
222 Name methodName = method.getSimpleName();
223 String operationName = builder.getOperationName(methodName);
224 operationName = webMethod != null && webMethod.operationName().length() > 0 ?
225 webMethod.operationName() : operationName;
226 String reqName = operationName;
227 String resName = operationName + WebServiceConstants.RESPONSE.getValue();
228 String reqNamespace = typeNamespace;
229 String resNamespace = typeNamespace;
231 String requestClassName = beanPackage + StringUtils.capitalize(method.getSimpleName().toString());
232 RequestWrapper reqWrapper = method.getAnnotation(RequestWrapper.class);
233 if (reqWrapper != null) {
234 if (reqWrapper.className().length() > 0)
235 requestClassName = reqWrapper.className();
236 if (reqWrapper.localName().length() > 0)
237 reqName = reqWrapper.localName();
238 if (reqWrapper.targetNamespace().length() > 0)
239 reqNamespace = reqWrapper.targetNamespace();
240 }
241 builder.log("requestWrapper: "+requestClassName);
242 ///// fix for wsgen CR 6442344
243 File file = new File(DirectoryUtil.getOutputDirectoryFor(requestClassName, builder.getSourceDir()),
244 Names.stripQualifier(requestClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue());
245 builder.getOptions().addGeneratedFile(file);
246 //////////
247 boolean canOverwriteRequest = builder.canOverWriteClass(requestClassName);
248 if (!canOverwriteRequest) {
249 builder.log("Class " + requestClassName + " exists. Not overwriting.");
250 }
251 if (duplicateName(requestClassName) && canOverwriteRequest) {
252 builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_REQUEST_WRAPPER_BEAN_NAME_NOT_UNIQUE(
253 typeElement.getQualifiedName(), method.toString()));
254 }
256 String responseClassName = null;
257 boolean canOverwriteResponse = canOverwriteRequest;
258 if (!isOneway) {
259 responseClassName = beanPackage+StringUtils.capitalize(method.getSimpleName().toString())+RESPONSE.getValue();
260 ResponseWrapper resWrapper = method.getAnnotation(ResponseWrapper.class);
261 if(resWrapper != null) {
262 if (resWrapper.className().length() > 0)
263 responseClassName = resWrapper.className();
264 if (resWrapper.localName().length() > 0)
265 resName = resWrapper.localName();
266 if (resWrapper.targetNamespace().length() > 0)
267 resNamespace = resWrapper.targetNamespace();
268 }
269 canOverwriteResponse = builder.canOverWriteClass(responseClassName);
270 if (!canOverwriteResponse) {
271 builder.log("Class " + responseClassName + " exists. Not overwriting.");
272 }
273 if (duplicateName(responseClassName) && canOverwriteResponse) {
274 builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RESPONSE_WRAPPER_BEAN_NAME_NOT_UNIQUE(
275 typeElement.getQualifiedName(), method.toString()));
276 }
277 file = new File(DirectoryUtil.getOutputDirectoryFor(responseClassName, builder.getSourceDir()),
278 Names.stripQualifier(responseClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue());
279 builder.getOptions().addGeneratedFile(file);
280 }
281 //ArrayList<MemberInfo> reqMembers = new ArrayList<MemberInfo>();
282 //ArrayList<MemberInfo> resMembers = new ArrayList<MemberInfo>();
283 WrapperInfo reqWrapperInfo = new WrapperInfo(requestClassName);
284 //reqWrapperInfo.setMembers(reqMembers);
285 WrapperInfo resWrapperInfo = null;
286 if (!isOneway) {
287 resWrapperInfo = new WrapperInfo(responseClassName);
288 //resWrapperInfo.setMembers(resMembers);
289 }
290 seiContext.setReqWrapperOperation(method, reqWrapperInfo);
291 if (!isOneway)
292 seiContext.setResWrapperOperation(method, resWrapperInfo);
293 try {
294 if (!canOverwriteRequest && !canOverwriteResponse) {
295 return false;
296 }
298 JDefinedClass reqCls = null;
299 if (canOverwriteRequest) {
300 reqCls = getCMClass(requestClassName, CLASS);
301 }
303 JDefinedClass resCls = null;
304 if (!isOneway && canOverwriteResponse) {
305 resCls = getCMClass(responseClassName, CLASS);
306 }
308 // XMLElement Declarations
309 writeXmlElementDeclaration(reqCls, reqName,reqNamespace);
310 writeXmlElementDeclaration(resCls, resName, resNamespace);
312 List<MemberInfo> reqMembers = ap_generator.collectRequestBeanMembers(method);
313 List<MemberInfo> resMembers = ap_generator.collectResponseBeanMembers(method);
315 // XmlType
316 writeXmlTypeDeclaration(reqCls, reqName, reqNamespace, reqMembers);
317 writeXmlTypeDeclaration(resCls, resName, resNamespace, resMembers);
319 // class members
320 writeMembers(reqCls, reqMembers);
321 writeMembers(resCls, resMembers);
323 } catch (Exception e) {
324 throw new ModelerException("modeler.nestedGeneratorError",e);
325 }
326 return true;
327 }
329 // private List<Annotation> collectJAXBAnnotations(Declaration decl) {
330 // List<Annotation> jaxbAnnotation = new ArrayList<Annotation>();
331 // for(Class jaxbClass : jaxbAnns) {
332 // Annotation ann = decl.getAnnotation(jaxbClass);
333 // if (ann != null) {
334 // jaxbAnnotation.add(ann);
335 // }
336 // }
337 // return jaxbAnnotation;
338 // }
340 private TypeMirror getSafeType(TypeMirror type) {
341 return makeSafeVisitor.visit(type, builder.getProcessingEnvironment().getTypeUtils());
342 }
344 private JType getType(TypeMirror typeMirror) {
345 String type = typeMirror.toString();
346 try {
347 // System.out.println("typeName: "+typeName);
348 return cm.parseType(type);
349 // System.out.println("type: "+type);
350 } catch (ClassNotFoundException e) {
351 return cm.ref(type);
352 }
353 }
355 private void writeMembers(JDefinedClass cls, Collection<MemberInfo> members) {
356 if (cls == null)
357 return;
358 for (MemberInfo memInfo : members) {
359 JType type = getType(memInfo.getParamType());
360 JFieldVar field = cls.field(JMod.PRIVATE, type, memInfo.getParamName());
361 annotateParameterWithJaxbAnnotations(memInfo, field);
362 }
363 for (MemberInfo memInfo : members) {
364 writeMember(cls, memInfo.getParamType(),
365 memInfo.getParamName());
366 }
367 }
369 private void annotateParameterWithJaxbAnnotations(MemberInfo memInfo, JFieldVar field) {
370 List<Annotation> jaxbAnnotations = memInfo.getJaxbAnnotations();
371 for(Annotation ann : jaxbAnnotations) {
372 if (ann instanceof XmlMimeType) {
373 JAnnotationUse jaxbAnn = field.annotate(XmlMimeType.class);
374 jaxbAnn.param("value", ((XmlMimeType)ann).value());
375 } else if (ann instanceof XmlJavaTypeAdapter) {
376 JAnnotationUse jaxbAnn = field.annotate(XmlJavaTypeAdapter.class);
377 XmlJavaTypeAdapter ja = (XmlJavaTypeAdapter) ann;
378 try {
379 ja.value();
380 throw new AssertionError();
381 } catch (MirroredTypeException e) {
382 jaxbAnn.param("value",getType(e.getTypeMirror()));
383 }
384 // XmlJavaTypeAdapter.type() is for package only. No need to copy.
385 } else if (ann instanceof XmlAttachmentRef) {
386 field.annotate(XmlAttachmentRef.class);
387 } else if (ann instanceof XmlList){
388 field.annotate(XmlList.class);
389 } else if (ann instanceof XmlElement) {
390 XmlElement elemAnn = (XmlElement)ann;
391 JAnnotationUse jAnn = field.annotate(XmlElement.class);
392 jAnn.param("name", elemAnn.name());
393 jAnn.param("namespace", elemAnn.namespace());
394 if (elemAnn.nillable()) {
395 jAnn.param("nillable", true);
396 }
397 if (elemAnn.required()) {
398 jAnn.param("required", true);
399 }
400 } else {
401 throw new WebServiceException("SEI Parameter cannot have this JAXB annotation: " + ann);
402 }
403 }
404 }
406 protected JDefinedClass getCMClass(String className, com.sun.codemodel.internal.ClassType type) {
407 JDefinedClass cls;
408 try {
409 cls = cm._class(className, type);
410 } catch (com.sun.codemodel.internal.JClassAlreadyExistsException e){
411 cls = cm._getClass(className);
412 }
413 return cls;
414 }
416 private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) {
417 if (!builder.isServiceException(thrownDecl.asType()))
418 return false;
420 String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString());
421 if (processedExceptions.contains(exceptionName))
422 return false;
423 processedExceptions.add(exceptionName);
424 WebFault webFault = thrownDecl.getAnnotation(WebFault.class);
425 String className = beanPackage+ exceptionName + BEAN.getValue();
427 Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl);
428 boolean isWSDLException = isWSDLException(members, thrownDecl);
429 String namespace = typeNamespace;
430 String name = exceptionName;
431 FaultInfo faultInfo;
432 if (isWSDLException) {
433 TypeMirror beanType = getFaultInfoMember(members).getParamType();
434 faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true);
435 namespace = webFault.targetNamespace().length()>0 ?
436 webFault.targetNamespace() : namespace;
437 name = webFault.name().length()>0 ?
438 webFault.name() : name;
439 faultInfo.setElementName(new QName(namespace, name));
440 seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
441 return false;
442 }
443 if (webFault != null) {
444 namespace = webFault.targetNamespace().length()>0 ?
445 webFault.targetNamespace() : namespace;
446 name = webFault.name().length()>0 ?
447 webFault.name() : name;
448 className = webFault.faultBean().length()>0 ?
449 webFault.faultBean() : className;
451 }
452 JDefinedClass cls = getCMClass(className, CLASS);
453 faultInfo = new FaultInfo(className, false);
455 if (duplicateName(className)) {
456 builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE(
457 typeElement.getQualifiedName(), thrownDecl.getQualifiedName()));
458 }
460 boolean canOverWriteBean = builder.canOverWriteClass(className);
461 if (!canOverWriteBean) {
462 builder.log("Class " + className + " exists. Not overwriting.");
463 seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
464 return false;
465 }
466 if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null)
467 return false;
469 //write class comment - JAXWS warning
470 JDocComment comment = cls.javadoc();
471 for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) {
472 comment.add(doc);
473 }
475 // XmlElement Declarations
476 writeXmlElementDeclaration(cls, name, namespace);
478 // XmlType Declaration
479 //members = sortMembers(members);
480 XmlType xmlType = thrownDecl.getAnnotation(XmlType.class);
481 String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName;
482 String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace;
483 writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members);
485 writeMembers(cls, members);
487 seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
488 return true;
489 }
491 protected boolean isWSDLException(Collection<MemberInfo> members, TypeElement thrownDecl) {
492 WebFault webFault = thrownDecl.getAnnotation(WebFault.class);
493 return webFault != null && members.size() == 2 && getFaultInfoMember(members) != null;
494 }
496 /*
497 * Returns the corresponding MemberInfo for getFaultInfo()
498 * method of an exception. Returns null, if that method is not there.
499 */
500 private MemberInfo getFaultInfoMember(Collection<MemberInfo> members) {
501 for(MemberInfo member : members) {
502 if (member.getParamName().equals(FAULT_INFO.getValue())) {
503 return member;
504 }
505 }
506 return null;
507 }
509 private void writeXmlElementDeclaration(JDefinedClass cls, String elementName, String namespaceUri) {
511 if (cls == null)
512 return;
513 JAnnotationUse xmlRootElementAnn = cls.annotate(XmlRootElement.class);
514 xmlRootElementAnn.param("name", elementName);
515 if (namespaceUri.length() > 0) {
516 xmlRootElementAnn.param("namespace", namespaceUri);
517 }
518 JAnnotationUse xmlAccessorTypeAnn = cls.annotate(cm.ref(XmlAccessorType.class));
519 xmlAccessorTypeAnn.param("value", XmlAccessType.FIELD);
520 }
522 private void writeXmlTypeDeclaration(JDefinedClass cls, String typeName, String namespaceUri,
523 Collection<MemberInfo> members) {
524 if (cls == null)
525 return;
526 JAnnotationUse xmlTypeAnn = cls.annotate(cm.ref(XmlType.class));
527 xmlTypeAnn.param("name", typeName);
528 xmlTypeAnn.param("namespace", namespaceUri);
529 if (members.size() > 1) {
530 JAnnotationArrayMember paramArray = xmlTypeAnn.paramArray("propOrder");
531 for (MemberInfo memInfo : members) {
532 paramArray.param(memInfo.getParamName());
533 }
534 }
535 }
537 private void writeMember(JDefinedClass cls, TypeMirror paramType,
538 String paramName) {
540 if (cls == null)
541 return;
543 String accessorName =BindingHelper.mangleNameToPropertyName(paramName);
544 String getterPrefix = paramType.toString().equals("boolean")? "is" : "get";
545 JType propType = getType(paramType);
546 JMethod m = cls.method(JMod.PUBLIC, propType, getterPrefix+ accessorName);
547 JDocComment methodDoc = m.javadoc();
548 JCommentPart ret = methodDoc.addReturn();
549 ret.add("returns "+propType.name());
550 JBlock body = m.body();
551 body._return( JExpr._this().ref(paramName) );
553 m = cls.method(JMod.PUBLIC, cm.VOID, "set"+accessorName);
554 JVar param = m.param(propType, paramName);
555 methodDoc = m.javadoc();
556 JCommentPart part = methodDoc.addParam(paramName);
557 part.add("the value for the "+ paramName+" property");
558 body = m.body();
559 body.assign( JExpr._this().ref(paramName), param );
560 }
561 }