Javolution 6.0.0 java
|
Public Member Functions | |
Initializer (ClassLoader classLoader) | |
Class<?>[] | loadedClasses () |
void | loadClass (Class<?> cls) |
boolean | initializeLoadedClasses () |
Static Public Attributes | |
static final Configurable< Boolean > | SHOW_INITIALIZED |
Private Attributes | |
final ClassLoader | classLoader |
An initializer for all classes loaded by any given class loader.
Initialization of classes at startup (or during bundle activation) ensures a significantly improved worst case execution time especially if the classes has configuration logic to be executed then.
Javolution activator initialize Realtime classes when started. When running outside OSGi the method
can be used to that effect..
Class loading can be performed in a lazy manner and therefore some parts of the class loading process may be done on first use rather than at load time. Javolution bundle activator ensure that all its classes are initialized at start up. The following code illustrates how this can be done for any bundle. [code] public class MyActivator implements BundleActivator { public void start(BundleContext bc) throws Exception { Initializer initializer = new Initializer(MyActivator.class.getClassLoader()); initializer.loadClass(com.foo.internal.UnreferencedClass.class); // Load explicitly classes not directly or indirectly referenced. ... initializer.initializeLoadedClasses(); // Recursive loading/initialization. ... // Continue activation } }[/code]
This utility use reflection to find the classes loaded and may not be supported on all platforms.
Definition at line 50 of file Initializer.java.
javolution.lang.Initializer.Initializer | ( | ClassLoader | classLoader | ) |
Creates an initializer for the specified class loader.
Definition at line 69 of file Initializer.java.
References javolution.lang.Initializer.classLoader.
boolean javolution.lang.Initializer.initializeLoadedClasses | ( | ) |
Initializes all the loaded classes. If the initialization leads to more classes being loaded, these classes are initialized as well (recursive process).
Definition at line 119 of file Initializer.java.
References javolution.lang.Initializer.classLoader, javolution.context.LogContext.debug(), javolution.context.LogContext.error(), javolution.lang.Configurable< T >.get(), javolution.lang.Initializer.loadedClasses(), and javolution.lang.Initializer.SHOW_INITIALIZED.
Referenced by javolution.osgi.internal.OSGiServices.initializeRealtimeClasses().
void javolution.lang.Initializer.loadClass | ( | Class<?> | cls | ) |
Loads the specified class (does not perform any initialization). This method is typically used to load unreferenced classes.
Definition at line 103 of file Initializer.java.
References javolution.lang.Initializer.classLoader, and javolution.context.LogContext.debug().
Referenced by javolution.osgi.internal.OSGiServices.initializeRealtimeClasses().
Class<?> [] javolution.lang.Initializer.loadedClasses | ( | ) |
Returns the classes loaded by the class loader of this initializer or null
if not supported by the platform.
Definition at line 78 of file Initializer.java.
References javolution.lang.Initializer.classLoader.
Referenced by javolution.lang.Initializer.initializeLoadedClasses().
|
private |
The class loader for this initializer
Definition at line 64 of file Initializer.java.
Referenced by javolution.lang.Initializer.initializeLoadedClasses(), javolution.lang.Initializer.Initializer(), javolution.lang.Initializer.loadClass(), and javolution.lang.Initializer.loadedClasses().
|
static |
Indicates if the class being initialized should be logged (default
).
Definition at line 56 of file Initializer.java.
Referenced by javolution.lang.Initializer.initializeLoadedClasses().