001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.websvc.api.jaxws.wsdlmodel;
043:
044: import com.sun.tools.ws.processor.model.Operation;
045: import com.sun.tools.ws.processor.model.java.JavaParameter;
046: import java.util.*;
047: import org.openide.util.NbBundle;
048:
049: /**
050: *
051: * @author mkuchtiak
052: */
053: public class WsdlOperation {
054: public static final int TYPE_NORMAL = 0;
055: public static final int TYPE_ASYNC_POLLING = 1;
056: public static final int TYPE_ASYNC_CALLBACK = 2;
057:
058: private String operationName;
059: private Operation operation;
060:
061: /** Creates a new instance of WsdlOperation */
062: public WsdlOperation(Operation operation) {
063: this .operation = operation;
064: }
065:
066: public Object /*com.sun.tools.ws.processor.model.Operation*/getInternalJAXWSOperation() {
067: return operation;
068: }
069:
070: public String getName() {
071: if (operationName == null) {
072: operationName = operation.getName().getLocalPart();
073: }
074: String postfix = null;
075: switch (getOperationType()) {
076: case TYPE_NORMAL:
077: break;
078: case TYPE_ASYNC_POLLING: {
079: postfix = NbBundle.getMessage(WsdlOperation.class,
080: "TXT_asyncPolling");
081: break;
082: }
083: case TYPE_ASYNC_CALLBACK: {
084: postfix = NbBundle.getMessage(WsdlOperation.class,
085: "TXT_asyncCallback");
086: break;
087: }
088: }
089: if (postfix != null)
090: operationName = NbBundle.getMessage(WsdlOperation.class,
091: "TXT_operationName", operationName, postfix);
092: return operationName;
093: }
094:
095: public String getJavaName() {
096: return operation.getJavaMethod().getName();
097: }
098:
099: public String getReturnTypeName() {
100: return operation.getJavaMethod().getReturnType().getName();
101: }
102:
103: public List<WsdlParameter> getParameters() {
104: List<WsdlParameter> wsdlParameters = new ArrayList<WsdlParameter>();
105: if (operation == null)
106: return wsdlParameters;
107: List<JavaParameter> parameterList = operation.getJavaMethod()
108: .getParametersList();
109: for (JavaParameter param : parameterList)
110: wsdlParameters.add(new WsdlParameter(param));
111: return wsdlParameters;
112: }
113:
114: public Iterator<String> getExceptions() {
115: return operation.getJavaMethod().getExceptions();
116: }
117:
118: public int getOperationType() {
119: String returnType = getReturnTypeName();
120: if (returnType.startsWith("javax.xml.ws.Response")) { //NOI18N
121: return TYPE_ASYNC_POLLING;
122: } else if (returnType.startsWith("java.util.concurrent.Future")) { //NOI18N
123: return TYPE_ASYNC_CALLBACK;
124: } else
125: return TYPE_NORMAL;
126:
127: }
128:
129: public String getOperationName() {
130: if (operationName == null) {
131: operationName = operation.getName().getLocalPart();
132: }
133: return operationName;
134: }
135:
136: public void setOperationName(String operationName) {
137: this.operationName = operationName;
138: }
139:
140: }
|