1 19 20 package org.netbeans.modules.websvc.jaxrpc.actions; 21 22 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(FileObject f) { 41 if (f != null) { 46 return new WebServiceClassesCookieImpl(findWSDescriptionFromClass( f), f); 47 } 48 return null; 49 } 50 51 public static WebserviceDescription findWSDescriptionFromClass( 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 e) { 59 throw new RuntimeException (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 String wsSEI = portComponent.getServiceEndpointInterface(); 70 if ((wsSEI != null) && (wsSEI.equals(implClassFO.getName()))) { 73 return wsDescription; 74 } 75 76 ServiceImplBean serviceImplBean = portComponent.getServiceImplBean(); 78 String link = serviceImplBean.getServletLink(); 79 if (link == null) { 80 link = serviceImplBean.getEjbLink(); 81 } 82 String implBean = wsSupport.getImplementationBean(link); 83 if (implBean == null) { 84 ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "WSCFactory: Implementation bean reference could not be found."); 85 } else if (implBean.equals(implClassFO.getName())) { 88 return wsDescription; 89 } 90 } 91 } 92 } 93 return null; 94 } 95 96 } 97 | Popular Tags |