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.NestedModule; 14 import org.jfox.deployment.application.EARModule; 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 23 24 public class NestedEJBModule extends EJBModule implements NestedModule { 25 public static final String Target = "apps" + File.separator; 26 private EARModule earModule; 27 private EJBBundle ejbBundle; 28 29 public NestedEJBModule(EARModule earModule, File jarFile) throws DeployException { 30 super(jarFile); 31 this.earModule = earModule; 32 init(); 33 } 34 35 private void init() throws DeployException { 36 try { 37 ((J2EEClassLoader) getClassLoader()).addURL(getPackage().toURL()); 38 ejbBundle = new EJBBundle(XMLUtils.getDocument(getDescriptorURL())); 39 } 40 catch(Exception e) { 41 throw new DeployException(e); 42 } 43 } 44 45 public URL getDescriptorURL() { 46 try { 47 return new URLClassLoader (new URL []{getPackage().toURL()}, null).findResource("META-INF/ejb-jar.xml"); 51 } 53 catch(Exception e) { 54 return null; 55 } 56 } 57 58 public File getPackage() { 59 return super.getPackage(); 60 } 61 62 public URLClassLoader getClassLoader() { 63 return earModule.getClassLoader(); 64 } 65 66 public void deploy(Deployer deployer) throws DeployException { 67 super.deploy(deployer); 68 } 69 70 public File getTempDeployDirectory() { 71 return new File (earModule.getTempDeployDirectory(), Target); 72 } 73 74 public EARModule getEARModule() { 75 return earModule; 76 } 77 78 public EJBBundle getEJBBundle() { 79 return ejbBundle; 80 } 81 82 public static void main(String [] args) { 83 84 } 85 } 86 87 | Popular Tags |