FileDocCategorySizeDatePackage
ResourcesServiceGroup.javaAPI DocGlassfish v2 API8131Fri May 04 22:35:48 BST 2007com.sun.enterprise.server.ondemand

ResourcesServiceGroup

public class ResourcesServiceGroup extends ServiceGroup
Represents the group services needed by resources. The main components of this servicegroup JMS provider or MQ. Almost all the resources in Sun application server are lazily loaded anyway. So this service group just concentrates on SJSMQ.
author
Binod PG
see
ServiceGroup
see
ServiceGroupBuilder

Fields Summary
Constructors Summary
Methods Summary
public voidabort(com.sun.enterprise.server.ondemand.entry.EntryContext context)
Abort the servicegroup. This is not called from anywhere as of now.

        super.stopLifecycleServices();
    
public booleananalyseEntryContext(com.sun.enterprise.server.ondemand.entry.EntryContext context)
Analyse the entrycontext and specifies whether this servicegroup can be started or not.

return
boolean If true is returned, this servicegroup can be started If false is returned, the entrycontext is not recognized by the servicegroup.

        
        if (_logger.isLoggable(Level.FINER)) {
            _logger.log(Level.FINER, 
            "Analysing the context in Resources ServiceGroup :" + context);
        }

        if (context.get() == null) {
            return false;
        }

        if ( context.getEntryPointType() == EntryPoint.JNDI ) {
            // TODO. Move connectors lazy loading from naming to here.
            return false;
        }

        boolean result = false;
        try {
            ConfigContext ctxt = context.getServerContext().getConfigContext();
            Config conf = ServerBeansFactory.getConfigBean( ctxt );
            JmsService jmsService_ = conf.getJmsService();
            String defaultJmsHost = jmsService_.getDefaultJmsHost();
            JmsHost jmsHost_ = null;
            boolean embedded = true;

            if (defaultJmsHost==null || defaultJmsHost.equals("")) {
               jmsHost_ = ServerBeansFactory.getJmsHostBean(ctxt);
            } else {
               jmsHost_ = jmsService_.getJmsHostByName(defaultJmsHost);
            }

            if (jmsHost_ == null || jmsService_.getType() == null ||
                ! jmsService_.getType().equalsIgnoreCase("embedded")) {
                embedded = false;
            }

            if ( context.getEntryPointType() == EntryPoint.STARTUP ) {
                boolean onDemandStartup = ((Boolean) context.get()).booleanValue();
                if (onDemandStartup == true && embedded == false) {
                    result = true;
                }
            } else if (embedded == false) {
                return false;
            }

            if (context.getEntryPointType() == EntryPoint.APPLOADER ) {
                String mqRA = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
                Descriptor desc = (Descriptor) context.get();
                if (desc instanceof Application) {
                    Application application = (Application) desc;
                    for (ConnectorDescriptor cd : (java.util.Set<ConnectorDescriptor>) 
                         application.getRarDescriptors()) {
                         Application app = cd.getApplication();
                         if (app !=null && mqRA.equals(app.getRegistrationName())) {
                             result = true;
                         }
                    }
                } else if (desc instanceof ConnectorDescriptor ) { 
                    ConnectorDescriptor cd = (ConnectorDescriptor) desc;
                    Application app = cd.getApplication();
                    if (app != null && mqRA.equals(app.getRegistrationName())) {
                        result = true;
                    }
                }
                
            }

            if ( context.getEntryPointType() == EntryPoint.PORT ) {
                String portStr = jmsHost_.getPort();
                if (Integer.parseInt(portStr.trim()) == 
                   ((Integer) context.get()).intValue()) {
                   result = true;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = false;
        }

        return result;
    
private voidloadSystemApps()
Loads all the system apps belongs to this servicegroup.

see
OnDemandServices
see
SystemAppLoader

        SystemAppLoader loader = OnDemandServer.getSystemAppLoader();
        loader.loadSystemApps(loader.getResourcesServiceGroupSystemApps());
    
public voidstart(com.sun.enterprise.server.ondemand.entry.EntryContext context)
Triggers the start of the servicegroup. The entry context that caused this startup is used by the servicegroup to obtain any startup information it require.

param
context EntryContext object.
see
EntryContext.

        try {
            //loadSystemApps();

            startLifecycleServices(context.getServerContext());
            //(ConnectorRuntime.DEFAULT_JMS_ADAPTER);
        } catch (Exception e) {
            throw new ServiceGroupException(e);
        }
    
private voidstartLifecycleServices(com.sun.enterprise.server.ServerContext context)
Start lifecycles belonging to this service group.

see
OnDemandServices

        String[][] services = OnDemandServices.getResourcesServiceGroupServices();
        super.startLifecycleServices(services, context);
    
public voidstop(com.sun.enterprise.server.ondemand.entry.EntryContext context)
Stop the servicegroup. It stops all the lifecycle modules belongs to this servicegroup.

        super.stopLifecycleServices();