001: /*
002: * %W% %E%
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.jumpimpl.module.installer;
028:
029: import com.sun.jump.common.JUMPAppModel;
030: import com.sun.jump.common.JUMPApplication;
031: import java.net.MalformedURLException;
032: import java.net.URL;
033:
034: /**
035: * This is the representation class for a Main application.
036: */
037: public class MAINApplication extends JUMPApplication {
038:
039: public static final String CLASSPATH_KEY = "MAINApplication_classpath";
040: public static final String BUNDLE_KEY = "MAINApplication_bundle";
041: public static final String INITIAL_CLASS_KEY = "MAINApplication_initialClass";
042: private String repositoryDir = null;
043:
044: /**
045: * Create an instance of an application.
046: *
047: * @param bundle The name of the bundle the application belongs to
048: * @param clazz The class name of the application
049: * @param classpath The path to the application
050: * @param title The application's title, can be null
051: * @param iconPath The location of the application's icon in, can be null
052: */
053: public MAINApplication(String repositoryDir, String bundle,
054: String clazz, URL classpath, String title, URL iconPath,
055: int id) {
056:
057: super (title, iconPath, JUMPAppModel.MAIN, id);
058: this .repositoryDir = repositoryDir;
059: addProperty(INITIAL_CLASS_KEY, clazz);
060: if (classpath != null) {
061: addProperty(CLASSPATH_KEY, classpath.getFile());
062: }
063: addProperty(BUNDLE_KEY, bundle);
064: }
065:
066: /**
067: * Get the name of the bundle this application belongs to
068: * @return the bundle this application belongs to
069: */
070: public String getBundle() {
071: return getProperty(BUNDLE_KEY);
072: }
073:
074: /**
075: * Set the bundle name of the application.
076: * @param bundle the bundle this application belongs to
077: */
078: public void setBundle(String bundle) {
079: addProperty(BUNDLE_KEY, bundle);
080: }
081:
082: /**
083: * Set the classpath value of this application
084: * @param classpath the classpath value
085: */
086: public void setClasspath(URL classpath) {
087: if (classpath != null) {
088: addProperty(CLASSPATH_KEY, classpath.getFile());
089: }
090: }
091:
092: /**
093: * Get the classpath value of this application
094: * @return the classpath value
095: */
096: public URL getClasspath() {
097: URL url = null;
098: try {
099: url = new URL("file", null, getProperty(CLASSPATH_KEY));
100: } catch (MalformedURLException ex) {
101: ex.printStackTrace();
102: }
103: return url;
104: }
105:
106: /**
107: * Set the initial class of this application
108: * @param initialClass the initial class of this application
109: */
110: public void setInitialClass(String initialClass) {
111: addProperty(INITIAL_CLASS_KEY, initialClass);
112: }
113: }
|