1 23 24 package com.sun.enterprise.server.ondemand; 25 26 import java.util.*; 27 import java.util.logging.*; 28 import com.sun.logging.LogDomains; 29 import com.sun.enterprise.server.*; 30 import com.sun.enterprise.server.ss.*; 31 import com.sun.enterprise.server.ondemand.entry.*; 32 33 import com.sun.appserv.server.ServerLifecycle; 34 import com.sun.appserv.server.LifecycleEvent; 35 import com.sun.appserv.server.ServerLifecycleException; 36 import com.sun.enterprise.server.pluggable.PluggableFeatureFactory; 37 import com.sun.enterprise.server.pluggable.PluggableFeatureFactoryImpl; 38 import com.sun.enterprise.server.pluggable.InternalServicesList; 39 40 41 42 46 public class OnDemandServer extends ApplicationServer implements EntryPoint{ 47 48 private static boolean onDemandStartup = true; 49 50 private static ServerEntryListener listener = null; 51 private static SystemAppLoader systemAppLoader = null; 52 private ServiceGroup sg = null; 53 54 55 static Logger _logger = LogDomains.getLogger(LogDomains.CORE_LOGGER); 56 57 58 71 public void onInitialization(ServerContext context) 72 throws ServerLifecycleException { 73 listener = new ServerEntryListenerImpl(this); 74 ServiceGroupBuilder builder = new ServiceGroupBuilder(); 75 sg = builder.buildServiceGroup(this); 76 77 try { 81 super.setServerContext(context); 82 PluggableFeatureFactory pff = context.getPluggableFeatureFactory(); 83 ASLazyKernel lazyStartupKernel = pff.getASLazyKernel(); 84 onDemandStartup = lazyStartupKernel.startASSocketServices(context) ; 85 } catch (Exception e) { 86 onDemandStartup = false; 87 } 89 com.sun.enterprise.naming.SerialInitContextFactory. 92 setInitializeOrbManager(false); 93 super.onInitialization(context); 94 try { 95 systemAppLoader = new SystemAppLoader(); 96 } catch (Exception e) { 97 throw new ServerLifecycleException(e); 98 } 99 } 100 101 109 public void onStartup() 110 throws ServerLifecycleException { 111 generateEntryContext(new Boolean (onDemandStartup)); 112 super.onStartup(); 113 } 114 115 121 public void onShutdown() 122 throws ServerLifecycleException { 123 super.onShutdown(); 124 try { 125 sg.stop(null); 126 } catch (Exception e) { 127 throw new ServerLifecycleException(e); 128 } 129 } 130 131 public void generateEntryContext(Object event) { 132 ServerEntryHelper.generateStartUpEntryContext((Boolean ) event); 133 } 134 135 protected ArrayList instantiateRuntimeServices() throws ServerLifecycleException { 136 if (onDemandStartup) { 137 InternalServicesList services = new TomcatServices(); 138 InternalServicesList ondemandservices = new OnDemandServices(); 139 String [][] servicesByName = services.getServicesByName(); 140 String [][] odsByName = ondemandservices.getServicesByName(); 141 if (servicesByName == null) { 142 _logger.log(Level.SEVERE, "services.null"); 143 throw new ServerLifecycleException(); 144 } 145 146 ArrayList serviceList = new ArrayList(); 147 148 allServices : 150 for (String [] service : servicesByName) { 151 for (String [] ods : odsByName) { 152 if (service[0].equals(ods[0])) { 153 continue allServices; 154 } 155 } 156 try { 157 Class c = java.lang.Class.forName(service[1]); 159 Object o = c.newInstance(); 160 serviceList.add(o); 161 } catch (Exception ex) { 162 _logger.log(Level.SEVERE, "server.exception", ex); 163 throw new ServerLifecycleException(ex.getMessage()); 164 } 165 } 166 return serviceList; 167 } else { 168 return super.instantiateRuntimeServices(); 169 } 170 } 171 172 public static ServerEntryListener getServerEntryListener() { 174 return listener; 175 } 176 177 public static SystemAppLoader getSystemAppLoader() { 179 return systemAppLoader; 180 } 181 182 public ServiceGroup getServiceGroup() { 184 return sg; 185 } 186 187 public static boolean isOnDemandOff() { 188 return onDemandStartup == false; 189 } 190 191 } 192 | Popular Tags |