1 19 package org.netbeans.modules.j2ee.api.ejbjar; 20 21 import org.netbeans.modules.j2ee.ejbjar.EarAccessor; 22 import org.netbeans.modules.j2ee.spi.ejbjar.EarImplementation; 23 import org.netbeans.modules.j2ee.spi.ejbjar.EarProvider; 24 import org.netbeans.modules.j2ee.spi.ejbjar.EarProvider; 25 import org.netbeans.modules.web.api.webmodule.WebModule; 26 import org.openide.filesystems.FileObject; 27 import org.openide.util.Lookup; 28 29 43 public final class Ear { 44 45 private final EarImplementation impl; 46 private static final Lookup.Result<EarProvider> implementations = 47 Lookup.getDefault().lookup(new Lookup.Template<EarProvider>(EarProvider.class)); 48 49 static { 50 EarAccessor.DEFAULT = new EarAccessor() { 51 public Ear createEar(EarImplementation spiEar) { 52 return new Ear(spiEar); 53 } 54 55 public EarImplementation getEarImplementation(Ear wm) { 56 return wm == null ? null : wm.impl; 57 } 58 }; 59 } 60 61 private Ear (EarImplementation impl) { 62 if (impl == null) 63 throw new IllegalArgumentException (); 64 this.impl = impl; 65 } 66 67 71 public static Ear getEar (FileObject f) { 72 if (f == null) { 73 throw new NullPointerException ("Passed null to Ear.getEar(FileObject)"); } 75 for (EarProvider earProvider : implementations.allInstances()) { 76 Ear wm = earProvider.findEar(f); 77 if (wm != null) { 78 return wm; 79 } 80 } 81 return null; 82 } 83 84 85 89 public String getJ2eePlatformVersion () { 90 return impl.getJ2eePlatformVersion(); 91 } 92 93 95 public FileObject getDeploymentDescriptor () { 96 return impl.getDeploymentDescriptor(); 97 } 98 99 102 public void addWebModule (WebModule module) { 103 impl.addWebModule (module); 104 } 105 106 109 public void addEjbJarModule (EjbJar module) { 110 impl.addEjbJarModule (module); 111 } 112 113 116 public void addCarModule(Car module) { 117 impl.addCarModule(module); 118 } 119 120 } 121 | Popular Tags |