01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.tools.java2wsdl.generator.wsdl11.annotator;
19:
20: import org.apache.cxf.tools.common.model.Annotator;
21: import org.apache.cxf.tools.common.model.JavaAnnotatable;
22: import org.apache.cxf.tools.common.model.JavaAnnotation;
23: import org.apache.cxf.tools.java2wsdl.generator.wsdl11.model.WrapperBeanClass;
24:
25: public class WrapperBeanAnnotator implements Annotator {
26:
27: public void annotate(final JavaAnnotatable clz) {
28: WrapperBeanClass wrapperBeanClass = null;
29: if (clz instanceof WrapperBeanClass) {
30: wrapperBeanClass = (WrapperBeanClass) clz;
31: } else {
32: throw new RuntimeException(
33: "WrapperBeanAnnotator expect JavaClass as input");
34: }
35:
36: JavaAnnotation xmlRootElement = new JavaAnnotation(
37: "XmlRootElement");
38: xmlRootElement.addArgument("name", wrapperBeanClass
39: .getElementName().getLocalPart());
40: xmlRootElement.addArgument("namespace", wrapperBeanClass
41: .getElementName().getNamespaceURI());
42:
43: JavaAnnotation xmlAccessorType = new JavaAnnotation(
44: "XmlAccessorType");
45: xmlAccessorType.addArgument("XmlAccessType.FIELD", "null", "");
46:
47: JavaAnnotation xmlType = new JavaAnnotation("XmlType");
48: //xmlType.addArgument("name", wrapperBeanClass.getElementName().getLocalPart());
49: xmlType.addArgument("name", wrapperBeanClass.getElementName()
50: .getLocalPart());
51: xmlType.addArgument("namespace", wrapperBeanClass
52: .getElementName().getNamespaceURI());
53: // Revisit: why annotation is string?
54: wrapperBeanClass.addAnnotation(xmlRootElement.toString());
55: wrapperBeanClass.addAnnotation(xmlAccessorType.toString());
56: wrapperBeanClass.addAnnotation(xmlType.toString());
57:
58: wrapperBeanClass
59: .addImport("javax.xml.bind.annotation.XmlAccessType");
60: wrapperBeanClass
61: .addImport("javax.xml.bind.annotation.XmlAccessorType");
62: wrapperBeanClass
63: .addImport("javax.xml.bind.annotation.XmlRootElement");
64: wrapperBeanClass.addImport("javax.xml.bind.annotation.XmlType");
65: }
66: }
|