FileDocCategorySizeDatePackage
ConnectorModuleLoader.javaAPI DocGlassfish v2 API10519Fri May 04 22:35:40 BST 2007com.sun.enterprise.server

ConnectorModuleLoader

public class ConnectorModuleLoader extends AbstractLoader
Connector loader loads and unloads stand alone connector module.
author
Orit Flint
since
JDK1.4

Fields Summary
static Logger
_logger
private com.sun.enterprise.deployment.ConnectorDescriptor
connectorDescriptor
Constructors Summary
ConnectorModuleLoader(String modID, ClassLoader parentClassLoader, com.sun.enterprise.instance.ConnectorModulesManager connModulesManager)
ConnectorModuleLoader loads one connector module.

param
modID the name of the connector module
param
parentClassLoader the parent class loader
param
connModulesManager the connector module mgr for this VS


                                                    
       
          

            super(modID,parentClassLoader,connModulesManager);
            // set connector descriptor for subsequent use
            setConnectorDescriptor(modID);
    
Methods Summary
voidcreateLeafMBean(com.sun.enterprise.deployment.Descriptor descriptor)
Create jsr77 resource adapter mebans which are contained within this connector module

        ConnectorDescriptor cd = null;
        try {
            cd = (ConnectorDescriptor) descriptor;
        } catch (Exception e) {
            throw new MBeanException(e);
        }
        Switch.getSwitch().getManagementObjectManager().createRARMBean(cd,
            this.configManager.getInstanceEnvironment().getName());
    
voidcreateLeafMBeans()
Create jsr77 resource adapter mebans which are contained within this connector module

        Switch.getSwitch().getManagementObjectManager().createRARMBeans(connectorDescriptor,
            this.configManager.getInstanceEnvironment().getName());
    
voidcreateRootMBean()
Create jsr77 root mBean


	try {
            Switch.getSwitch().getManagementObjectManager().createRARModuleMBean(
		connectorDescriptor,
            	this.configManager.getInstanceEnvironment().getName(),
		this.configManager.getLocation(this.id));
	} catch (Exception e) {
	    throw new MBeanException(e);
	}
    
voiddeleteLeafAndRootMBeans()
Delete jsr77 mBeans for the module and its' components

        deleteLeafMBeans();
        deleteRootMBean();
    
voiddeleteLeafMBean(com.sun.enterprise.deployment.Descriptor descriptor)
Delete jsr77 resource adapter mebans which are contained within this connector module

        ConnectorDescriptor cd = null;
        try {
            cd = (ConnectorDescriptor) descriptor;
        } catch (Exception e) {
            throw new MBeanException(e);
        }
        Switch.getSwitch().getManagementObjectManager().deleteRARMBean(cd,
            this.configManager.getInstanceEnvironment().getName());
    
voiddeleteLeafMBeans()
Delete jsr77 resource adapter mebans which are contained within this connector module

        Switch.getSwitch().getManagementObjectManager().deleteRARMBeans(connectorDescriptor, 
            this.configManager.getInstanceEnvironment().getName());
    
voiddeleteRootMBean()
Delete jsr77 root mBean


        Switch.getSwitch().getManagementObjectManager().deleteRARModuleMBean(connectorDescriptor,
            this.configManager.getInstanceEnvironment().getName());
    
booleandoLoad(boolean jsr77)
Loads stand alone connector module.

param
jsr77 create jsr77 mBeans if true
return
true if the connector loaded properly

	//Note: Application.isVirtual will be true for stand-alone module
	notifyAppEvent(ApplicationEvent.BEFORE_APPLICATION_LOAD);

        if (load()) {
            try {
                createLeafMBeans();
            } catch (MBeanException mbe) {
                _logger.log(Level.WARNING,"loader.exception",mbe);
            }
            return true;
        }
        return false;
    
public com.sun.enterprise.deployment.ConnectorDescriptorgetConnectorDescriptor()
Returns connector descriptor for this module

        return connectorDescriptor;
    
booleanload()
Loads stand alone connector module.

return
true if the connector loaded properly

        try{
           ConnectorRuntime cr = ConnectorRuntime.getRuntime();
           cr.initialize(ConnectorRuntime.SERVER);
           cr.createActiveResourceAdapter(this.configManager.getLocation(this.id),this.id);
           return true;
        }catch(ConfigException e){
            _logger.log(Level.WARNING,"loader.configexception",e);
            return false;
        }
        catch(ConnectorRuntimeException ex) {
            _logger.log(Level.WARNING,"Failed to load the rar",ex);

            return false;

        }
    
private voidsetConnectorDescriptor(java.lang.String modID)
Create connector descriptor and store in local variable for subsequent use by jsr77 and connector code.

        try {
            // hack for setting stand-alone attribute
            // this needs to be fixed in connectorArchivist
            // remove this code once it is fixed in connectorArchivist
            // hack-start
	    this.application = configManager.getDescriptor(modID, null, false);	    
            connectorDescriptor = (ConnectorDescriptor) application.getStandaloneBundleDescriptor();
            // hack-end
        } catch(ConfigException ex) {
            _logger.log(Level.WARNING,"Failed to get the module directory ");
        }
    
voidsetState(int state)
Set the state for the rootMBean


        Switch.getSwitch().getManagementObjectManager().setRARModuleState(state, connectorDescriptor,
            this.configManager.getInstanceEnvironment().getName());

    
booleanunload()
Unloads stand alone connector module.

return
true if removed successful

           ConnectorRuntime connectorRuntime = ConnectorRuntime.getRuntime();
           try {
               connectorRuntime.destroyActiveResourceAdapter(this.id,cascade);
               configManager.unregisterDescriptor(id);
           } 
           catch(ConnectorRuntimeException cre) {
              return false;
           }
           return true;
    
booleanunload(boolean jsr77)
Unloads stand alone connector module.

param
jsr77 delete jsr77 mBeans if true
return
true if removed successful

        if (unload()) {
            try {
                deleteLeafMBeans();
            } catch (MBeanException mbe) {
                _logger.log(Level.WARNING,"loader.exception",mbe);
            }
            return true;
        }
        return false;