Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
8 |
* Development and Distribution License("CDDL") (collectively, the |
9 |
* "License"). You may not use this file except in compliance with the |
10 |
* License. You can obtain a copy of the License at |
11 |
* http://www.netbeans.org/cddl-gplv2.html |
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
13 |
* specific language governing permissions and limitations under the |
14 |
* License. When distributing the software, include this License Header |
15 |
* Notice in each file and include the License file at |
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this |
17 |
* particular file as subject to the "Classpath" exception as provided |
18 |
* by Sun in the GPL Version 2 section of the License file that |
19 |
* accompanied this code. If applicable, add the following below the |
20 |
* License Header, with the fields enclosed by brackets [] replaced by |
21 |
* your own identifying information: |
22 |
* "Portions Copyrighted [year] [name of copyright owner]" |
23 |
* |
24 |
* If you wish your version of this file to be governed by only the CDDL |
25 |
* or only the GPL Version 2, indicate your decision by adding |
26 |
* "[Contributor] elects to include this software in this distribution |
27 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
28 |
* single choice of license, a recipient has the option to distribute |
29 |
* your version of this file under either the CDDL, the GPL Version 2 or |
30 |
* to extend the choice of license to its licensees as provided above. |
31 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
32 |
* Version 2 license, then the option applies only if the new code is |
33 |
* made subject to such option by the copyright holder. |
34 |
* |
35 |
* Contributor(s): |
36 |
* |
37 |
* Portions Copyrighted 2008 Sun Microsystems, Inc. |
38 |
*/ |
39 |
package org.netbeans.modules.mobility.project.ui.wizard; |
40 |
|
41 |
import java.util.logging.Level; |
42 |
import java.util.logging.Logger; |
43 |
import org.openide.util.Lookup; |
44 |
import org.openide.util.RequestProcessor; |
45 |
|
46 |
/** |
47 |
* Preloads Java classes that will be loaded if a project is created |
48 |
* after a cold start. Part of fix for issue 147403. Basically we |
49 |
* amortize the classloading cost by doing classloading on a background |
50 |
* low-priority thread while the user is still in the wizard. |
51 |
* <p/> |
52 |
* The idea is to amortize some classloading over the time the machine |
53 |
* is relatively idle, as the user goes through the wizard the first time, |
54 |
* and to warm up the OS's |
55 |
* filesystem cache with the JARs that will be touched once the project |
56 |
* is created. |
57 |
* <p> |
58 |
* Note that the list of classes includes non-public ones in some cases, |
59 |
* so it will probably require maintenance on a release-by-release basis. |
60 |
* |
61 |
* @author Tim Boudreau |
62 |
*/ |
63 |
public final class ClassPreloader implements Runnable { |
64 |
private static volatile boolean done; |
65 |
private ClassPreloader() {} |
66 |
|
67 |
static void start() { |
68 |
//invoked from a static block in NewProjectIterator |
69 |
RequestProcessor.getDefault().post(new ClassPreloader(), 0, |
70 |
Thread.MIN_PRIORITY); |
71 |
} |
72 |
|
73 |
public static void stop() { |
74 |
//invoked by J2MEProjectGenerator.createNewProject() |
75 |
done = true; |
76 |
} |
77 |
|
78 |
public void run() { |
79 |
ClassLoader systemLoader = Lookup.getDefault().lookup(ClassLoader.class); |
80 |
assert systemLoader != null; |
81 |
Object o; |
82 |
Logger logger = Logger.getLogger(ClassPreloader.class.getName()); |
83 |
int ix = 0; |
84 |
final boolean logDetails = logger.isLoggable (Level.FINEST); |
85 |
for (String type : TO_PRELOAD) { |
86 |
try { |
87 |
o = Class.forName(type, true, systemLoader); |
88 |
if (logDetails) { |
89 |
logger.log(Level.FINEST, "Preloaded " + type); //NOI18N |
90 |
} |
91 |
//Try to keep this thread from ever bogging down the UI |
92 |
if ((ix++ % 5) == 0) { |
93 |
Thread.yield(); |
94 |
} |
95 |
} catch (ClassNotFoundException ex) { |
96 |
if (logger.isLoggable(Level.INFO)) { |
97 |
logger.log(Level.INFO, "Could not preload " + type); //NOI18N |
98 |
} |
99 |
} |
100 |
if (done) { |
101 |
if (logDetails) { |
102 |
logger.log(Level.FINEST, "Exit preload early"); //NOI18N |
103 |
} |
104 |
break; |
105 |
} |
106 |
} |
107 |
} |
108 |
private static final String[] TO_PRELOAD = new String[]{ |
109 |
"org.netbeans.modules.mobility.project.J2MEProjectGenerator", //NOI18N |
110 |
"org.netbeans.spi.project.support.ant.ProjectGenerator", //NOI18N |
111 |
"javax.xml.transform.TransformerFactory", //NOI18N |
112 |
"javax.xml.transform.FactoryFinder", //NOI18N |
113 |
"com.sun.org.apache.xalan.internal.xsltc.compiler.RelativePathPattern", //NOI18N |
114 |
"com.sun.org.apache.bcel.internal.classfile.Node", //NOI18N |
115 |
"com.sun.org.apache.bcel.internal.classfile.Constant", //NOI18N |
116 |
"com.sun.org.apache.bcel.internal.classfile.Attribute", //NOI18N |
117 |
"com.sun.org.apache.bcel.internal.classfile.SourceFile", //NOI18N |
118 |
"org.netbeans.api.queries.FileEncodingQuery", //NOI18N |
119 |
"com.sun.org.apache.xalan.internal.xsltc.compiler.Comment", //NOI18N |
120 |
"com.sun.org.apache.xalan.internal.xsltc.compiler.XslAttribute", //NOI18N |
121 |
"com.sun.org.apache.xalan.internal.xsltc.compiler.ValueOf", //NOI18N |
122 |
"com.sun.org.apache.xml.internal.utils.SystemIDResolver", //NOI18N |
123 |
"javax.script.ScriptEngine", //NOI18N |
124 |
"javax.script.ScriptEngineManager", //NOI18N |
125 |
"javax.script.Bindings", //NOI18N |
126 |
"javax.script.SimpleBindings", //NOI18N |
127 |
"javax.script.ScriptEngineManager$1", //NOI18N |
128 |
"javax.script.ScriptEngineFactory", //NOI18N |
129 |
"com.sun.script.javascript.RhinoScriptEngineFactory", //NOI18N |
130 |
"org.netbeans.libs.freemarker.FreemarkerFactory", //NOI18N |
131 |
"javax.script.AbstractScriptEngine", //NOI18N |
132 |
"org.netbeans.libs.freemarker.FreemarkerEngine", //NOI18N |
133 |
"javax.script.ScriptContext", //NOI18N |
134 |
"javax.script.SimpleScriptContext", //NOI18N |
135 |
"org.openide.loaders.CreateFromTemplateAttributesProvider", //NOI18N |
136 |
"org.netbeans.modules.project.uiapi.ProjectTemplateAttributesProvider", //NOI18N |
137 |
"org.netbeans.modules.projectapi.ProjectFileEncodingQueryImplementation", //NOI18N |
138 |
"org.netbeans.modules.diff.DiffFileEncodingQueryImplementation", //NOI18N |
139 |
"org.netbeans.spi.java.project.support.ui.PackageView", //NOI18N |
140 |
"org.netbeans.spi.java.project.support.ui.PackageRootNode", //NOI18N |
141 |
"org.netbeans.modules.editor.SimpleIndentEngine", //NOI18N |
142 |
"org.netbeans.modules.mobility.project.ui.NodeActions$AntAction", //NOI18N |
143 |
"org.netbeans.modules.mobility.project.ui.NodeActions$BuildConfigurationAction", //NOI18N |
144 |
"org.netbeans.modules.mobility.project.ui.NodeActions$CleanAndBuildConfigurationAction", //NOI18N |
145 |
"org.netbeans.modules.mobility.project.ui.NodeActions$CleanConfigurationAction", //NOI18N |
146 |
"org.netbeans.modules.mobility.project.ui.NodeActions$DeployConfigurationAction", //NOI18N |
147 |
"org.netbeans.modules.mobility.project.ui.NodeActions$SetConfigurationAction", //NOI18N |
148 |
"org.netbeans.modules.mobility.project.ui.NodeActions$AddConfigurationAction", //NOI18N |
149 |
"freemarker.template.TemplateScalarModel", //NOI18N |
150 |
"freemarker.template.TemplateSequenceModel", //NOI18N |
151 |
"freemarker.template.TemplateHashModelEx", //NOI18N |
152 |
"freemarker.template.TemplateMethodModel", //NOI18N |
153 |
"freemarker.template.TemplateMethodModelEx", //NOI18N |
154 |
"freemarker.template.GeneralPurposeNothing", //NOI18N |
155 |
"freemarker.template.TemplateCollectionModel", //NOI18N |
156 |
"freemarker.template.WrappingTemplateModel", //NOI18N |
157 |
"com.sun.tools.javac.api.JavacTool", //NOI18N |
158 |
"javax.tools.Diagnostic", //NOI18N |
159 |
"java.beans.MethodDescriptor", //NOI18N |
160 |
"java.beans.GenericBeanInfo", //NOI18N |
161 |
"javax.lang.model.type.TypeMirror", //NOI18N |
162 |
"javax.lang.model.type.PrimitiveType", //NOI18N |
163 |
"org.netbeans.modules.editor.guards.GuardedWriter", //NOI18N |
164 |
"org.netbeans.modules.editor.guards.GuardedReader", //NOI18N |
165 |
"org.netbeans.api.editor.guards.GuardedSectionManager", //NOI18N |
166 |
"org.netbeans.modules.vmd.api.model.VersionDescriptor", //NOI18N |
167 |
"org.netbeans.modules.vmd.midp.components.MidpVersionDescriptor", //NOI18N |
168 |
"org.netbeans.modules.palette.ui.AutoscrollSupport", //NOI18N |
169 |
"org.apache.lucene.index.IndexCommitPoint", //NOI18N |
170 |
"org.netbeans.modules.mobility.project.ui.ConfigurationsProvider", //NOI18N |
171 |
"org.netbeans.modules.mobility.deployment.ricoh.RicohDeploymentProperties", //NOI18N |
172 |
"org.netbeans.modules.xml.text.indent.DTDFormatter", //NOI18N |
173 |
"org.netbeans.editor.TokenItem", //NOI18N |
174 |
"org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties$PropertyInfo", //NOI18N |
175 |
"org.netbeans.modules.mobility.project.ui.customizer.CustomizerAbilities", //NOI18N |
176 |
"org.netbeans.modules.profiler.HistoryListener", //NOI18N |
177 |
"org.netbeans.modules.profiler.SaveViewAction$ViewProvider", //NOI18N |
178 |
"org.netbeans.modules.profiler.LiveResultsWindow", //NOI18N |
179 |
"org.netbeans.lib.profiler.ui.memory.MemoryResUserActionsHandler", //NOI18N |
180 |
"org.netbeans.lib.profiler.ui.cpu.CPUResUserActionsHandler", //NOI18N |
181 |
"org.netbeans.lib.profiler.ui.LiveResultsPanel", //NOI18N |
182 |
"org.netbeans.api.visual.widget.Widget", //NOI18N |
183 |
"org.netbeans.api.visual.widget.Scene", //NOI18N |
184 |
"org.netbeans.api.visual.model.ObjectScene", //NOI18N |
185 |
"org.netbeans.api.visual.graph.GraphPinScene", //NOI18N |
186 |
"org.netbeans.modules.vmd.api.flow.visual.FlowScene", //NOI18N |
187 |
"org.netbeans.modules.visual.widget.WidgetAccessibleContext", //NOI18N |
188 |
"org.netbeans.api.visual.action.TwoStateHoverProvider", //NOI18N |
189 |
"org.netbeans.modules.debugger.jpda.projects.BreakpointAnnotationProvider", //NOI18N |
190 |
"java.awt.TexturePaint", //NOI18N |
191 |
"org.netbeans.modules.visual.widget.SatelliteComponent", //NOI18N |
192 |
"org.netbeans.api.visual.widget.SceneComponent", //NOI18N |
193 |
"org.netbeans.api.visual.action.SelectProvider", //NOI18N |
194 |
"org.netbeans.api.visual.action.HoverProvider", //NOI18N |
195 |
"org.netbeans.api.visual.widget.LayerWidget", //NOI18N |
196 |
"org.netbeans.api.visual.action.MoveProvider", //NOI18N |
197 |
"org.netbeans.api.visual.action.AcceptProvider", //NOI18N |
198 |
"org.netbeans.api.visual.action.ConnectDecorator", //NOI18N |
199 |
"org.netbeans.api.visual.action.ConnectProvider", //NOI18N |
200 |
"org.netbeans.api.visual.action.ReconnectDecorator", //NOI18N |
201 |
"org.netbeans.api.visual.action.ReconnectProvider", //NOI18N |
202 |
"org.netbeans.api.visual.action.TextFieldInplaceEditor", //NOI18N |
203 |
"org.netbeans.api.visual.action.EditProvider", //NOI18N |
204 |
"org.netbeans.api.visual.action.PopupMenuProvider", //NOI18N |
205 |
"org.netbeans.api.visual.action.WidgetAction", //NOI18N |
206 |
"org.netbeans.api.visual.router.ConnectionWidgetCollisionsCollector", //NOI18N |
207 |
"org.netbeans.api.visual.graph.layout.GraphLayout", //NOI18N |
208 |
"org.netbeans.api.visual.graph.layout.GridGraphLayout", //NOI18N |
209 |
"org.netbeans.api.visual.model.ObjectSceneListener", //NOI18N |
210 |
"org.netbeans.api.visual.model.ObjectState", //NOI18N |
211 |
"org.netbeans.api.visual.action.WidgetAction$Chain", //NOI18N |
212 |
"org.netbeans.api.visual.border.BorderFactory", //NOI18N |
213 |
"org.netbeans.api.visual.border.Border", //NOI18N |
214 |
"org.netbeans.modules.visual.router.DirectRouter", //NOI18N |
215 |
"org.netbeans.modules.visual.router.FreeRouter", //NOI18N |
216 |
"org.netbeans.modules.visual.router.OrthogonalSearchRouter", //NOI18N |
217 |
"org.netbeans.modules.visual.action.MouseCenteredZoomAction", //NOI18N |
218 |
"org.netbeans.modules.visual.action.DefaultRectangularSelectDecorator", //NOI18N |
219 |
"org.netbeans.modules.visual.action.ObjectSceneRectangularSelectProvider", //NOI18N |
220 |
"org.netbeans.modules.visual.action.RectangularSelectAction", //NOI18N |
221 |
"org.netbeans.modules.visual.anchor.FreeRectangularAnchor", //NOI18N |
222 |
"org.netbeans.modules.visual.anchor.RectangularAnchor", //NOI18N |
223 |
"org.netbeans.modules.visual.anchor.CircularAnchor", //NOI18N |
224 |
"org.netbeans.modules.visual.anchor.DirectionalAnchor", //NOI18N |
225 |
"org.netbeans.modules.visual.anchor.ProxyAnchor", //NOI18N |
226 |
"org.netbeans.modules.visual.anchor.FixedAnchor", //NOI18N |
227 |
"org.netbeans.modules.visual.anchor.CenterAnchor", //NOI18N |
228 |
"org.netbeans.modules.visual.action.MouseHoverAction", //NOI18N |
229 |
"org.netbeans.modules.visual.router.OrthogonalSearchRouterCore", //NOI18N |
230 |
"org.netbeans.modules.visual.action.ForwardKeyEventsAction", //NOI18N |
231 |
"org.netbeans.api.visual.model.StateModel", //NOI18N |
232 |
"org.netbeans.modules.vmd.api.model.presenters.InfoPresenter", //NOI18N |
233 |
"org.netbeans.modules.vmd.api.model.PresenterListener", //NOI18N |
234 |
"org.netbeans.modules.vmd.api.screen.display.DeviceBorder", //NOI18N |
235 |
"org.netbeans.modules.vmd.api.screen.display.ScreenDeviceInfoPresenter", //NOI18N |
236 |
"org.netbeans.modules.vmd.midp.components.sources.EventSourceSupport", //NOI18N |
237 |
"org.apache.lucene.store.AlreadyClosedException", //NOI18N |
238 |
"org.apache.lucene.index.DirectoryIndexReader", //NOI18N |
239 |
"org.apache.lucene.index.SegmentInfos", //NOI18N |
240 |
"org.apache.lucene.index.CorruptIndexException", //NOI18N |
241 |
"org.apache.lucene.index.IndexFileNameFilter", //NOI18N |
242 |
"org.apache.lucene.index.IndexFileNames", //NOI18N |
243 |
"org.apache.lucene.search.HitCollector", //NOI18N |
244 |
"org.netbeans.modules.vmd.api.model.TransactionManager", //NOI18N |
245 |
"org.netbeans.modules.vmd.game.integration.components.GamePrimitiveDescriptor", //NOI18N |
246 |
"org.netbeans.modules.vmd.midp.components.MidpVersionDescriptor", //NOI18N |
247 |
"org.netbeans.modules.vmd.inspector.InspectorUI", //NOI18N |
248 |
"org.netbeans.modules.vmd.inspector.InspectorFolderNode", //NOI18N |
249 |
"org.netbeans.modules.vmd.inspector.InspectorBeanTreeView", //NOI18N |
250 |
"org.netbeans.api.visual.anchor.Anchor", //NOI18N |
251 |
"org.netbeans.api.visual.vmd.VMDNodeAnchor", //NOI18N |
252 |
"org.netbeans.api.visual.widget.ImageWidget", //NOI18N |
253 |
"org.netbeans.api.visual.vmd.VMDGlyphSetWidget", //NOI18N |
254 |
"org.netbeans.api.visual.widget.SeparatorWidget", //NOI18N |
255 |
"org.netbeans.api.visual.vmd.VMDFactory", //NOI18N |
256 |
"org.netbeans.api.visual.vmd.VMDColorScheme", //NOI18N |
257 |
"org.netbeans.modules.visual.vmd.VMDOriginalColorScheme", //NOI18N |
258 |
"org.netbeans.modules.visual.vmd.VMDNetBeans60ColorScheme", //NOI18N |
259 |
"org.netbeans.api.visual.vmd.VMDNodeBorder", //NOI18N |
260 |
"org.netbeans.api.visual.anchor.PointShapeFactory", //NOI18N |
261 |
"org.netbeans.api.visual.anchor.PointShape", //NOI18N |
262 |
"org.netbeans.modules.visual.anchor.ImagePointShape", //NOI18N |
263 |
"org.netbeans.modules.visual.border.CompositeBorder", //NOI18N |
264 |
"org.netbeans.modules.java.source.usages.fcs.FileChangeSupport", //NOI18N |
265 |
"org.openide.nodes.Sheet", //NOI18N |
266 |
"org.openide.explorer.propertysheet.ButtonPanel", //NOI18N |
267 |
"org.netbeans.modules.java.source.JavaFileFilterQuery", //NOI18N |
268 |
"org.netbeans.modules.java.source.parsing.FileObjects", //NOI18N |
269 |
"org.netbeans.modules.java.source.parsing.FolderArchive", //NOI18N |
270 |
"org.netbeans.modules.java.source.parsing.CachingArchive", //NOI18N |
271 |
"com.sun.javadoc.Doc", //NOI18N |
272 |
"com.sun.javadoc.ProgramElementDoc", //NOI18N |
273 |
"com.sun.javadoc.Type", //NOI18N |
274 |
"com.sun.javadoc.ClassDoc", //NOI18N |
275 |
"com.sun.javadoc.AnnotationTypeDoc", //NOI18N |
276 |
"com.sun.javadoc.DocErrorReporter", //NOI18N |
277 |
"com.sun.tools.javadoc.Messager", //NOI18N |
278 |
"com.sun.tools.javadoc.DocImpl", //NOI18N |
279 |
"com.sun.tools.javadoc.ProgramElementDocImpl", //NOI18N |
280 |
"com.sun.tools.javadoc.ClassDocImpl", //NOI18N |
281 |
"com.sun.tools.javadoc.AnnotationTypeDocImpl", //NOI18N |
282 |
"com.sun.javadoc.MemberDoc", //NOI18N |
283 |
"com.sun.javadoc.ExecutableMemberDoc", //NOI18N |
284 |
"com.sun.javadoc.MethodDoc", //NOI18N |
285 |
"org.openide.loaders.DataLdrActions", //NOI18N |
286 |
"org.openide.actions.OpenAction", //NOI18N |
287 |
"org.netbeans.core.ui.options.filetypes.OpenAsAction", //NOI18N |
288 |
"org.netbeans.core.ui.sysopen.SystemOpenAction", //NOI18N |
289 |
"org.openide.actions.RenameAction", //NOI18N |
290 |
"org.openide.actions.FileSystemAction", //NOI18N |
291 |
"org.openide.actions.FileSystemAction$Menu", //NOI18N |
292 |
"org.openide.actions.SaveAsTemplateAction", //NOI18N |
293 |
"org.openide.nodes.NodeAcceptor", //NOI18N |
294 |
}; |
295 |
} |