KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > Events


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans;
21
22 import java.util.Arrays JavaDoc;
23 import java.util.logging.Level JavaDoc;
24
25 /** Track events that occur in the module system abstractly.
26  * A concrete implementation can provide localized messages
27  * for these, notify the user visually, track performance, etc.
28  * Only events relevant to the user or to performance need to
29  * be logged; detailed low-level descriptions of what is
30  * happening can simply be logged to the ErrorManager.
31  * @author Jesse Glick
32  */

33 public abstract class Events {
34
35     /** String message */
36     public static final String JavaDoc PERF_START = "perfStart"; // NOI18N
37
/** String message */
38     public static final String JavaDoc PERF_TICK = "perfTick"; // NOI18N
39
/** String message */
40     public static final String JavaDoc PERF_END = "perfEnd"; // NOI18N
41

42     /** File jar */
43     public static final String JavaDoc START_CREATE_REGULAR_MODULE = "startCreateRegularModule"; // NOI18N
44
/** File jar */
45     public static final String JavaDoc FINISH_CREATE_REGULAR_MODULE = "finishCreateRegularModule"; // NOI18N
46
/** Object history */
47     public static final String JavaDoc START_CREATE_BOOT_MODULE = "startCreateBootModule"; // NOI18N
48
/** Object history */
49     public static final String JavaDoc FINISH_CREATE_BOOT_MODULE = "finishCreateBootModule"; // NOI18N
50
/** no args */
51     public static final String JavaDoc CREATED_MODULE_SYSTEM = "createdModuleSystem"; // NOI18N
52
/** no args */
53     public static final String JavaDoc START_LOAD_BOOT_MODULES = "startLoadBootModules"; // NOI18N
54
/** no args */
55     public static final String JavaDoc FINISH_LOAD_BOOT_MODULES = "finishLoadBootModules"; // NOI18N
56
/** File jar */
57     public static final String JavaDoc START_DEPLOY_TEST_MODULE = "startDeployTestModule"; // NOI18N
58
/** File jar */
59     public static final String JavaDoc FINISH_DEPLOY_TEST_MODULE = "finishDeployTestModule"; // NOI18N
60
/** Module toDelete */
61     public static final String JavaDoc DELETE_MODULE = "deleteModule"; // NOI18N
62
/** List<Module> toEnable */
63     public static final String JavaDoc START_ENABLE_MODULES = "startEnableModules"; // NOI18N
64
/** List<Module> toEnable */
65     public static final String JavaDoc FINISH_ENABLE_MODULES = "finishEnableModules"; // NOI18N
66
/** List<Module> toDisable */
67     public static final String JavaDoc START_DISABLE_MODULES = "startDisableModules"; // NOI18N
68
/** List<Module> toDisable */
69     public static final String JavaDoc FINISH_DISABLE_MODULES = "finishDisableModules"; // NOI18N
70
/** Module prepared */
71     public static final String JavaDoc PREPARE = "prepare"; // NOI18N
72
/** List<Module> loaded */
73     public static final String JavaDoc START_LOAD = "startLoad"; // NOI18N
74
/** List<Module> loaded */
75     public static final String JavaDoc FINISH_LOAD = "finishLoad"; // NOI18N
76
/** List<Module> unloaded */
77     public static final String JavaDoc START_UNLOAD = "startUnload"; // NOI18N
78
/** List<Module> unloaded */
79     public static final String JavaDoc FINISH_UNLOAD = "finishUnload"; // NOI18N
80
/** Module installed */
81     public static final String JavaDoc INSTALL = "install"; // NOI18N
82
/** Module uninstalled */
83     public static final String JavaDoc UNINSTALL = "uninstall"; // NOI18N
84
/** Module restored */
85     public static final String JavaDoc RESTORE = "restore"; // NOI18N
86
/** Module updated */
87     public static final String JavaDoc UPDATE = "update"; // NOI18N
88
/** Module home, ManifestSection section */
89     public static final String JavaDoc LOAD_SECTION = "loadSection"; // NOI18N
90
/** no args */
91     public static final String JavaDoc CLOSE = "close"; // NOI18N
92
/** no args */
93     public static final String JavaDoc START_READ = "startRead"; // NOI18N
94
/** Set<Module> found */
95     public static final String JavaDoc FINISH_READ = "finishRead"; // NOI18N
96
/** FileObject */
97     public static final String JavaDoc MODULES_FILE_PROCESSED = "modulesFileProcessed"; // NOI18N
98
/** Integer */
99     public static final String JavaDoc MODULES_FILE_SCANNED = "modulesFileScanned"; // NOI18N
100
/** Set<Module> toInstall */
101     public static final String JavaDoc START_AUTO_RESTORE = "startAutoRestore"; // NOI18N
102
/** Set<Module> toInstall */
103     public static final String JavaDoc FINISH_AUTO_RESTORE = "finishAutoRestore"; // NOI18N
104
/** Set<Module> notInstalled */
105     public static final String JavaDoc FAILED_INSTALL_NEW = "failedInstallNew"; // NOI18N
106
/** Module notInstalled, InvalidException problem */
107     public static final String JavaDoc FAILED_INSTALL_NEW_UNEXPECTED = "failedInstallNewUnexpected"; // NOI18N
108
/** Set<Module> modules */
109     public static final String JavaDoc LOAD_LAYERS = "loadLayers"; // NOI18N
110
/** Set<Module> modules */
111     public static final String JavaDoc UNLOAD_LAYERS = "unloadLayers"; // NOI18N
112
/** Module culprit, Class offending, ClassLoader expected */
113     public static final String JavaDoc WRONG_CLASS_LOADER = "wrongClassLoader"; // NOI18N
114
/** File extension, Set<File> owners */
115     public static final String JavaDoc EXTENSION_MULTIPLY_LOADED = "extensionMultiplyLoaded"; // NOI18N
116
/** File nonexistentJar */
117     public static final String JavaDoc MISSING_JAR_FILE = "missingJarFile"; // NOI18N
118
/** Module autoload (or since org.netbeans.core/1 1.3, eager) */
119     public static final String JavaDoc CANT_DELETE_ENABLED_AUTOLOAD = "cantDeleteEnabledAutoload"; // NOI18N
120
/** Module afflicted, String propname, Object valueOnDisk, Object actualValue */
121     public static final String JavaDoc MISC_PROP_MISMATCH = "miscPropMismatch"; // NOI18N
122
/** File patchfile */
123     public static final String JavaDoc PATCH = "patch"; // NOI18N
124

125     /** Constructor for subclasses to use. */
126     protected Events() {
127     }
128     
129     /** Log an event.
130      * You must pass a fixed event type string, and a list
131      * of arguments (meaning varies according to event type).
132      * Note that the event type string must be the exact String
133      * listed as the constant in this class, not a copy.
134      */

135     public final void log(String JavaDoc message, Object JavaDoc ... args) {
136         if (Util.err.isLoggable(Level.FINE) &&
137                 message != PERF_START && message != PERF_TICK && message != PERF_END) {
138             Util.err.fine("EVENT -> " + message + " " + Arrays.asList(args));
139         }
140         try {
141             logged(message, args);
142         } catch (RuntimeException JavaDoc re) {
143             // If there is any problem logging, it should not kill the system
144
// which called the logger.
145
Util.err.log(Level.WARNING, null, re);
146         }
147     }
148     
149     /** Report an event.
150      */

151     protected abstract void logged(String JavaDoc message, Object JavaDoc[] args);
152     
153 }
154
Popular Tags