KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > config > ModuleConfig


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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 JavaDoc;
23 import java.io.File JavaDoc;
24 import java.util.logging.Logger JavaDoc;
25
26 /**
27  *
28  * date: Aug 13, 2004
29  * @author Rakesh Kalra
30  */

31 public class ModuleConfig {
32
33     private static final Logger JavaDoc logger = Loggers.getLogger(ModuleConfig.class);
34
35     private String JavaDoc id;
36     private MetaApplicationConfig metaConfig;
37     private String JavaDoc connectionFactory;
38
39     public ModuleConfig(String JavaDoc id,
40                         MetaApplicationConfig metaConfig,
41                         String JavaDoc 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 JavaDoc getConnectionFactory() {
54         return connectionFactory;
55     }
56
57     public boolean isAvailable(){
58         final String JavaDoc moduleDirPath =
59                 CoreUtils.getModuleDir(id);
60         final File JavaDoc moduleDir = new File JavaDoc(moduleDirPath);
61         return moduleDir.isDirectory();
62     }
63
64     public URL JavaDoc[] getModuleClassPath()
65         throws ModuleNotFoundException {
66
67         final String JavaDoc moduleDirPath =
68                 CoreUtils.getModuleDir(id);
69         final File JavaDoc moduleDir = new File JavaDoc(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 JavaDoc{
77         ModuleNotFoundException(String JavaDoc module){
78             super("Module=" + module);
79         }
80     }
81 }
82
Popular Tags