Class WidgetClassLoader

  • All Implemented Interfaces:
    Resettable, java.io.Closeable, java.lang.AutoCloseable

    public class WidgetClassLoader
    extends CockpitClassLoader
    implements java.io.Closeable
    Class loader for classes/resources located in a cockpit widget archive. Includes a cache for resources which can be enabled by passing the corresponding argument value in the constructor.
    • Constructor Summary

      Constructors 
      Constructor Description
      WidgetClassLoader​(java.lang.ClassLoader parent, WidgetJarLibInfo widgetLibInfo, java.lang.String rootDir, boolean resourceCacheEnabled)
      Constructor, see ClassLoader.
      WidgetClassLoader​(java.lang.ClassLoader parent, java.lang.String rootDir, boolean resourceCacheEnabled)
      Constructor, see ClassLoader.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void close()  
      protected CockpitResourceCache createResourceCache()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1811
      not used anymore
      protected java.lang.Class<?> findClass​(java.lang.String name)  
      protected java.lang.Class<?> findClassInDir​(java.lang.String className, java.io.File rootDir)  
      protected java.net.URL findResource​(java.lang.String resourceName)  
      protected java.util.Enumeration<java.net.URL> findResources​(java.lang.String name)  
      protected java.lang.Class<?> getClassFromCache​(java.lang.String name)  
      protected java.lang.Class<?> getClassFromInputStream​(java.io.InputStream inputStream, java.lang.String className)  
      java.io.InputStream getResourceAsStream​(WidgetJarLibInfo componentInfo, java.lang.String resourceName)
      Reads a resource related to specified component.
      java.io.InputStream getResourceAsStream​(java.lang.String resourceName)  
      java.util.Enumeration<java.net.URL> getResources​(java.lang.String resourceName)  
      WidgetJarLibInfo getWidgetLibInfo()  
      protected java.lang.Class<?> loadClass​(java.lang.String name, boolean resolve)  
      protected void putClassInCache​(java.lang.String name, java.lang.Class<?> c)  
      void reset()
      Resets the something the implementation provides.
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WidgetClassLoader

        public WidgetClassLoader​(java.lang.ClassLoader parent,
                                 WidgetJarLibInfo widgetLibInfo,
                                 java.lang.String rootDir,
                                 boolean resourceCacheEnabled)
        Constructor, see ClassLoader.
        Parameters:
        parent - The parent class loader.
        widgetLibInfo - A WidgetJarLibInfo instance, containing information about the cockpit widget archive in which the widget resides, or null.
        rootDir - The path to the directory where the cockpit widget archive files are located.
        resourceCacheEnabled - Whether or not to enable the built-in resource cache.
        See Also:
        CockpitApplicationContext.getClassLoader(), getResourceAsStream(WidgetJarLibInfo, String)
      • WidgetClassLoader

        public WidgetClassLoader​(java.lang.ClassLoader parent,
                                 java.lang.String rootDir,
                                 boolean resourceCacheEnabled)
        Constructor, see ClassLoader.
        Parameters:
        parent - The parent class loader.
        rootDir - The path to the directory where the cockpit widget archive files are located.
        resourceCacheEnabled - Whether or not to enable the built-in resource cache.
    • Method Detail

      • createResourceCache

        @Deprecated(since="1811",
                    forRemoval=true)
        protected CockpitResourceCache createResourceCache()
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 1811
        not used anymore
        Returns:
        cockpit cache implementation
      • getResources

        public java.util.Enumeration<java.net.URL> getResources​(java.lang.String resourceName)
                                                         throws java.io.IOException
        Overrides:
        getResources in class java.lang.ClassLoader
        Throws:
        java.io.IOException
      • getResourceAsStream

        public java.io.InputStream getResourceAsStream​(java.lang.String resourceName)
        Overrides:
        getResourceAsStream in class java.lang.ClassLoader
      • getResourceAsStream

        public java.io.InputStream getResourceAsStream​(WidgetJarLibInfo componentInfo,
                                                       java.lang.String resourceName)
        Description copied from class: CockpitClassLoader
        Reads a resource related to specified component.
        Specified by:
        getResourceAsStream in class CockpitClassLoader
        Parameters:
        componentInfo - component information
        resourceName - relative path to resource
        Returns:
        a stream to resource or null if resource cannot be found
      • findResource

        protected java.net.URL findResource​(java.lang.String resourceName)
        Overrides:
        findResource in class java.lang.ClassLoader
      • findResources

        protected java.util.Enumeration<java.net.URL> findResources​(java.lang.String name)
                                                             throws java.io.IOException
        Overrides:
        findResources in class java.lang.ClassLoader
        Throws:
        java.io.IOException
      • loadClass

        protected java.lang.Class<?> loadClass​(java.lang.String name,
                                               boolean resolve)
                                        throws java.lang.ClassNotFoundException
        Overrides:
        loadClass in class java.lang.ClassLoader
        Throws:
        java.lang.ClassNotFoundException
      • getClassFromCache

        protected java.lang.Class<?> getClassFromCache​(java.lang.String name)
      • putClassInCache

        protected void putClassInCache​(java.lang.String name,
                                       java.lang.Class<?> c)
      • findClass

        protected java.lang.Class<?> findClass​(java.lang.String name)
                                        throws java.lang.ClassNotFoundException
        Overrides:
        findClass in class java.lang.ClassLoader
        Throws:
        java.lang.ClassNotFoundException
      • findClassInDir

        protected java.lang.Class<?> findClassInDir​(java.lang.String className,
                                                    java.io.File rootDir)
                                             throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException
      • getClassFromInputStream

        protected java.lang.Class<?> getClassFromInputStream​(java.io.InputStream inputStream,
                                                             java.lang.String className)
                                                      throws java.io.IOException,
                                                             java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • reset

        public void reset()
        Description copied from interface: Resettable
        Resets the something the implementation provides.
        Specified by:
        reset in interface Resettable