KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > jaxrpc > actions > WebServiceCookieFactory


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.jaxrpc.actions;
21
22 // Retouche
23
//import org.netbeans.jmi.javamodel.JavaClass;
24
//import org.netbeans.jmi.javamodel.Resource;
25
//import org.netbeans.modules.javacore.api.JavaModel;
26
import org.netbeans.modules.j2ee.dd.api.webservices.DDProvider;
27 import org.openide.ErrorManager;
28 import org.openide.filesystems.FileObject;
29 import org.netbeans.modules.websvc.api.webservices.WebServicesSupport;
30 import org.netbeans.modules.j2ee.dd.api.webservices.Webservices;
31 import org.netbeans.modules.j2ee.dd.api.webservices.PortComponent;
32 import org.netbeans.modules.j2ee.dd.api.webservices.ServiceImplBean;
33 import org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription;
34 import org.openide.loaders.*;
35
36 public class WebServiceCookieFactory {
37
38     private WebServiceCookieFactory() {}
39     
40     public static WebServiceClassesCookie getWebServiceClassesCookie(/*Retouche : JavaClass ce*/FileObject f) {
41 // RETOUCHE
42
// if (ce == null) return null;
43
// Resource r = ce.getResource();
44
// FileObject f = JavaModel.getFileObject(r);
45
if (f != null) {
46             return new WebServiceClassesCookieImpl(findWSDescriptionFromClass(/*RETOUCHE: ce,*/ f), f);
47         }
48         return null;
49     }
50
51     public static WebserviceDescription findWSDescriptionFromClass(/* Retouche:JavaClass ce,*/ FileObject implClassFO) {
52         WebServicesSupport wsSupport = WebServicesSupport.getWebServicesSupport(implClassFO);
53         if (wsSupport != null) {
54             DDProvider wsDDProvider = DDProvider.getDefault();
55             Webservices webServices = null;
56             try {
57                 webServices = wsDDProvider.getDDRoot(wsSupport.getWebservicesDD());
58             } catch(java.io.IOException JavaDoc e) {
59                 throw new RuntimeException JavaDoc(e.getMessage());
60             }
61           
62             if(webServices != null) {
63                 WebserviceDescription[] wsDescriptions = webServices.getWebserviceDescription();
64                 for (int i = 0; i < wsDescriptions.length; i++) {
65                     WebserviceDescription wsDescription = wsDescriptions[i];
66                     PortComponent portComponent = wsDescription.getPortComponent(0);
67                     
68                     // first check the interface
69
String JavaDoc wsSEI = portComponent.getServiceEndpointInterface();
70                     // Retouche
71
//if ((wsSEI != null) && (wsSEI.equals(ce.getName()))) {
72
if ((wsSEI != null) && (wsSEI.equals(implClassFO.getName()))) {
73                         return wsDescription;
74                     }
75                     
76                     // then the implementation bean
77
ServiceImplBean serviceImplBean = portComponent.getServiceImplBean();
78                     String JavaDoc link = serviceImplBean.getServletLink();
79                     if (link == null) {
80                         link = serviceImplBean.getEjbLink();
81                     }
82                     String JavaDoc implBean = wsSupport.getImplementationBean(link);
83                     if (implBean == null) {
84                         ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "WSCFactory: Implementation bean reference could not be found.");
85                     // Retouche
86
//} else if (implBean.equals(ce.getName())) {
87
} else if (implBean.equals(implClassFO.getName())) {
88                         return wsDescription;
89                     }
90                 }
91             }
92         }
93         return null;
94     }
95
96 }
97
Popular Tags