1 23 24 package com.sun.enterprise.server.ondemand; 25 26 import java.util.Set ; 27 import java.util.logging.Logger ; 28 import java.util.logging.Level ; 29 import com.sun.enterprise.server.ondemand.entry.EntryContext; 30 import com.sun.enterprise.server.ondemand.entry.EntryPoint; 31 import com.sun.enterprise.server.ServerContext; 32 import com.sun.enterprise.server.ResourcesUtil; 33 import com.sun.enterprise.config.*; 34 import com.sun.enterprise.config.serverbeans.*; 35 import com.sun.enterprise.connectors.ConnectorRuntime; 36 import com.sun.enterprise.connectors.DeferredResourceConfig; 37 import com.sun.enterprise.deployment.*; 38 39 40 50 public class ResourcesServiceGroup extends ServiceGroup { 51 52 60 public void start(EntryContext context) 61 throws ServiceGroupException { 62 try { 63 65 startLifecycleServices(context.getServerContext()); 66 } catch (Exception e) { 68 throw new ServiceGroupException(e); 69 } 70 } 71 72 80 public boolean analyseEntryContext( EntryContext context ) { 81 82 if (_logger.isLoggable(Level.FINER)) { 83 _logger.log(Level.FINER, 84 "Analysing the context in Resources ServiceGroup :" + context); 85 } 86 87 if (context.get() == null) { 88 return false; 89 } 90 91 boolean result = false; 92 try { 93 ConfigContext ctxt = context.getServerContext().getConfigContext(); 94 Config conf = ServerBeansFactory.getConfigBean( ctxt ); 95 JmsService jmsService_ = conf.getJmsService(); 96 String defaultJmsHost = jmsService_.getDefaultJmsHost(); 97 JmsHost jmsHost_ = null; 98 boolean embedded = true; 99 100 if (defaultJmsHost==null || defaultJmsHost.equals("")) { 101 jmsHost_ = ServerBeansFactory.getJmsHostBean(ctxt); 102 } else { 103 jmsHost_ = jmsService_.getJmsHostByName(defaultJmsHost); 104 } 105 106 if (jmsHost_ == null || jmsService_.getType() == null || 107 ! jmsService_.getType().equalsIgnoreCase("embedded")) { 108 embedded = false; 109 } 110 111 if ( context.getEntryPointType() == EntryPoint.JNDI ) { 112 } 114 115 if ( context.getEntryPointType() == EntryPoint.STARTUP ) { 116 boolean onDemandStartup = ((Boolean ) context.get()).booleanValue(); 117 if (onDemandStartup == true && embedded == false) { 118 result = true; 119 } 120 } else if (embedded == false) { 121 return false; 122 } 123 124 if (context.getEntryPointType() == EntryPoint.APPLOADER ) { 125 String mqRA = ConnectorRuntime.DEFAULT_JMS_ADAPTER; 126 Descriptor desc = (Descriptor) context.get(); 127 if (desc instanceof Application) { 128 Application application = (Application) desc; 129 for (ConnectorDescriptor cd : (java.util.Set <ConnectorDescriptor>) 130 application.getRarDescriptors()) { 131 Application app = cd.getApplication(); 132 if (app !=null && mqRA.equals(app.getRegistrationName())) { 133 result = true; 134 } 135 } 136 } else if (desc instanceof ConnectorDescriptor ) { 137 ConnectorDescriptor cd = (ConnectorDescriptor) desc; 138 Application app = cd.getApplication(); 139 if (app != null && mqRA.equals(app.getRegistrationName())) { 140 result = true; 141 } 142 } 143 144 } 145 146 if ( context.getEntryPointType() == EntryPoint.PORT ) { 147 String portStr = jmsHost_.getPort(); 148 if (Integer.parseInt(portStr.trim()) == 149 ((Integer ) context.get()).intValue()) { 150 result = true; 151 } 152 } 153 } catch (Exception e) { 154 e.printStackTrace(); 155 result = false; 156 } 157 158 return result; 159 } 160 161 166 private void loadSystemApps() { 167 SystemAppLoader loader = OnDemandServer.getSystemAppLoader(); 168 loader.loadSystemApps(loader.getResourcesServiceGroupSystemApps()); 169 } 170 171 172 176 private void startLifecycleServices(ServerContext context) { 177 String [][] services = OnDemandServices.getResourcesServiceGroupServices(); 178 super.startLifecycleServices(services, context); 179 } 180 181 185 public void stop(EntryContext context) throws ServiceGroupException { 186 super.stopLifecycleServices(); 187 } 188 189 192 public void abort(EntryContext context) { 193 super.stopLifecycleServices(); 194 } 195 196 } 197 | Popular Tags |