FileDocCategorySizeDatePackage
EjbModule.javaAPI DocGlassfish v2 API5504Fri May 04 22:34:30 BST 2007com.sun.enterprise.ddgenerator.sun

EjbModule

public class EjbModule extends Object implements DDGenerator
Class description
author
Sreenivas Munnangi

Fields Summary
private EjbBundleDescriptor
ejbBundleDescriptor
private String
applicationDirectory
Constructors Summary
public EjbModule()


       
    
public EjbModule(EjbBundleDescriptor ejbBundleDescriptor, String applicationDirectory)

	this.ejbBundleDescriptor = ejbBundleDescriptor;
	this.applicationDirectory = applicationDirectory;
    
Methods Summary
public voidbackupSunDescriptor()


	File file = getSunDescriptorFile();

	if (file == null) return;

	if (file.exists()) {
	    try {
		FileUtils.copy(file, new File(file.getAbsolutePath() + ".bak"));
	    } catch (java.io.IOException ioe) {
	    }
	}

    
public voidgenerate()

	if (ejbBundleDescriptor == null) return;

	java.util.Set ejbDescriptors = ejbBundleDescriptor.getEjbs();

	for (Iterator it = ejbDescriptors.iterator(); it.hasNext();) {
		EjbDescriptor ejbDescriptor = (EjbDescriptor) it.next();
		String jndiName = ejbDescriptor.getJndiName();
		if ((jndiName == null) || (jndiName.length() <1)) {
			String homeName = ejbDescriptor.getHomeClassName();
			ejbDescriptor.setJndiName(homeName);
		}
	}

    
private java.io.FilegetSunDescriptorFile()

	
	File file = null;

	String archiveUri = ejbBundleDescriptor.getModuleDescriptor().getArchiveUri();

	String friendlyFileName = FileUtils.makeFriendlyFilename(archiveUri);

	String sunXmlFileName = (applicationDirectory + File.separator + 
				 friendlyFileName + File.separator + 
				 com.sun.enterprise.deployment.io.DescriptorConstants.S1AS_EJB_DD_ENTRY);

	file = new File(sunXmlFileName);

	return file;
    
public booleanhasSunDescriptor()

	
	File file = getSunDescriptorFile();

	if (file == null) return false;

	if (file.exists()) {
		return true;
	} 

	return false;
    
public static voidmain(java.lang.String[] args)


        System.out.println("Ejb");

	String appDir = "/home/sreeni/TEMP/stateless-converterEjb_1";

        System.out.println("Press enter to continue ...");
	try {
		System.in.read();
	} catch (java.io.IOException ioe) {
	}

	FileArchive in = new FileArchive();

	try {
		in.open(appDir);
	} catch (java.io.IOException ioe) {
	}


	EjbArchivist ejbArchivist = new EjbArchivist();
	ejbArchivist.setXMLValidation(false);
	ejbArchivist.setClassLoader(null);

	com.sun.enterprise.deployment.Application application = null;
	try {
		application = (com.sun.enterprise.deployment.Application)
			ApplicationArchivist.openArchive(ejbArchivist, in, true);
	} catch (java.io.IOException ioe) {
	} catch (org.xml.sax.SAXParseException saxpe) {
	}

	com.sun.enterprise.ddgenerator.sun.Application app = 
		new com.sun.enterprise.ddgenerator.sun.Application(application, appDir); 

	app.generate();
    
public voidsetApplicationDirectory(java.lang.String applicationDirectory)

	this.applicationDirectory = applicationDirectory;
    
public voidsetDescriptor(com.sun.enterprise.deployment.Descriptor descriptor)

	this.ejbBundleDescriptor = (com.sun.enterprise.deployment.EjbBundleDescriptor) descriptor;