001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans;
043:
044: import java.util.Arrays;
045: import java.util.logging.Level;
046:
047: /** Track events that occur in the module system abstractly.
048: * A concrete implementation can provide localized messages
049: * for these, notify the user visually, track performance, etc.
050: * Only events relevant to the user or to performance need to
051: * be logged; detailed low-level descriptions of what is
052: * happening can simply be logged to the ErrorManager.
053: * @author Jesse Glick
054: */
055: public abstract class Events {
056:
057: /** String message */
058: public static final String PERF_START = "perfStart"; // NOI18N
059: /** String message */
060: public static final String PERF_TICK = "perfTick"; // NOI18N
061: /** String message */
062: public static final String PERF_END = "perfEnd"; // NOI18N
063:
064: /** File jar */
065: public static final String START_CREATE_REGULAR_MODULE = "startCreateRegularModule"; // NOI18N
066: /** File jar */
067: public static final String FINISH_CREATE_REGULAR_MODULE = "finishCreateRegularModule"; // NOI18N
068: /** Object history */
069: public static final String START_CREATE_BOOT_MODULE = "startCreateBootModule"; // NOI18N
070: /** Object history */
071: public static final String FINISH_CREATE_BOOT_MODULE = "finishCreateBootModule"; // NOI18N
072: /** no args */
073: public static final String CREATED_MODULE_SYSTEM = "createdModuleSystem"; // NOI18N
074: /** no args */
075: public static final String START_LOAD_BOOT_MODULES = "startLoadBootModules"; // NOI18N
076: /** no args */
077: public static final String FINISH_LOAD_BOOT_MODULES = "finishLoadBootModules"; // NOI18N
078: /** File jar */
079: public static final String START_DEPLOY_TEST_MODULE = "startDeployTestModule"; // NOI18N
080: /** File jar */
081: public static final String FINISH_DEPLOY_TEST_MODULE = "finishDeployTestModule"; // NOI18N
082: /** Module toDelete */
083: public static final String DELETE_MODULE = "deleteModule"; // NOI18N
084: /** List<Module> toEnable */
085: public static final String START_ENABLE_MODULES = "startEnableModules"; // NOI18N
086: /** List<Module> toEnable */
087: public static final String FINISH_ENABLE_MODULES = "finishEnableModules"; // NOI18N
088: /** List<Module> toDisable */
089: public static final String START_DISABLE_MODULES = "startDisableModules"; // NOI18N
090: /** List<Module> toDisable */
091: public static final String FINISH_DISABLE_MODULES = "finishDisableModules"; // NOI18N
092: /** Module prepared */
093: public static final String PREPARE = "prepare"; // NOI18N
094: /** List<Module> loaded */
095: public static final String START_LOAD = "startLoad"; // NOI18N
096: /** List<Module> loaded */
097: public static final String FINISH_LOAD = "finishLoad"; // NOI18N
098: /** List<Module> unloaded */
099: public static final String START_UNLOAD = "startUnload"; // NOI18N
100: /** List<Module> unloaded */
101: public static final String FINISH_UNLOAD = "finishUnload"; // NOI18N
102: /** Module installed */
103: public static final String INSTALL = "install"; // NOI18N
104: /** Module uninstalled */
105: public static final String UNINSTALL = "uninstall"; // NOI18N
106: /** Module restored */
107: public static final String RESTORE = "restore"; // NOI18N
108: /** Module updated */
109: public static final String UPDATE = "update"; // NOI18N
110: /** Module home, ManifestSection section */
111: public static final String LOAD_SECTION = "loadSection"; // NOI18N
112: /** no args */
113: public static final String CLOSE = "close"; // NOI18N
114: /** no args */
115: public static final String START_READ = "startRead"; // NOI18N
116: /** Set<Module> found */
117: public static final String FINISH_READ = "finishRead"; // NOI18N
118: /** FileObject */
119: public static final String MODULES_FILE_PROCESSED = "modulesFileProcessed"; // NOI18N
120: /** Integer */
121: public static final String MODULES_FILE_SCANNED = "modulesFileScanned"; // NOI18N
122: /** Set<Module> toInstall */
123: public static final String START_AUTO_RESTORE = "startAutoRestore"; // NOI18N
124: /** Set<Module> toInstall */
125: public static final String FINISH_AUTO_RESTORE = "finishAutoRestore"; // NOI18N
126: /** Set<Module> notInstalled */
127: public static final String FAILED_INSTALL_NEW = "failedInstallNew"; // NOI18N
128: /** Module notInstalled, InvalidException problem */
129: public static final String FAILED_INSTALL_NEW_UNEXPECTED = "failedInstallNewUnexpected"; // NOI18N
130: /** Set<Module> modules */
131: public static final String LOAD_LAYERS = "loadLayers"; // NOI18N
132: /** Set<Module> modules */
133: public static final String UNLOAD_LAYERS = "unloadLayers"; // NOI18N
134: /** Module culprit, Class offending, ClassLoader expected */
135: public static final String WRONG_CLASS_LOADER = "wrongClassLoader"; // NOI18N
136: /** File extension, Set<File> owners */
137: public static final String EXTENSION_MULTIPLY_LOADED = "extensionMultiplyLoaded"; // NOI18N
138: /** File nonexistentJar */
139: public static final String MISSING_JAR_FILE = "missingJarFile"; // NOI18N
140: /** Module autoload (or since org.netbeans.core/1 1.3, eager) */
141: public static final String CANT_DELETE_ENABLED_AUTOLOAD = "cantDeleteEnabledAutoload"; // NOI18N
142: /** Module afflicted, String propname, Object valueOnDisk, Object actualValue */
143: public static final String MISC_PROP_MISMATCH = "miscPropMismatch"; // NOI18N
144: /** File patchfile */
145: public static final String PATCH = "patch"; // NOI18N
146:
147: /** Constructor for subclasses to use. */
148: protected Events() {
149: }
150:
151: /** Log an event.
152: * You must pass a fixed event type string, and a list
153: * of arguments (meaning varies according to event type).
154: * Note that the event type string must be the exact String
155: * listed as the constant in this class, not a copy.
156: */
157: public final void log(String message, Object... args) {
158: if (Util.err.isLoggable(Level.FINE) && message != PERF_START
159: && message != PERF_TICK && message != PERF_END) {
160: Util.err.fine("EVENT -> " + message + " "
161: + Arrays.asList(args));
162: }
163: try {
164: logged(message, args);
165: } catch (RuntimeException re) {
166: // If there is any problem logging, it should not kill the system
167: // which called the logger.
168: Util.err.log(Level.WARNING, null, re);
169: }
170: }
171:
172: /** Report an event.
173: */
174: protected abstract void logged(String message, Object[] args);
175:
176: }
|