KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > api > jaxws > wsdlmodel > WsdlOperation


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.api.jaxws.wsdlmodel;
21
22 import com.sun.tools.ws.processor.model.Operation;
23 import com.sun.tools.ws.processor.model.java.JavaParameter;
24 import java.util.*;
25 import org.openide.util.NbBundle;
26
27 /**
28  *
29  * @author mkuchtiak
30  */

31 public class WsdlOperation {
32     public static final int TYPE_NORMAL=0;
33     public static final int TYPE_ASYNC_POLLING=1;
34     public static final int TYPE_ASYNC_CALLBACK=2;
35     
36     private Operation operation;
37     /** Creates a new instance of WsdlOperation */
38     public WsdlOperation(Operation operation) {
39         this.operation=operation;
40     }
41     
42     public Object JavaDoc /*com.sun.tools.ws.processor.model.Operation*/ getInternalJAXWSOperation() {
43         return operation;
44     }
45     
46     public String JavaDoc getName() {
47         String JavaDoc operationName = operation.getName().getLocalPart();
48         String JavaDoc postfix=null;
49         switch (getOperationType()) {
50             case TYPE_NORMAL:break;
51             case TYPE_ASYNC_POLLING: {
52                 postfix = NbBundle.getMessage(WsdlOperation.class,"TXT_asyncPolling");
53                 break;
54             }
55             case TYPE_ASYNC_CALLBACK: {
56                 postfix = NbBundle.getMessage(WsdlOperation.class,"TXT_asyncCallback");
57                 break;
58             }
59         }
60         if (postfix!=null)
61             operationName = NbBundle.getMessage(WsdlOperation.class,"TXT_operationName",operationName,postfix);
62         return operationName;
63     }
64     
65     public String JavaDoc getJavaName() {
66         return operation.getJavaMethod().getName();
67     }
68     
69     public String JavaDoc getReturnTypeName() {
70         return operation.getJavaMethod().getReturnType().getName();
71     }
72     
73     public List<WsdlParameter> getParameters() {
74         List<WsdlParameter> wsdlParameters = new ArrayList<WsdlParameter> ();
75         if (operation==null) return wsdlParameters;
76         List<JavaParameter> parameterList = operation.getJavaMethod().getParametersList();
77         for (JavaParameter param: parameterList)
78             wsdlParameters.add(new WsdlParameter(param));
79         return wsdlParameters;
80     }
81     
82     public Iterator<String JavaDoc> getExceptions() {
83         return operation.getJavaMethod().getExceptions();
84     }
85     
86     public int getOperationType() {
87         String JavaDoc returnType = getReturnTypeName();
88         if (returnType.startsWith("javax.xml.ws.Response")) { //NOI18N
89
return TYPE_ASYNC_POLLING;
90         } else if (returnType.startsWith("java.util.concurrent.Future")) { //NOI18N
91
return TYPE_ASYNC_CALLBACK;
92         } else return TYPE_NORMAL;
93         
94     }
95     
96 }
97
Popular Tags