FileDocCategorySizeDatePackage
AppclientJWSSupportManager.javaAPI DocGlassfish v2 API9636Fri May 04 22:34:12 BST 2007com.sun.enterprise.appclient.jws

AppclientJWSSupportManager

public class AppclientJWSSupportManager extends Object implements com.sun.enterprise.server.event.ApplicationLoaderEventListener, com.sun.enterprise.server.event.ApplicationClientLoaderEventListener
Singleton that keeps the AppclientJWSSupportInfo up-to-date as applications and app clients are loaded and unloaded and as the administrator enables and disables Java Web Start access to them.
author
tjquinn

Fields Summary
private static Logger
_logger
private static AppclientJWSSupportManager
instance
the singleton instance
private AppclientJWSSupportInfo
jwsInfo
the data structure shared with the system web app
private static final String
JWS_FEATURE_ON_PROPERTY_NAME
system property name used to turn off JWS feature
private final boolean
isJWSFeatureOn
indicates if JWS handling is turned on or off via property
Constructors Summary
private AppclientJWSSupportManager()
Creates a new instance of AppclientJWSSupportManager

        /**
         *If the JWS feature is turned on (the default), register this object
         *as a listener for app loader and app client loader events.
         */
        if (isJWSFeatureOn) {
            ApplicationLoaderEventNotifier.getInstance().addListener((ApplicationLoaderEventListener) this);
            ApplicationLoaderEventNotifier.getInstance().addListener((ApplicationClientLoaderEventListener) this);
        } else {
            _logger.info("Java Web Start support turned off by " + JWS_FEATURE_ON_PROPERTY_NAME);
        }
    
Methods Summary
public static synchronized com.sun.enterprise.appclient.jws.AppclientJWSSupportManagergetInstance()
Returns the singleton instance.

return
the instance of the manager

    
                 
         
        if (instance == null) {
            instance = new AppclientJWSSupportManager();
            if (instance.isJWSFeatureOn) {
                try {
                    /*
                     *Obtain the data structure object.
                     */
                    instance.jwsInfo = AppclientJWSSupportInfo.getInstance();
                } catch (IOException ioe) {
                    _logger.log(Level.SEVERE, "Error initializing Java Web Start support information", ioe);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
        return instance;
    
public voidhandleApplicationClientEvent(com.sun.enterprise.server.event.ApplicationClientEvent event)
Responds to app client events broadcast by the instance.

param
the event describing what has happened

        /*
         *Respond to after-load or before-unload events.
         */
        int eventType = event.getEventType();
        if ((eventType == event.BEFORE_APPLICATION_CLIENT_LOAD) ||
            (eventType == event.AFTER_APPLICATION_CLIENT_UNLOAD) ) {
            return;
        }
        
        /*
         *Find out if this app client is eligible for Java Web Start access.
         */
        Application app = event.getApplication();
        
        /*
         *The Application object wraps the app client, so there should be only
         *a single nested module (at most) representing the app client itself.
         */
        ModuleDescriptor [] mds = NamingConventions.getEligibleAppclientModuleDescriptors(app);
        
        if (mds.length > 1) {
            _logger.warning("During app client loading, expected exactly one app client module in the wrapping application but found more; using the first one and ignoring the others");
        } else if (mds.length == 0) {
            _logger.warning("During app client loading, expected exactly one app client module in the wrapping application but found none; ignoring this app client and continuing");
            return;
        }
        
        try {
            if (eventType == event.AFTER_APPLICATION_CLIENT_LOAD) {
                jwsInfo.startJWSServicesForAppclient(app, mds[0], event.getConfigContext());
            } else if (eventType == event.BEFORE_APPLICATION_CLIENT_UNLOAD) {
                jwsInfo.endJWSServicesForAppclient(app, mds[0], event.getConfigContext());
            }
        } catch (Throwable thr) {
            _logger.log(Level.SEVERE, "Error updating Java Web Start information for app client " + app.getRegistrationName(), thr);
        }
    
public voidhandleApplicationEvent(com.sun.enterprise.server.event.ApplicationEvent event)
Responds to an application-related event broadcast by the instance.

param
the ApplicationEvent describing what has happened

        /*
         *Respond to after-load or before-unload events.
         */
        int eventType = event.getEventType();
        if ((eventType == event.BEFORE_APPLICATION_LOAD) ||
            (eventType == event.AFTER_APPLICATION_UNLOAD) ) {
            return;
        }
        
        /*
         *Get the module descriptors (if any) for eligible nested app clients.
         *If there are any, start Java Web Start services for this app and
         *those eligible app clients.
         */
        Application app = event.getApplication();
        ModuleDescriptor [] mds = NamingConventions.getEligibleAppclientModuleDescriptors(app);
        if (mds.length > 0) {
            try {
                if (eventType == event.AFTER_APPLICATION_LOAD) {
                    jwsInfo.startJWSServicesForApplication(app, mds, event.getConfigContext());
                } else if (eventType == event.BEFORE_APPLICATION_UNLOAD) {
                    jwsInfo.endJWSServicesForApplication(app, mds, event.getConfigContext());
                }
            } catch (Throwable thr) {
                _logger.log(Level.SEVERE, "Error updating Java Web Start information for application " + app.getRegistrationName(), thr);
            }            
        }

    
public voidhandleEjbContainerEvent(com.sun.enterprise.server.event.EjbContainerEvent ejbContainerEvent)
No-op implementation needed to conform to the interface.

    
public voidstartJWSServicesForDeployedAppclients()
Register all deployed appclients with JWS service. This will be called by OnDemand initialization framework, when webcontainer starts.

         jwsInfo.startJWSServicesForDeployedAppclients();