|
1 /* |
|
2 * Copyright (c) 1997, 2012, 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 */ |
|
25 |
|
26 package com.sun.tools.internal.ws.processor.model; |
|
27 |
|
28 import com.sun.codemodel.internal.JClass; |
|
29 import com.sun.codemodel.internal.JCodeModel; |
|
30 import com.sun.tools.internal.ws.processor.model.java.JavaSimpleType; |
|
31 import com.sun.tools.internal.ws.processor.model.java.JavaType; |
|
32 import com.sun.tools.internal.ws.processor.model.jaxb.JAXBTypeAndAnnotation; |
|
33 import com.sun.tools.internal.ws.wsdl.framework.Entity; |
|
34 |
|
35 import javax.xml.namespace.QName; |
|
36 |
|
37 |
|
38 /** |
|
39 * @author Vivek Pandey |
|
40 * |
|
41 * |
|
42 */ |
|
43 public class AsyncOperation extends Operation { |
|
44 |
|
45 /** |
|
46 * |
|
47 */ |
|
48 public AsyncOperation(Entity entity) { |
|
49 super(entity); |
|
50 // TODO Auto-generated constructor stub |
|
51 } |
|
52 |
|
53 /** |
|
54 * @param operation |
|
55 */ |
|
56 public AsyncOperation(Operation operation, Entity entity) { |
|
57 super(operation, entity); |
|
58 this.operation = operation; |
|
59 } |
|
60 |
|
61 /** |
|
62 * @param name |
|
63 */ |
|
64 public AsyncOperation(QName name, Entity entity) { |
|
65 super(name, entity); |
|
66 // TODO Auto-generated constructor stub |
|
67 } |
|
68 |
|
69 /** |
|
70 * @return Returns the async. |
|
71 */ |
|
72 public boolean isAsync() { |
|
73 return _async; |
|
74 } |
|
75 |
|
76 public void setAsyncType(AsyncOperationType type) { |
|
77 this._asyncOpType = type; |
|
78 _async = true; |
|
79 } |
|
80 |
|
81 public AsyncOperationType getAsyncType(){ |
|
82 return _asyncOpType; |
|
83 } |
|
84 |
|
85 public void setResponseBean(AbstractType type){ |
|
86 _responseBean = type; |
|
87 } |
|
88 |
|
89 public AbstractType getResponseBeanType(){ |
|
90 return _responseBean; |
|
91 } |
|
92 |
|
93 public JavaType getResponseBeanJavaType(){ |
|
94 JCodeModel cm = _responseBean.getJavaType().getType().getType().owner(); |
|
95 if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){ |
|
96 JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard()); |
|
97 return new JavaSimpleType(new JAXBTypeAndAnnotation(future)); |
|
98 }else if(_asyncOpType.equals(AsyncOperationType.POLLING)){ |
|
99 JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify()); |
|
100 return new JavaSimpleType(new JAXBTypeAndAnnotation(polling)); |
|
101 } |
|
102 return null; |
|
103 } |
|
104 |
|
105 public JavaType getCallBackType(){ |
|
106 if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){ |
|
107 JCodeModel cm = _responseBean.getJavaType().getType().getType().owner(); |
|
108 JClass cb = cm.ref(javax.xml.ws.AsyncHandler.class).narrow(_responseBean.getJavaType().getType().getType().boxify()); |
|
109 return new JavaSimpleType(new JAXBTypeAndAnnotation(cb)); |
|
110 |
|
111 } |
|
112 return null; |
|
113 } |
|
114 |
|
115 public Operation getNormalOperation(){ |
|
116 return operation; |
|
117 } |
|
118 |
|
119 public void setNormalOperation(Operation operation){ |
|
120 this.operation = operation; |
|
121 } |
|
122 |
|
123 @Override public String getJavaMethodName() { |
|
124 return super.getJavaMethodName() + "Async"; |
|
125 } |
|
126 |
|
127 //Normal operation |
|
128 private Operation operation; |
|
129 private boolean _async; |
|
130 private AsyncOperationType _asyncOpType; |
|
131 private AbstractType _responseBean; |
|
132 |
|
133 } |