1 16 package org.jmanage.core.config; 17 18 import org.jmanage.core.config.MetaApplicationConfig; 19 import org.jmanage.core.util.CoreUtils; 20 import org.jmanage.core.util.Loggers; 21 22 import java.net.URL ; 23 import java.io.File ; 24 import java.util.logging.Logger ; 25 26 31 public class ModuleConfig { 32 33 private static final Logger logger = Loggers.getLogger(ModuleConfig.class); 34 35 private String id; 36 private MetaApplicationConfig metaConfig; 37 private String connectionFactory; 38 39 public ModuleConfig(String id, 40 MetaApplicationConfig metaConfig, 41 String connectionFactory) 42 throws ModuleNotFoundException { 43 44 this.id = id; 45 this.metaConfig = metaConfig; 46 this.connectionFactory = connectionFactory; 47 } 48 49 public MetaApplicationConfig getMetaApplicationConfig() { 50 return metaConfig; 51 } 52 53 public String getConnectionFactory() { 54 return connectionFactory; 55 } 56 57 public boolean isAvailable(){ 58 final String moduleDirPath = 59 CoreUtils.getModuleDir(id); 60 final File moduleDir = new File (moduleDirPath); 61 return moduleDir.isDirectory(); 62 } 63 64 public URL [] getModuleClassPath() 65 throws ModuleNotFoundException { 66 67 final String moduleDirPath = 68 CoreUtils.getModuleDir(id); 69 final File moduleDir = new File (moduleDirPath); 70 if(!moduleDir.isDirectory()){ 71 throw new ModuleNotFoundException(id); 72 } 73 return ConfigUtils.getClassPath(moduleDir); 74 } 75 76 public static class ModuleNotFoundException extends RuntimeException { 77 ModuleNotFoundException(String module){ 78 super("Module=" + module); 79 } 80 } 81 } 82 | Popular Tags |