1 19 package org.netbeans.modules.j2ee.api.ejbjar; 20 21 import java.util.Iterator ; 22 import org.netbeans.api.project.Project; 23 import org.netbeans.modules.j2ee.ejbjar.EjbJarAccessor; 24 import org.netbeans.modules.j2ee.metadata.MetadataUnit; 25 import org.netbeans.modules.j2ee.spi.ejbjar.*; 26 import org.netbeans.modules.j2ee.spi.ejbjar.EjbJarProvider; 27 import org.openide.filesystems.FileObject; 28 import org.openide.util.Lookup; 29 30 43 public final class EjbJar { 44 45 private EjbJarImplementation impl; 46 private static final Lookup.Result<EjbJarProvider> implementations = 47 Lookup.getDefault().lookup(new Lookup.Template<EjbJarProvider>(EjbJarProvider.class)); 48 49 static { 50 EjbJarAccessor.DEFAULT = new EjbJarAccessor() { 51 public EjbJar createEjbJar(EjbJarImplementation spiEjbJar) { 52 return new EjbJar(spiEjbJar); 53 } 54 55 public EjbJarImplementation getEjbJarImplementation(EjbJar wm) { 56 return wm == null ? null : wm.impl; 57 } 58 }; 59 } 60 61 private EjbJar (EjbJarImplementation impl) { 62 if (impl == null) 63 throw new IllegalArgumentException (); 64 this.impl = impl; 65 } 66 67 70 public static EjbJar getEjbJar (FileObject f) { 71 if (f == null) { 72 throw new NullPointerException ("Passed null to EjbJar.getEjbJar(FileObject)"); } 74 for (EjbJarProvider impl : implementations.allInstances()) { 75 EjbJar wm = impl.findEjbJar (f); 76 if (wm != null) { 77 return wm; 78 } 79 } 80 return null; 81 } 82 83 86 public static EjbJar [] getEjbJars (Project project) { 87 EjbJarsInProject providers = project.getLookup().lookup(EjbJarsInProject.class); 88 if (providers != null) { 89 EjbJar jars [] = providers.getEjbJars(); 90 if (jars != null) { 91 return jars; 92 } 93 } 94 return new EjbJar[] {}; 95 } 96 97 101 public String getJ2eePlatformVersion () { 102 return impl.getJ2eePlatformVersion(); 103 } 104 105 110 public FileObject getDeploymentDescriptor () { 111 return impl.getDeploymentDescriptor(); 112 } 113 114 120 public FileObject[] getJavaSources() { 121 return impl.getJavaSources(); 122 } 123 124 126 public FileObject getMetaInf() { 127 return impl.getMetaInf(); 128 } 129 130 136 public MetadataUnit getMetadataUnit() { 137 return impl.getMetadataUnit(); 138 } 139 140 } 141 | Popular Tags |