JavaScript is disabled on your browser.
javolution.lang

Class Initializer



  • public class Initializer
    extends Object 

    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 javolution.osgi.internal.OSGiServices.initializeRealtimeClasses() 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.

     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
     }
     }

    This utility use reflection to find the classes loaded and may not be supported on all platforms.

    Version:
    5.1, July 26, 2007
    Author:
    Jean-Marie Dautelle
    • Field Detail

      • SHOW_INITIALIZED

        public static final Configurable<Boolean> SHOW_INITIALIZED
        Indicates if the class being initialized should be logged (default false).
    • Constructor Detail

      • Initializer

        public Initializer(ClassLoader classLoader)
        Creates an initializer for the specified class loader.
    • Method Detail

      • loadedClasses

        public Class<?>[] loadedClasses()
        Returns the classes loaded by the class loader of this initializer or null if not supported by the platform.
      • loadClass

        public void loadClass(Class<?> cls)
        Loads the specified class (does not perform any initialization). This method is typically used to load unreferenced classes.
      • initializeLoadedClasses

        public boolean initializeLoadedClasses()
        Initializes all the loaded classes. If the initialization leads to more classes being loaded, these classes are initialized as well (recursive process).
        Returns:
        true if initialization has been performed successfully; false otherwise.

Copyright © 2005-2013 Javolution. All Rights Reserved.

AltStyle によって変換されたページ (->オリジナル) /