1 23 24 package com.sun.enterprise.server.ondemand; 25 26 27 import java.util.logging.Logger ; 28 import java.util.logging.Level ; 29 import javax.management.ObjectName ; 30 import com.sun.enterprise.deployment.*; 31 import com.sun.enterprise.config.*; 32 import com.sun.enterprise.config.serverbeans.*; 33 import com.sun.appserv.server.ServerLifecycle; 34 import com.sun.appserv.server.ServerLifecycleException; 35 import com.sun.enterprise.server.ondemand.entry.EntryContext; 36 import com.sun.enterprise.server.ondemand.entry.EntryPoint; 37 import com.sun.enterprise.server.ServerContext; 38 import com.sun.enterprise.appclient.jws.AppclientJWSSupportManager; 39 40 48 public class WebServiceGroup extends ServiceGroup { 49 50 58 public void start(EntryContext context) throws ServiceGroupException { 59 try { 60 startLifecycleServices(context.getServerContext()); 61 loadSystemApps(); 62 AppclientJWSSupportManager.getInstance(). 63 startJWSServicesForDeployedAppclients(); 64 setState(ServiceGroup.STARTED); 65 } catch (Exception e) { 66 throw new ServiceGroupException (e); 67 } 68 } 69 70 75 private void loadSystemApps() { 76 SystemAppLoader loader = OnDemandServer.getSystemAppLoader(); 77 loader.loadSystemApps(loader.getWebServiceGroupSystemApps()); 78 } 79 80 88 public boolean analyseEntryContext( EntryContext context ) { 89 90 if (_logger.isLoggable(Level.FINER)) { 91 _logger.log(Level.FINER, 92 "Analysing the context in Web ServiceGroup :" + context); 93 } 94 95 if (context.get() == null) { 96 return false; 97 } 98 99 boolean result = false; 100 try { 101 ConfigContext ctxt = context.getServerContext().getConfigContext(); 102 Config conf = ServerBeansFactory.getConfigBean( ctxt ); 103 104 if (context.getEntryPointType() == EntryPoint.APPLOADER ) { 105 Descriptor desc = (Descriptor) context.get(); 106 if (desc instanceof Application) { 107 result = !((Application) desc).getWebBundleDescriptors().isEmpty() || 110 !((Application) desc).getWebServiceDescriptors().isEmpty(); 111 } else if (desc instanceof EjbBundleDescriptor) { 112 result = ((EjbBundleDescriptor) desc).hasWebServices(); 113 } else if (desc instanceof EjbAbstractDescriptor) { 114 result = ((EjbAbstractDescriptor) desc).hasWebServiceEndpointInterface(); 115 } else { 116 result = desc instanceof WebBundleDescriptor || 117 desc instanceof WebServicesDescriptor; 118 } 119 } 120 121 if ( context.getEntryPointType() == EntryPoint.JNDI ) { 122 125 } 126 127 if ( context.getEntryPointType() == EntryPoint.PORT ) { 128 HttpService httpService = conf.getHttpService(); 130 HttpListener[] httpListeners = httpService.getHttpListener(); 131 for ( int i=0; i<httpListeners.length; i++ ) { 132 int port = Integer.parseInt(httpListeners[i].getPort()); 133 if (port == ((Integer ) context.get()).intValue() ) { 134 result = true; 135 } 136 } 137 } 138 139 if (context.getEntryPointType() == EntryPoint.MBEAN) { 140 result = analyseObjectName((ObjectName ) context.get()); 141 } 142 } catch (Exception e) { 143 e.printStackTrace(); 144 result = false; 145 } 146 147 return result; 148 } 149 150 private boolean analyseObjectName(ObjectName name) { 153 154 164 165 String type = name.getKeyProperty("type"); 166 if ((type != null) && type.equals("Loader")) { 167 return true; 168 } 169 170 String j2eeType = name.getKeyProperty("j2eeType"); 171 if ((j2eeType != null) && 172 j2eeType.equals("WebModule")) { 173 return true; 174 } 175 176 if (name.getKeyProperty("WebModule") != null) { 177 return true; 178 } 179 180 String nameStr = name.getKeyProperty("name"); 181 String ref = name.getKeyProperty("ref"); 182 String app = name.getKeyProperty("J2EEApplication"); 183 184 return belongsToThisServiceGroup(nameStr) || 185 belongsToThisServiceGroup(ref) || 186 belongsToThisServiceGroup(app); 187 188 189 } 190 191 private boolean belongsToThisServiceGroup(String name) { 192 SystemAppLoader appLoader = OnDemandServer.getSystemAppLoader(); 193 if (appLoader != null) { 194 for (Object n : appLoader.getWebServiceGroupSystemApps()) { 195 if (((String ) n).equals(name)) { 196 return true; 197 } 198 } 199 } 200 return false; 201 } 202 203 204 208 private void startLifecycleServices(ServerContext context) { 209 String [][] services = OnDemandServices.getWebServiceGroupServices(); 210 super.startLifecycleServices(services, context); 211 } 212 213 217 public void stop(EntryContext context) throws ServiceGroupException { 218 super.stopLifecycleServices(); 219 } 220 221 224 public void abort(EntryContext context) { 225 super.stopLifecycleServices(); 226 } 227 } 228 | Popular Tags |