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.wsdlto.frontend.jaxws.processor.internal.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.common.model.JavaMethod;
24: import org.apache.cxf.tools.common.model.JavaParameter;
25:
26: public class WrapperAnnotator implements Annotator {
27: JavaParameter wrapperRequest;
28: JavaParameter wrapperResponse;
29:
30: public WrapperAnnotator(JavaParameter request,
31: JavaParameter response) {
32: wrapperRequest = request;
33: wrapperResponse = response;
34: }
35:
36: public void annotate(JavaAnnotatable ja) {
37: JavaMethod method;
38: if (ja instanceof JavaMethod) {
39: method = (JavaMethod) ja;
40: } else {
41: throw new RuntimeException(
42: "RequestWrapper and ResponseWrapper can only annotate JavaMethod");
43: }
44: if (wrapperRequest != null) {
45: JavaAnnotation wrapperRequestAnnotation = new JavaAnnotation(
46: "RequestWrapper");
47: wrapperRequestAnnotation.addArgument("localName",
48: wrapperRequest.getType());
49: wrapperRequestAnnotation.addArgument("targetNamespace",
50: wrapperRequest.getTargetNamespace());
51: wrapperRequestAnnotation.addArgument("className",
52: wrapperRequest.getClassName());
53: method.addAnnotation("RequestWrapper",
54: wrapperRequestAnnotation);
55: method.getInterface().addImport(
56: "javax.xml.ws.RequestWrapper");
57: }
58: if (wrapperResponse != null) {
59: JavaAnnotation wrapperResponseAnnotation = new JavaAnnotation(
60: "ResponseWrapper");
61: wrapperResponseAnnotation.addArgument("localName",
62: wrapperResponse.getType());
63: wrapperResponseAnnotation.addArgument("targetNamespace",
64: wrapperResponse.getTargetNamespace());
65: wrapperResponseAnnotation.addArgument("className",
66: wrapperResponse.getClassName());
67: method.addAnnotation("ResponseWrapper",
68: wrapperResponseAnnotation);
69: method.getInterface().addImport(
70: "javax.xml.ws.ResponseWrapper");
71: }
72: }
73: }
|