1 19 20 package org.netbeans.modules.j2ee.deployment.common.api; 21 22 import java.io.File ; 23 import javax.enterprise.deploy.model.DDBean ; 24 import javax.enterprise.deploy.model.DeployableObject ; 25 import org.netbeans.api.project.FileOwnerQuery; 26 import org.netbeans.api.project.Project; 27 import org.netbeans.modules.j2ee.deployment.config.DDCommon; 28 import org.netbeans.modules.j2ee.deployment.config.DeployableObjectImpl; 29 import org.netbeans.modules.j2ee.deployment.config.StandardDDImpl; 30 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; 31 import org.openide.filesystems.FileObject; 32 import org.openide.util.Lookup; 33 34 44 public abstract class SourceFileMap { 45 46 50 public abstract FileObject[] findSourceFile(String distributionPath); 51 52 56 public abstract File getDistributionPath(FileObject sourceFile); 57 58 61 public abstract FileObject[] getSourceRoots(); 62 63 66 public abstract String getContextName(); 67 68 73 public abstract File getEnterpriseResourceDir(); 74 75 84 public abstract File [] getEnterpriseResourceDirs(); 85 86 97 public abstract boolean add(String distributionPath, FileObject sourceFile); 98 99 103 public abstract FileObject remove(String distributionPath); 104 105 110 public static final SourceFileMap findSourceMap(FileObject source) { 111 Project owner = FileOwnerQuery.getOwner(source); 112 if (owner != null) { 113 Lookup l = owner.getLookup(); 114 J2eeModuleProvider projectModule = (J2eeModuleProvider) l.lookup(J2eeModuleProvider.class); 115 if (projectModule != null) { 116 return projectModule.getSourceFileMap(); 117 } 118 } 119 return null; 120 } 121 122 127 public static final SourceFileMap findSourceMap(DDBean ddbean) { 128 if (ddbean instanceof DDCommon) { 129 DDCommon dd = (DDCommon) ddbean; 130 return dd.getModuleProvider().getSourceFileMap(); 131 } else if (ddbean instanceof StandardDDImpl) { 132 StandardDDImpl dd = (StandardDDImpl) ddbean; 133 return dd.getModuleProvider().getSourceFileMap(); 134 } 135 return null; 136 } 137 138 143 public static final SourceFileMap findSourceMap(DeployableObject deployable) { 144 if (deployable instanceof DeployableObjectImpl) { 145 return ((DeployableObjectImpl)deployable).getProvider().getSourceFileMap(); 146 } 147 return null; 148 } 149 } 150 | Popular Tags |