Class WidgetClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- com.hybris.cockpitng.core.persistence.packaging.CockpitClassLoader
-
- com.hybris.cockpitng.core.persistence.packaging.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.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASS_EXTENSIONprotected static CockpitJarCacheJAR_CACHEstatic java.lang.StringJAR_EXTENSION
-
Constructor Summary
Constructors Constructor Description WidgetClassLoader(java.lang.ClassLoader parent, WidgetJarLibInfo widgetLibInfo, java.lang.String rootDir, boolean resourceCacheEnabled)Constructor, seeClassLoader.WidgetClassLoader(java.lang.ClassLoader parent, java.lang.String rootDir, boolean resourceCacheEnabled)Constructor, seeClassLoader.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()protected CockpitResourceCachecreateResourceCache()Deprecated, for removal: This API element is subject to removal in a future version.since 1811
not used anymoreprotected java.lang.Class<?>findClass(java.lang.String name)protected java.lang.Class<?>findClassInDir(java.lang.String className, java.io.File rootDir)protected java.net.URLfindResource(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.InputStreamgetResourceAsStream(WidgetJarLibInfo componentInfo, java.lang.String resourceName)Reads a resource related to specified component.java.io.InputStreamgetResourceAsStream(java.lang.String resourceName)java.util.Enumeration<java.net.URL>getResources(java.lang.String resourceName)WidgetJarLibInfogetWidgetLibInfo()protected java.lang.Class<?>loadClass(java.lang.String name, boolean resolve)protected voidputClassInCache(java.lang.String name, java.lang.Class<?> c)voidreset()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
-
-
-
-
Field Detail
-
JAR_EXTENSION
public static final java.lang.String JAR_EXTENSION
- See Also:
- Constant Field Values
-
CLASS_EXTENSION
public static final java.lang.String CLASS_EXTENSION
- See Also:
- Constant Field Values
-
JAR_CACHE
protected static final CockpitJarCache JAR_CACHE
-
-
Constructor Detail
-
WidgetClassLoader
public WidgetClassLoader(java.lang.ClassLoader parent, WidgetJarLibInfo widgetLibInfo, java.lang.String rootDir, boolean resourceCacheEnabled)Constructor, seeClassLoader.- Parameters:
parent- The parent class loader.widgetLibInfo- AWidgetJarLibInfoinstance, 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, seeClassLoader.- 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
-
getWidgetLibInfo
public WidgetJarLibInfo getWidgetLibInfo()
-
getResources
public java.util.Enumeration<java.net.URL> getResources(java.lang.String resourceName) throws java.io.IOException- Overrides:
getResourcesin classjava.lang.ClassLoader- Throws:
java.io.IOException
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String resourceName)
- Overrides:
getResourceAsStreamin classjava.lang.ClassLoader
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(WidgetJarLibInfo componentInfo, java.lang.String resourceName)
Description copied from class:CockpitClassLoaderReads a resource related to specified component.- Specified by:
getResourceAsStreamin classCockpitClassLoader- Parameters:
componentInfo- component informationresourceName- relative path to resource- Returns:
- a stream to resource or
nullif resource cannot be found
-
findResource
protected java.net.URL findResource(java.lang.String resourceName)
- Overrides:
findResourcein classjava.lang.ClassLoader
-
findResources
protected java.util.Enumeration<java.net.URL> findResources(java.lang.String name) throws java.io.IOException- Overrides:
findResourcesin classjava.lang.ClassLoader- Throws:
java.io.IOException
-
loadClass
protected java.lang.Class<?> loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException- Overrides:
loadClassin classjava.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:
findClassin classjava.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.IOExceptionjava.lang.ClassNotFoundException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
reset
public void reset()
Description copied from interface:ResettableResets the something the implementation provides.- Specified by:
resetin interfaceResettable
-
-