001: /**
002: * Copyright (c) 2004-2005 jManage.org
003: *
004: * This is a free software; you can redistribute it and/or
005: * modify it under the terms of the license at
006: * http://www.jmanage.org.
007: *
008: * Unless required by applicable law or agreed to in writing, software
009: * distributed under the License is distributed on an "AS IS" BASIS,
010: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011: * See the License for the specific language governing permissions and
012: * limitations under the License.
013: */package org.jmanage.core.config;
014:
015: import org.jmanage.core.util.Loggers;
016: import org.jmanage.core.util.CoreUtils;
017:
018: import java.net.URL;
019: import java.util.logging.Logger;
020: import java.io.File;
021:
022: /**
023: *
024: * <p>
025: * Date: Sep 25, 2005
026: * @author Rakesh Kalra
027: */
028: public class ApplicationType {
029:
030: private static final Logger logger = Loggers
031: .getLogger(ApplicationType.class);
032:
033: private String id;
034: private String name;
035: private ModuleConfig module;
036: private boolean isCompatibleJMX;
037: private String defaultHost;
038: private String defaultPort;
039: private String defaultURL;
040:
041: private ClassLoader classLoader;
042:
043: public ApplicationType(String id, String name, ModuleConfig module,
044: boolean isCompatibleJMX, String defaultHost,
045: String defaultPort, String defaultURL) {
046: this .id = id;
047: this .name = name;
048: this .module = module;
049: this .isCompatibleJMX = isCompatibleJMX;
050: this .defaultHost = defaultHost;
051: this .defaultPort = defaultPort;
052: this .defaultURL = defaultURL;
053: }
054:
055: public String getId() {
056: return id;
057: }
058:
059: public String getName() {
060: return name;
061: }
062:
063: public ModuleConfig getModule() {
064: return module;
065: }
066:
067: public boolean isCompatibleJMX() {
068: return isCompatibleJMX;
069: }
070:
071: public String getDefaultHost() {
072: return defaultHost;
073: }
074:
075: public String getDefaultPort() {
076: return defaultPort;
077: }
078:
079: public String getDefaultURL() {
080: return defaultURL;
081: }
082:
083: public ClassLoader getClassLoader() {
084: if (classLoader == null) {
085: classLoader = ClassLoaderRepository.getClassLoader(
086: getClassPath(), isCompatibleJMX);
087: }
088: return classLoader;
089: }
090:
091: public URL[] getClassPath() {
092: URL[] classpath = module.getModuleClassPath();
093: File appDir = new File(CoreUtils.getApplicationDir(id));
094: if (appDir.isDirectory()) {
095: URL[] appClasspath = ConfigUtils.getClassPath(appDir);
096: /* add the two paths together */
097: URL[] moduleClasspath = classpath;
098: classpath = new URL[appClasspath.length
099: + moduleClasspath.length];
100: int i = 0;
101: for (i = 0; i < appClasspath.length; i++) {
102: classpath[i] = appClasspath[i];
103: }
104: for (int j = 0; j < moduleClasspath.length; j++, i++) {
105: classpath[i] = appClasspath[j];
106: }
107: }
108: return classpath;
109: }
110: }
|