1 23 package com.sun.enterprise.admin.wsmgmt.config.impl; 24 25 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigProvider; 26 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigFactory; 27 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig; 28 29 import java.util.List ; 30 import java.util.ArrayList ; 31 import com.sun.enterprise.config.serverbeans.ServerHelper; 32 import com.sun.enterprise.config.serverbeans.ApplicationHelper; 33 import com.sun.enterprise.config.ConfigBean; 34 import com.sun.enterprise.config.serverbeans.ApplicationRef; 35 import com.sun.enterprise.config.ConfigContext; 36 import com.sun.enterprise.config.ConfigException; 37 import com.sun.enterprise.server.ApplicationServer; 38 39 import com.sun.enterprise.config.serverbeans.WebServiceEndpoint; 40 import com.sun.enterprise.config.serverbeans.WebModule; 41 import com.sun.enterprise.config.serverbeans.EjbModule; 42 import com.sun.enterprise.config.serverbeans.J2eeApplication; 43 44 48 public class AppServConfigProvider implements ConfigProvider 49 { 50 51 56 public String getProviderID() { 57 return ConfigFactory.CONFIG_DEFAULT_PROVIDER; 58 } 59 60 67 public WebServiceConfig[] getWebserviceConfigs(String appId) { 68 WebServiceEndpoint[] wsps = getWebServiceEndpoints(appId); 69 70 WebServiceConfig[] wsCfgs = new WebServiceConfig[wsps.length]; 71 for (int idx =0; idx < wsps.length; idx++) { 72 wsCfgs[idx] = new WebServiceConfigImpl(wsps[idx]); 73 } 74 return wsCfgs; 75 } 76 77 WebServiceEndpoint[] getWebServiceEndpoints(String appId) { 78 WebServiceEndpoint[] wsps = null; 79 try { 80 ConfigContext ctx = ApplicationServer.getServerContext(). 81 getConfigContext(); 82 83 ConfigBean cb = ApplicationHelper.findApplication(ctx, appId); 84 85 88 if ( cb instanceof WebModule) { 89 wsps = ( (WebModule) cb).getWebServiceEndpoint(); 90 } else if ( cb instanceof EjbModule) { 91 wsps = ( (EjbModule) cb).getWebServiceEndpoint(); 92 } else if (cb instanceof J2eeApplication) { 93 wsps = ( (J2eeApplication) cb).getWebServiceEndpoint(); 94 } 95 96 } catch (ConfigException ce) { 97 } finally { 99 return wsps; 100 } 101 } 102 103 110 public WebServiceConfig getWebServiceConfig(String appId, String modId, 111 boolean isStandalone, String name) { 112 113 WebServiceEndpoint[] wsps = getWebServiceEndpoints(appId); 114 115 for (int idx =0; idx < wsps.length; idx++) { 116 String sName = null; 117 if ( isStandalone ) { 118 sName = name; 119 } else { 120 sName = modId + "#" + name; 121 } 122 if ( wsps[idx].getName().equals(sName) ) { 123 return new WebServiceConfigImpl(wsps[idx]); 124 } 125 } 126 return null; 127 } 128 129 130 137 public WebServiceConfig getWebServiceConfig(String fqn) { 138 139 if (fqn==null) return null; 140 String appId = null; 141 int sepIdx = fqn.indexOf("#"); 142 appId = fqn.substring(0, sepIdx); 143 String partialName = fqn.substring(sepIdx +1); 144 145 WebServiceEndpoint[] wsps = getWebServiceEndpoints(appId); 146 147 for (int idx =0; idx < wsps.length; idx++) { 148 if ( wsps[idx].getName().equals(partialName) ) { 149 return new WebServiceConfigImpl(wsps[idx]); 150 } 151 } 152 return null; 153 } 154 155 161 public List getManagedWebserviceApplicationIds() { 162 163 List aList = new ArrayList (); 164 try { 165 ConfigContext ctx = ApplicationServer.getServerContext(). 166 getConfigContext(); 167 168 String serverName = 169 ApplicationServer.getServerContext().getInstanceName(); 170 171 ApplicationRef[] appRefs =ServerHelper.getApplicationReferences(ctx, 172 serverName); 173 for ( int appIdx =0; appIdx < appRefs.length; appIdx++) { 174 String appName = appRefs[appIdx].getRef(); 175 ConfigBean cb = ApplicationHelper.findApplication(ctx, appName); 176 179 int wsSize = 0; 180 181 if ( cb instanceof WebModule) { 182 wsSize = ( (WebModule) cb).sizeWebServiceEndpoint(); 183 } else if ( cb instanceof EjbModule) { 184 wsSize = ( (EjbModule) cb).sizeWebServiceEndpoint(); 185 } else if (cb instanceof J2eeApplication) { 186 wsSize = ( (J2eeApplication) cb).sizeWebServiceEndpoint(); 187 } 188 189 if (wsSize > 0) { aList.add(appName); } 190 } 191 } catch (ConfigException ce) { 192 } finally { 194 return aList; 195 } 196 } 197 198 } 199 | Popular Tags |