FileDocCategorySizeDatePackage
ConnectorModulesManager.javaAPI DocGlassfish v2 API12807Fri May 04 22:35:00 BST 2007com.sun.enterprise.instance

ConnectorModulesManager

public class ConnectorModulesManager extends ModulesManager

Fields Summary
Constructors Summary
public ConnectorModulesManager(InstanceEnvironment env)

        super(env, true);
    
public ConnectorModulesManager(InstanceEnvironment env, boolean useBackupServerXml)

        super(env, useBackupServerXml);
        //FIXME: HACK START
	ConnectorModule[] jArray = ((Applications)configBean).getConnectorModule();
	if(jArray!=null) {
            for(int i=0;i<jArray.length;i++) {
                jArray[i].setConfigContext(configContext);
		jArray[i].setXPath(ServerXPathHelper.getConnectorModuleIdXpathExpression(jArray[i].getName()));
            }
	}
	//FIXME: HACK END

    
Methods Summary
private ConnectorModulegetConnectorModule(java.lang.String modId)

        ConnectorModule mod = (ConnectorModule)
            ((Applications)this.configBean).getConnectorModuleByName(modId);
        
        if(mod == null)
            throw new ConfigException(Localizer.getValue(ExceptionType.NO_SUCH_CON_MOD));
        
        return mod;
        
    
public java.lang.StringgetDescription(java.lang.String modId)

        return getConnectorModule(modId).getDescription();
    
public com.sun.enterprise.deployment.ApplicationgetDescriptor(java.lang.String modId, java.lang.ClassLoader cl, java.lang.String modDir, boolean validateXml)
Returns the deployment descriptor object for the connector module in the specified directory.

param
modId web module id
param
modDir The directory containing the web module
param
validateXml use validating parser when true
param
verify true indicates that verifier option is ON
return
the deployment descriptor object for this web module
throws
ConfigException if unable to load the deployment descriptor


        Application application = getRegisteredDescriptor(modId);
        if (application!=null) {
            application.setClassLoader(cl);
            return application;
        }                
        try {
	    ConnectorArchivist connectorArchivist = new ConnectorArchivist();
	    connectorArchivist.setXMLValidation(validateXml);
            connectorArchivist.setClassLoader(cl);
	    
            FileArchive archive = new FileArchive();
            archive.open(modDir);
            // Try to load the app from the serialized descriptor file.
            SerializedDescriptorHelper.Loader sdLoader = SerializedDescriptorHelper.load(modId, this);
            Application deserializedApplication = sdLoader.getApplication();
            if (deserializedApplication != null) {
                application = deserializedApplication;
            } else {
                application = ApplicationArchivist.openArchive(modId, connectorArchivist, archive, true);
            }
	    application.setClassLoader(cl);
            application.setGeneratedXMLDirectory(getGeneratedXMLLocation(modId));
            
            registerDescriptor(modId, application);
            
            // If needed, save this app in serialized form for faster loading next time.
            sdLoader.store(application);

            return application;
	    
        } catch (IOException ioe) {
            throw new ConfigException(Localizer.getValue(
                ExceptionType.IO_ERROR_LOADING_DD, modId), ioe);
        } catch (Throwable t) {
            throw new ConfigException(Localizer.getValue(
                ExceptionType.FAIL_DD_LOAD, modId), t);
        }
	
public java.lang.StringgetGeneratedXMLLocation(java.lang.String name)

        ModuleEnvironment menv = instanceEnvironment.getModuleEnvironment(name,
                                                     DeployableObjectType.CONN);        
        return menv.getModuleGeneratedXMLPath();
    
public java.lang.StringgetLocation(java.lang.String name)

        String location  = null;
        if (ResourcesUtil.createInstance().belongToSystemRar(name)) {
            location = Switch.getSwitch().
                       getResourceInstaller().getSystemModuleLocation(name);
        } else {
            ConnectorModule connectorModule = (ConnectorModule)
            ((Applications)this.configBean).getConnectorModuleByName(name);
            location = connectorModule.getLocation();
        }
        return resolvePath(location);
    
public javax.enterprise.deploy.shared.ModuleTypegetModuleType()

return
the module type this class is managing

        return ModuleType.RAR;
    
public booleanisEnabled(java.lang.String modId)

        return getConnectorModule(modId).isEnabled();
    
protected booleanisRegistered(java.lang.String modId, com.sun.enterprise.config.ConfigBean bean)

        ConfigBean cb = null;
        try {
            cb = ((Applications)bean).getConnectorModuleByName(modId);
        } catch(Exception cn) {
        }
        
        if(cb != null) return true;
        return false;
    
public booleanisSystem(java.lang.String modId)
Checks whether this module is a systemmodule ResourceType in domain.xml should start with "system-"

return
true if resourceType starts with "system-"

        ConnectorModule cm =  getConnectorModule(modId);
        String resourceType = cm.getObjectType();
        if(resourceType.startsWith(SYSTEM_PREFIX))
            return true;
        else
            return false;
    
public booleanisSystemAdmin(java.lang.String modId)
Checks whether this module is a system admin module ResourceType in domain.xml should start with "system-admin"

return
true if resourceType starts with "system-admin"

        ConnectorModule cm =  getConnectorModule(modId);
        String resourceType = cm.getObjectType();
        if(resourceType.startsWith(SYSTEM_ADMIN_PREFIX))
            return true;
        else
            return false;
    
public booleanisSystemPredeployed(java.lang.String modId)
Checks whether this module is a pre-deployed system module ResourceType in domain.xml should start with "system" Also it should be directory deployed.

return
true if its a predeployed system module

        ConnectorModule cm =  getConnectorModule(modId);
        String resourceType = cm.getObjectType();
        boolean isDirectoryDeployed = cm.isDirectoryDeployed();
        if (resourceType.startsWith(SYSTEM_PREFIX) && isDirectoryDeployed) {
            return true;
        } else {
            return false;
        }
    
public ConnectorModule[]listConnectorModules()
Returns a list of all Connector modules deployed with the server.

        ConnectorModule[] mods = ((Applications)this.configBean).getConnectorModule();
        if(mods == null) return new ConnectorModule[0];

        ArrayList list = new ArrayList();
        for (int i=0; i<mods.length; i++) {
            // add the modules to the list if it is referenced
            // by this server
            if ( isReferenced(mods[i].getName()) ) {
                list.add(mods[i]);
            }
        }
        // returns an array of modules referenced by this server
        ConnectorModule[] refList = new ConnectorModule[list.size()];
        return ( (ConnectorModule[]) list.toArray(refList) );
	
public java.util.ListlistIds()
Returns a list of all Connector modules deployed with the server.

        ArrayList arr = new ArrayList();
        ConnectorModule[] mods = ((Applications)this.configBean).getConnectorModule();
        if(mods == null) return arr;
        for (int i=0;i<mods.length;i++) {          
            String name = mods[i].getName();
            // adds the web module to the list if 
            // it is referenced by this server 
            if ( isReferenced(name) ) {
                arr.add(name);
            }            
        }
        return arr;
    
public voidremove(java.lang.String modId)

        ConnectorModule backEm = (ConnectorModule)((Applications)configBean).getConnectorModuleByName(modId);
        ((Applications)configBean).removeConnectorModule(backEm);
    
public voidsetDescription(java.lang.String modId, java.lang.String desc)

        getConnectorModule(modId).setDescription(desc);
    
public voidsetEnable(java.lang.String modId, boolean enable)

        getConnectorModule(modId).setEnabled(enable);
    
public voidsetLocation(java.lang.String modId, java.lang.String location)

        ConnectorModule connectorModule = (ConnectorModule)
        ((Applications)this.configBean).getConnectorModuleByName(modId);
        connectorModule.setLocation(location);
    
public voidsetOptionalAttributes(java.lang.String modId, java.util.Properties optionalAttributes)
Set the optional attributes for an module

param
modId unique idenitifier for the module
param
optionalAttributes - pairs tag/value to set

        if(optionalAttributes!=null) {
            ConnectorModule cm = getConnectorModule(modId);
            Enumeration tags = optionalAttributes.keys();
            while(tags.hasMoreElements())
            {
                String tag = (String)tags.nextElement();
                String value = optionalAttributes.getProperty(tag);
                cm.setAttributeValue(tag, value);
            }
        }