AsyncOperation.java revision 325
0N/A/*
2362N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.internal.ws.processor.model;
0N/A
0N/Aimport com.sun.codemodel.internal.JClass;
0N/Aimport com.sun.codemodel.internal.JCodeModel;
0N/Aimport com.sun.tools.internal.ws.processor.model.java.JavaSimpleType;
0N/Aimport com.sun.tools.internal.ws.processor.model.java.JavaType;
0N/Aimport com.sun.tools.internal.ws.processor.model.jaxb.JAXBTypeAndAnnotation;
0N/Aimport com.sun.tools.internal.ws.wsdl.framework.Entity;
0N/A
0N/Aimport javax.xml.namespace.QName;
0N/A
0N/A
0N/A/**
0N/A * @author Vivek Pandey
0N/A *
0N/A *
0N/A */
0N/Apublic class AsyncOperation extends Operation {
0N/A
0N/A /**
0N/A *
0N/A */
0N/A public AsyncOperation(Entity entity) {
0N/A super(entity);
0N/A // TODO Auto-generated constructor stub
0N/A }
0N/A
0N/A /**
0N/A * @param operation
0N/A */
0N/A public AsyncOperation(Operation operation, Entity entity) {
0N/A super(operation, entity);
0N/A this.operation = operation;
0N/A }
0N/A
0N/A /**
0N/A * @param name
0N/A */
public AsyncOperation(QName name, Entity entity) {
super(name, entity);
// TODO Auto-generated constructor stub
}
/**
* @return Returns the async.
*/
public boolean isAsync() {
return _async;
}
public void setAsyncType(AsyncOperationType type) {
this._asyncOpType = type;
_async = true;
}
public AsyncOperationType getAsyncType(){
return _asyncOpType;
}
public void setResponseBean(AbstractType type){
_responseBean = type;
}
public AbstractType getResponseBeanType(){
return _responseBean;
}
public JavaType getResponseBeanJavaType(){
JCodeModel cm = _responseBean.getJavaType().getType().getType().owner();
if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){
JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard());
return new JavaSimpleType(new JAXBTypeAndAnnotation(future));
}else if(_asyncOpType.equals(AsyncOperationType.POLLING)){
JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify());
return new JavaSimpleType(new JAXBTypeAndAnnotation(polling));
}
return null;
}
public JavaType getCallBackType(){
if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){
JCodeModel cm = _responseBean.getJavaType().getType().getType().owner();
JClass cb = cm.ref(javax.xml.ws.AsyncHandler.class).narrow(_responseBean.getJavaType().getType().getType().boxify());
return new JavaSimpleType(new JAXBTypeAndAnnotation(cb));
}
return null;
}
public Operation getNormalOperation(){
return operation;
}
public void setNormalOperation(Operation operation){
this.operation = operation;
}
@Override public String getJavaMethodName() {
return super.getJavaMethodName() + "Async";
}
//Normal operation
private Operation operation;
private boolean _async;
private AsyncOperationType _asyncOpType;
private AbstractType _responseBean;
}