1 19 20 package org.netbeans.modules.j2ee.ejbjar; 21 22 import java.util.Collections ; 23 import java.util.HashMap ; 24 import org.netbeans.api.java.classpath.ClassPath; 25 import org.netbeans.modules.j2ee.api.ejbjar.*; 26 import org.netbeans.modules.j2ee.metadata.MetadataUnit; 27 import org.netbeans.modules.j2ee.spi.ejbjar.*; 28 import org.netbeans.spi.java.classpath.PathResourceImplementation; 29 import org.netbeans.spi.java.classpath.support.ClassPathSupport; 30 import org.openide.filesystems.FileObject; 31 32 36 public class CustomProvider implements EjbJarProvider { 37 38 private HashMap cache = new HashMap (); 39 40 public CustomProvider () { 41 } 42 43 public EjbJar findEjbJar (FileObject file) { 44 if (file.getExt ().equals ("foo")) { 45 EjbJar em = (EjbJar) cache.get (file.getParent ()); 46 if (em == null) { 47 em = EjbJarFactory.createEjbJar (new EM (file.getParent (), EjbProjectConstants.J2EE_14_LEVEL)); 48 cache.put (file.getParent (), em); 49 } 50 return em; 51 } 52 return null; 53 } 54 55 private class EM implements EjbJarImplementation { 56 FileObject root; 57 String ver; 58 private MetadataUnit metadataUnit; 59 60 public EM (FileObject root, String ver) { 61 this.root = root; 62 this.ver = ver; 63 } 64 65 public String getJ2eePlatformVersion () { 66 return ver; 67 } 68 69 public FileObject getDeploymentDescriptor () { 70 return root.getFileObject ("conf/ejb-jar.xml"); 71 } 72 73 public FileObject getMetaInf () { 74 return null; 75 } 76 77 public FileObject[] getJavaSources() { 78 return null; 79 } 80 81 public MetadataUnit getMetadataUnit() { 82 synchronized (this) { 83 if (metadataUnit == null) { 84 metadataUnit = new MetadataUnitImpl(); 85 } 86 return metadataUnit; 87 } 88 } 89 90 private class MetadataUnitImpl implements MetadataUnit { 91 public ClassPath getClassPath() { 92 return ClassPathSupport.createClassPath(Collections.<PathResourceImplementation>emptyList()); 93 } 94 public FileObject getDeploymentDescriptor() { 95 return EM.this.getDeploymentDescriptor(); 96 } 97 } 98 } 99 } 100 | Popular Tags |