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

WebServiceGroup

public class WebServiceGroup extends ServiceGroup
Represents the group services needed by web apps. The main components of this servicegroup Webcontainer and admin apps.
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 Web ServiceGroup :" + context);
        }

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

        if ( context.getEntryPointType() == EntryPoint.JNDI ) {
            /*
            no.op. You cant access this servicegroup via JNDI.
            */
            return false;
        }

        boolean result = false;
        try {
            ConfigContext ctxt = context.getServerContext().getConfigContext();
            Config conf = ServerBeansFactory.getConfigBean( ctxt );

            if (context.getEntryPointType() == EntryPoint.APPLOADER ) {
                Descriptor desc = (Descriptor) context.get();
                if (desc instanceof Application) {
                    // has atleast one webcomponent or 
                    // Atleast one component has webservice       
                    result = !((Application) desc).getWebBundleDescriptors().isEmpty() || 
                             !((Application) desc).getWebServiceDescriptors().isEmpty(); 
                } else if (desc instanceof EjbBundleDescriptor) {
                    result = ((EjbBundleDescriptor) desc).hasWebServices();
                } else if (desc instanceof EjbAbstractDescriptor) {
                    result = ((EjbAbstractDescriptor) desc).hasWebServiceEndpointInterface();
                } else {
                    result = desc instanceof WebBundleDescriptor || 
                             desc instanceof WebServicesDescriptor;
                } 
            }

            if ( context.getEntryPointType() == EntryPoint.PORT ) {
  	        // Start HTTP listener ports
	        HttpService httpService = conf.getHttpService();
	        HttpListener[] httpListeners = httpService.getHttpListener();
	        for ( int i=0; i<httpListeners.length; i++ ) {
	            int port = Integer.parseInt(httpListeners[i].getPort());
                    if (port == ((Integer) context.get()).intValue() ) {
                        result = true;
                    }
                }
	    }

            if (context.getEntryPointType() == EntryPoint.MBEAN) {
                result = analyseObjectName((ObjectName) context.get());
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = false;
        }

        return result;
    
private booleananalyseObjectName(javax.management.ObjectName name)


        /*
        if (name == null) {
            return true;
        }

        String cat = name.getKeyProperty("category");
        if (cat != null && cat.equals("monitor")) {
            return true;
        }
        */

        String type = name.getKeyProperty("type");
        if ((type != null) && type.equals("Loader")) {
             return true;
        }

        String j2eeType = name.getKeyProperty("j2eeType");
        if ((j2eeType != null) && 
             j2eeType.equals("WebModule")) {
             return true;
        }

        if (name.getKeyProperty("WebModule") != null) {
            return true;
        }

        String nameStr = name.getKeyProperty("name");
        String ref = name.getKeyProperty("ref");
        String app = name.getKeyProperty("J2EEApplication");

        return    belongsToThisServiceGroup(nameStr) || 
                  belongsToThisServiceGroup(ref) || 
                  belongsToThisServiceGroup(app); 


    
private booleanbelongsToThisServiceGroup(java.lang.String name)

      SystemAppLoader appLoader = OnDemandServer.getSystemAppLoader();
        if (appLoader != null) {
            for (Object n : appLoader.getWebServiceGroupSystemApps()) {
                if (((String) n).equals(name)) {
                    return true;
                }
            }
        }
        return false;
    
private voidloadSystemApps()
Loads all the system apps belongs to this servicegroup.

see
OnDemandServices
see
SystemAppLoader

        SystemAppLoader loader = OnDemandServer.getSystemAppLoader();
        loader.loadSystemApps(loader.getWebServiceGroupSystemApps());
    
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 {
            startLifecycleServices(context.getServerContext());
            loadSystemApps();
            AppclientJWSSupportManager.getInstance().
            startJWSServicesForDeployedAppclients();
            setState(ServiceGroup.STARTED);
        } 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.getWebServiceGroupServices();
        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();