KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.core.config;
15
16 import org.jmanage.core.util.Loggers;
17 import org.jmanage.core.util.CoreUtils;
18
19 import java.net.URL JavaDoc;
20 import java.util.logging.Logger JavaDoc;
21 import java.io.File JavaDoc;
22
23 /**
24  *
25  * <p>
26  * Date: Sep 25, 2005
27  * @author Rakesh Kalra
28  */

29 public class ApplicationType {
30
31     private static final Logger JavaDoc logger =
32             Loggers.getLogger(ApplicationType.class);
33
34     private String JavaDoc id;
35     private String JavaDoc name;
36     private ModuleConfig module;
37     private boolean isCompatibleJMX;
38     private String JavaDoc defaultHost;
39     private String JavaDoc defaultPort;
40     private String JavaDoc defaultURL;
41
42     private ClassLoader JavaDoc classLoader;
43
44     public ApplicationType(String JavaDoc id,
45                            String JavaDoc name,
46                            ModuleConfig module,
47                            boolean isCompatibleJMX,
48                            String JavaDoc defaultHost,
49                            String JavaDoc defaultPort,
50                            String JavaDoc defaultURL){
51         this.id = id;
52         this.name = name;
53         this.module = module;
54         this.isCompatibleJMX = isCompatibleJMX;
55         this.defaultHost = defaultHost;
56         this.defaultPort = defaultPort;
57         this.defaultURL = defaultURL;
58     }
59
60     public String JavaDoc getId() {
61         return id;
62     }
63
64     public String JavaDoc getName() {
65         return name;
66     }
67
68     public ModuleConfig getModule() {
69         return module;
70     }
71
72     public boolean isCompatibleJMX() {
73         return isCompatibleJMX;
74     }
75
76     public String JavaDoc getDefaultHost() {
77         return defaultHost;
78     }
79
80     public String JavaDoc getDefaultPort() {
81         return defaultPort;
82     }
83
84     public String JavaDoc getDefaultURL() {
85         return defaultURL;
86     }
87
88     public ClassLoader JavaDoc getClassLoader() {
89         if(classLoader == null){
90             classLoader = ClassLoaderRepository.getClassLoader(getClassPath(),
91                     isCompatibleJMX);
92         }
93         return classLoader;
94     }
95
96     public URL JavaDoc[] getClassPath(){
97         URL JavaDoc[] classpath = module.getModuleClassPath();
98         File JavaDoc appDir = new File JavaDoc(CoreUtils.getApplicationDir(id));
99         if(appDir.isDirectory()){
100             URL JavaDoc[] appClasspath = ConfigUtils.getClassPath(appDir);
101             /* add the two paths together */
102             URL JavaDoc[] moduleClasspath = classpath;
103             classpath = new URL JavaDoc[appClasspath.length + moduleClasspath.length];
104             int i=0;
105             for(i=0; i<appClasspath.length;i++){
106                 classpath[i] = appClasspath[i];
107             }
108             for(int j=0; j<moduleClasspath.length; j++, i++){
109                 classpath[i] = appClasspath[j];
110             }
111         }
112         return classpath;
113     }
114 }
115
Popular Tags