1 6 package org.jfox.deployment.ejb; 7 8 import java.io.File ; 9 import java.net.URL ; 10 import java.net.URLClassLoader ; 11 12 import org.jfox.deployment.J2EEClassLoader; 13 import org.jfox.deployment.J2EEDeployMonitor; 14 import org.jfox.deployment.J2EEModule; 15 import org.jfox.ejb.meta.EJBBundle; 16 import org.jfox.ioc.deploy.DeployException; 17 import org.jfox.ioc.deployment.Deployer; 18 import org.jfox.ioc.util.XMLUtils; 19 20 25 26 public class EJBModule extends J2EEModule { 27 private String baseDeployDirectory = J2EEDeployMonitor.getDeploymentDir(); 28 private File jarFile; 29 30 private J2EEClassLoader loader = null; 31 32 private EJBBundle ejbBundle; 33 34 public EJBModule(File jarFile) throws DeployException { 35 this.jarFile = jarFile; 36 init(); 37 } 38 39 private void init() throws DeployException { 40 try { 41 this.loader = new J2EEClassLoader(new URL []{jarFile.toURL()}, this.getClass().getClassLoader()); 42 ejbBundle = new EJBBundle(XMLUtils.getDocument(getDescriptorURL())); 43 } 44 catch(Exception e) { 45 throw new DeployException(e); 46 } 47 48 } 49 50 public URL getDescriptorURL() { 51 return loader.findResource("META-INF/ejb-jar.xml"); 52 } 53 54 public File getPackage() { 55 return jarFile; 56 } 57 58 public URLClassLoader getClassLoader() { 59 return loader; 60 } 61 62 public void deploy(Deployer deployer) throws DeployException { 63 deployer.deploy(this); 64 } 65 66 public File getTempDeployDirectory() { 67 File dir = new File (baseDeployDirectory); 68 if(!dir.exists()) { 69 dir.mkdirs(); 70 } 71 return dir; 72 } 73 74 public EJBBundle getEJBBundle() { 75 return ejbBundle; 76 } 77 78 public static void main(String [] args) { 79 80 } 81 } 82 83 | Popular Tags |