FileDocCategorySizeDatePackage
EjbArchivist.javaAPI DocGlassfish v2 API10288Fri May 04 22:31:36 BST 2007com.sun.enterprise.deployment.archivist

EjbArchivist

public class EjbArchivist extends Archivist
This class is responsible for handling J2EE EJB Bundlearchive files.
author
Jerome Dochez
version

Fields Summary
com.sun.enterprise.deployment.EjbBundleDescriptor
descriptor
com.sun.enterprise.deployment.io.DeploymentDescriptorFile
standardDD
The DeploymentDescriptorFile handlers we are delegating for XML i/o
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
Constructors Summary
public EjbArchivist()
Creates new EjbBundleArchvisit

        
    
        
      
    
Methods Summary
protected java.lang.StringgetArchiveExtension()

        return EJB_EXTENSION;
    
public com.sun.enterprise.deployment.io.DeploymentDescriptorFilegetConfigurationDDFile()

return
if exists the DeploymentDescriptorFile responsible for handling the configuration deployment descriptors

        return new EjbRuntimeDDFile();
    
public com.sun.enterprise.deployment.DescriptorgetDefaultBundleDescriptor()

return
a default BundleDescriptor for this archivist

        EjbBundleDescriptor ejbBundleDesc =
            new EjbBundleDescriptor();
        return ejbBundleDesc;
    
public com.sun.enterprise.deployment.DescriptorgetDescriptor()

return
the Descriptor for this archvist

        return descriptor;
    
public javax.enterprise.deploy.shared.ModuleTypegetModuleType()

return
the module type handled by this archivist as defined in the application DTD

        return ModuleType.EJB;
    
public com.sun.enterprise.deployment.io.DeploymentDescriptorFilegetStandardDDFile()

return
the DeploymentDescriptorFile responsible for handling standard deployment descriptor

        return standardDD;
    
public java.lang.StringgetWebServicesDeploymentDescriptorPath()

return
the location of the web services related deployment descriptor file inside this archive or null if this archive does not support webservices implementation.

        return DescriptorConstants.EJB_WEBSERVICES_JAR_ENTRY;
    
protected booleanpostHandles(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive)

        EjbComponentAnnotationDetector detector = 
                    new EjbComponentAnnotationDetector();
        return detector.hasAnnotationInArchive(abstractArchive);
    
protected voidpostOpen(com.sun.enterprise.deployment.RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)
perform any post deployment descriptor reading action

param
descriptor deployment descriptor for the module
param
archive the module archive

        super.postOpen(descriptor, archive);
        EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) descriptor;
        ModuleContentValidator mdv = new ModuleContentValidator(archive);
        ejbBundle.visit((EjbBundleVisitor)mdv);
    
protected voidprepareForInclusion(com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
prepare an archivist for inclusion in a application archive.

param
out file where this archivist will be saved

        
	// store the ejbJar by its hort filename        
        String ejbClientJarUri = descriptor.getEjbClientJarUri();

        // If this ejb-jar has an ejb client jar, the ejb client jar URI
        // is relative to the directory in which the ejb-jar lives.
        if( !ejbClientJarUri.equals("") ) {
            String ejbClientJarPath = 
                ejbClientJarUri.replace(FileUtil.JAR_SEPARATOR_CHAR, File.separatorChar);
                
            File ejbJarFile = new File(path);
            File ejbClientJar = new File(ejbJarFile.getParentFile(), ejbClientJarPath);
            if( ejbClientJar.exists() ) {
                // Pull the ejb-client-jar into the .ear and set the
                // ejb-jar manifest classpath to point to it(relative
                // to the base of the .ear)
                addFileToArchive(out, ejbClientJar.getAbsolutePath(), ejbClientJarUri);
                String classPath = getClassPath();
                if (classPath==null) {
                    classPath=ejbClientJarUri;
                } else {
                    classPath+=" " + ejbClientJarUri;
                }
                setClassPath(classPath);
            } else {
               throw new FileNotFoundException(localStrings.getLocalString("enterprise.deployment.noclientjarentry", "Warning: {0} not found as a client jar entry.", new Object[] {ejbClientJar.toString()}));
            }
        }        
    
public voidreadPersistenceDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, com.sun.enterprise.deployment.Descriptor descriptor)

        if(logger.isLoggable(Level.FINE)) {
            logger.logp(Level.FINE, "EjbArchivist",
                    "readPersistenceDeploymentDescriptors", "archive = {0}",
                    archive.getURI());
        }
        // note we pass "" as the PURootPath because META-INF/persistence.xml
        // can only be present on the top level in an ejb-jar, so the root of
        // persistence unit is always same as the root of an ejb-jar file.
        // hence relative distance between them is empty.
        readPersistenceDeploymentDescriptor(archive, "", descriptor);
    
public voidsetDescriptor(com.sun.enterprise.deployment.Descriptor descriptor)
Set the DOL descriptor for this Archivist, used by super classes

        if (descriptor instanceof EjbBundleDescriptor) {
            this.descriptor = (EjbBundleDescriptor) descriptor;
        } else {
            if (descriptor instanceof Application) {
                // this is acceptable if the application actually represents 
                // a standalone module
                Set ejbBundles = ((Application) descriptor).getEjbBundleDescriptors();
                if (ejbBundles.size()>0) {
                    this.descriptor = (EjbBundleDescriptor) ejbBundles.iterator().next();
                    if (this.descriptor.getModuleDescriptor().isStandalone()) 
                        return;
                    else 
                        this.descriptor=null;
                }      
            }
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.descriptorFailure", new Object[] {this});
            throw new RuntimeException("Error setting descriptor " + descriptor + " in " + this);
        }
    
public voidvalidate(java.lang.ClassLoader aClassLoader)
validates the DOL Objects associated with this archivist, usually it requires that a class loader being set on this archivist or passed as a parameter

        ClassLoader cl = aClassLoader;
        if (cl==null) {
            cl = classLoader;
        }
        if (cl==null) {
            return;
        }
        descriptor.setClassLoader(cl);
        descriptor.visit((EjbBundleVisitor) new EjbBundleValidator());