001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.tools.internal.ws.processor.model;
026:
027: import javax.xml.namespace.QName;
028:
029: import com.sun.tools.internal.ws.processor.model.jaxb.JAXBType;
030: import com.sun.tools.internal.ws.processor.model.jaxb.JAXBTypeAndAnnotation;
031: import com.sun.tools.internal.ws.processor.model.java.JavaType;
032: import com.sun.tools.internal.ws.processor.model.java.JavaSimpleType;
033: import com.sun.codemodel.internal.JClass;
034: import com.sun.codemodel.internal.JCodeModel;
035:
036: /**
037: * @author Vivek Pandey
038: *
039: *
040: */
041: public class AsyncOperation extends Operation {
042:
043: /**
044: *
045: */
046: public AsyncOperation() {
047: super ();
048: // TODO Auto-generated constructor stub
049: }
050:
051: /**
052: * @param operation
053: */
054: public AsyncOperation(Operation operation) {
055: super (operation);
056: this .operation = operation;
057: }
058:
059: /**
060: * @param name
061: */
062: public AsyncOperation(QName name) {
063: super (name);
064: // TODO Auto-generated constructor stub
065: }
066:
067: /**
068: * @return Returns the async.
069: */
070: public boolean isAsync() {
071: return _async;
072: }
073:
074: public void setAsyncType(AsyncOperationType type) {
075: this ._asyncOpType = type;
076: _async = true;
077: }
078:
079: public AsyncOperationType getAsyncType() {
080: return _asyncOpType;
081: }
082:
083: public void setResponseBean(AbstractType type) {
084: _responseBean = type;
085: }
086:
087: public AbstractType getResponseBeanType() {
088: return _responseBean;
089: }
090:
091: public JavaType getResponseBeanJavaType() {
092: JCodeModel cm = _responseBean.getJavaType().getType().getType()
093: .owner();
094: if (_asyncOpType.equals(AsyncOperationType.CALLBACK)) {
095: JClass future = cm.ref(java.util.concurrent.Future.class)
096: .narrow(cm.ref(Object.class).wildcard());
097: return new JavaSimpleType(new JAXBTypeAndAnnotation(future));
098: } else if (_asyncOpType.equals(AsyncOperationType.POLLING)) {
099: JClass polling = cm.ref(javax.xml.ws.Response.class)
100: .narrow(
101: _responseBean.getJavaType().getType()
102: .getType().boxify());
103: return new JavaSimpleType(
104: new JAXBTypeAndAnnotation(polling));
105: }
106: return null;
107: }
108:
109: public JavaType getCallBackType() {
110: if (_asyncOpType.equals(AsyncOperationType.CALLBACK)) {
111: JCodeModel cm = _responseBean.getJavaType().getType()
112: .getType().owner();
113: JClass cb = cm.ref(javax.xml.ws.AsyncHandler.class).narrow(
114: _responseBean.getJavaType().getType().getType()
115: .boxify());
116: return new JavaSimpleType(new JAXBTypeAndAnnotation(cb));
117:
118: }
119: return null;
120: }
121:
122: public Operation getNormalOperation() {
123: return operation;
124: }
125:
126: public void setNormalOperation(Operation operation) {
127: this .operation = operation;
128: }
129:
130: @Override
131: public String getJavaMethodName() {
132: return super .getJavaMethodName() + "Async";
133: }
134:
135: //Normal operation
136: private Operation operation;
137: private boolean _async;
138: private AsyncOperationType _asyncOpType;
139: private AbstractType _responseBean;
140:
141: }
|