FileDocCategorySizeDatePackage
EjbModulesManager.javaAPI DocGlassfish v2 API16852Fri Jul 27 04:50:36 BST 2007com.sun.enterprise.instance

EjbModulesManager

public class EjbModulesManager extends ModulesManager

Fields Summary
Constructors Summary
public EjbModulesManager(InstanceEnvironment env)

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

        super(env, useBackupServerXml);
        //FIXME: HACK START
	EjbModule[] jArray = ((Applications)configBean).getEjbModule();
	if(jArray!=null) {
            for(int i=0;i<jArray.length;i++) {
                jArray[i].setConfigContext(configContext);
		jArray[i].setXPath(ServerXPathHelper.getEjbModuleIdXpathExpression(jArray[i].getName()));
            }
	}
	//FIXME: HACK END
    
Methods Summary
public java.lang.StringgetDescription(java.lang.String modId)

        return getEjbModule(modId).getDescription();
    
public com.sun.enterprise.deployment.ApplicationgetDescriptor(java.lang.String moduleID, java.lang.ClassLoader parentClassLoader)
This method is called only by ResourcesUtil during server start up. We need to construct the application classloader before calling into other getDescriptor method to fully populate the application object.


        ClassLoader cl = new EJBClassLoader(parentClassLoader);
        String[] classPaths = (String[]) EJBClassPathUtils.getModuleClasspath(
                                moduleID, null, this).toArray(new String[0]);

        if (classPaths != null) {
            int classPathSize    = classPaths.length;
            for (int i=0; i<classPathSize; i++) {
                try {
                    ((EJBClassLoader) cl).appendURL(new File(classPaths[i]));
                } catch (IOException ioe) {
                    //@@ i18n
                    _logger.log(Level.WARNING, "Cannot convert path to URL: " + classPaths[i]);
                }
            }
        }

        return getDescriptor(moduleID, cl, false);
    
public com.sun.enterprise.deployment.ApplicationgetDescriptor(java.lang.String modId, java.lang.ClassLoader cl, java.lang.String loc, boolean validateXML)
Returns the deployment descriptor object for this ejb module.

param
modId ejb module id
param
cl ejb class loader
param
validateXml use validating parser when true
return
the deployment descriptor object for this ejb module
throws
ConfigException if unable to load the deployment descriptor

        
        return getDescriptor(modId, cl, validateXML);
    
public com.sun.enterprise.deployment.ApplicationgetDescriptor(java.lang.String modId, java.lang.ClassLoader cl, boolean validateXml)
Returns the deployment descriptor object for this ejb module. This method gets called when deployment backend is running verification during deployment.

param
modId ejb module id
param
cl ejb class loader
param
validateXml use validating parser when true
param
verify sets cmp mappings, doctype, etc when true
return
the deployment descriptor object for this ejb module
throws
ConfigException if unable to load the deployment descriptor


        Application application = getRegisteredDescriptor(modId);
        if (application!=null) {
            application.setClassLoader(cl);
            return application;
        }
        try {
            String moduleDir             = getLocation(modId);
	    EjbArchivist ejbArchivist = new EjbArchivist();
	    ejbArchivist.setXMLValidation(validateXml);

            // We need to use a temp CL until we are done with validate(),
            // see https://glassfish.dev.java.net/issues/show_bug.cgi?id=223
            ClassLoader tcl = (cl instanceof InstrumentableClassLoader) ?
                    InstrumentableClassLoader.class.cast(cl).copy() : cl;
            ejbArchivist.setClassLoader(tcl);

	    FileArchive archive = openDDArchive(modId, moduleDir);
            
            // 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, ejbArchivist, archive, true);
                if(!isSystemAdmin(modId) && !isSystem(modId)) {
                    // we need to read persistence descriptors separately
                    // because they are read from appDir as oppsed to xmlDir.
                    readPersistenceDeploymentDescriptors(moduleDir, application);
                }
            }

            // We need to use a temp CL until the end of this method...
            // see https://glassfish.dev.java.net/issues/show_bug.cgi?id=223
            application.setClassLoader(tcl);
            // set it in all the bundles as well,
            for (BundleDescriptor bd : (Collection<BundleDescriptor>)
                    application.getBundleDescriptors()) {
                bd.setClassLoader(tcl);
            }
            application.setGeneratedXMLDirectory(getGeneratedXMLLocation(modId));
            
            if (!application.getWebServiceDescriptors().isEmpty()) {
                ModuleContentLinker visitor = new ModuleContentLinker(archive, true);
                application.visit((com.sun.enterprise.deployment.util.ApplicationVisitor) visitor);
            }

            // Now, let's set the actual class loader
            application.setClassLoader(cl);
            // set it in all the bundles as well,
            for (BundleDescriptor bd : (Collection<BundleDescriptor>)
                    application.getBundleDescriptors()) {
                bd.setClassLoader(cl);
            }
            registerDescriptor(modId, application);

            // If needed, save this app in serialized form for faster loading next time.
            sdLoader.store(application);
            
            return application;
        } catch (ConfigException ce) {
            throw ce;
        } 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);
        }
    
private EjbModulegetEjbModule(java.lang.String modId)

        EjbModule mod = (EjbModule)
            ((Applications)this.configBean).getEjbModuleByName(modId);
        
        if(mod == null)
            throw new ConfigException(Localizer.getValue(ExceptionType.NO_SUCH_EJB_MOD));
        
        return mod;
        
    
public java.lang.StringgetGeneratedXMLLocation(java.lang.String name)

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

        EjbModule ejbModule = (EjbModule)
            ((Applications)this.configBean).getEjbModuleByName(name);
        String location = ejbModule.getLocation();
        return resolvePath(location);
    
public javax.enterprise.deploy.shared.ModuleTypegetModuleType()

return
the module type this class is managing

        return ModuleType.EJB;
    
public java.lang.StringgetStubLocation(java.lang.String name)

        ModuleEnvironment menv = instanceEnvironment.getModuleEnvironment(name,
                                                     DeployableObjectType.EJB); 
        return menv.getModuleStubPath();
    
public booleanisEnabled(java.lang.String modId)

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

        ConfigBean cb = null;
        try {
            cb = ((Applications)bean).getEjbModuleByName(appId);
        } catch(Exception cn) {
        }
        
        if(cb != null) return true;
        return false;
    
public booleanisShared(java.lang.String modId)

        //FIXME NYI
        return false; //getEjbModule(modId).isShared();
    
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-"

        EjbModule em =  getEjbModule(modId);
        String resourceType = em.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"

        EjbModule em =  getEjbModule(modId);
        String resourceType = em.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

        EjbModule em =  getEjbModule(modId);
        String resourceType = em.getObjectType();
        boolean isDirectoryDeployed = em.isDirectoryDeployed();
        if (resourceType.startsWith(SYSTEM_PREFIX) && isDirectoryDeployed) {
            return true;
        } else {
            return false;
        }
    
public EjbModule[]listEjbModules()
Returns an array of all ejb modules deployed with the server.

        EjbModule[] mods = ((Applications)this.configBean).getEjbModule();
        if(mods == null) return new EjbModule[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
        EjbModule[] refList = new EjbModule[list.size()];
        return ( (EjbModule[]) list.toArray(refList) );
    
public java.util.ListlistIds()
Returns a list of all ejb modules deployed with the server.

        ArrayList arr = new ArrayList();
        EjbModule[] mods = ((Applications)this.configBean).getEjbModule();
        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)

        removeEjbModule(modID);
    
private voidremoveEjbModule(java.lang.String modId)

        EjbModule backEm = (EjbModule)
            ((Applications)configBean).getEjbModuleByName(modId);
        ((Applications)configBean).removeEjbModule(backEm);
    
public voidsetDescription(java.lang.String modId, java.lang.String desc)

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

        getEjbModule(modId).setEnabled(enable);
    
public voidsetLocation(java.lang.String modId, java.lang.String location)
Set the location for an EJB Module

param
modId unique idenitifier for the ejb module
param
location full path String

        getEjbModule(modId).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) {
            EjbModule em = getEjbModule(modId);
            Enumeration tags = optionalAttributes.keys();
            while(tags.hasMoreElements())
            {
                String tag = (String)tags.nextElement();
                String value = optionalAttributes.getProperty(tag);
                em.setAttributeValue(tag, value);
            }
        }
    
public voidsetShared(java.lang.String modId, boolean shared)

         //FIXME NYI
        //getEjbModule(modId).setShared(shared);