Package org.jppf.classloader
Class AbstractJPPFClassLoaderLifeCycle
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.jppf.classloader.AbstractJPPFClassLoaderLifeCycle
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
AbstractJPPFClassLoader
This class is a custom class loader serving the purpose of dynamically loading the JPPF classes and the client
application classes, to avoid costly redeployment system-wide.
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ClassLoaderConnection<?>The connection to the driver.protected booleanDetermines whether this class loader should handle dynamic class updating.protected final org.jppf.utils.hooks.HookFactoryTo create and invoke hook instances.protected final intUniquely identifies this class loader instance.protected final org.jppf.caching.JPPFCollectionCache<String>The cache handling resources that were not found by this class loader.protected final booleanDetermines whether this class laoder is in connected mode or not.protected final AtomicBooleanDetermines whether this remote class loading is enabled.protected ResourceCacheThe cache handling resources temporarily stored to file.The unique identifier for the submitting application. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractJPPFClassLoaderLifeCycle(ClassLoaderConnection<?> connection, ClassLoader parent, List<String> uuidPath, org.jppf.utils.hooks.HookFactory hookFactory) Initialize this class loader with a parent class loader. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()protected URL[]findMultipleResources(String... names) Get multiple resources, specified by their names, from the classpath.Get the uuid of the JPPF client this class loader gets resources from.Get the connection to the driver.org.jppf.utils.hooks.HookFactoryGet the factory that creates and invoke hook instances for this node.URL[]getMultipleResources(String... names) Get multiple resources, specified by their names, from the classpath.Get the resource cache handled by this class loader.protected voidinit()Initialize the connection to the driver.booleanDetermine whether this class loader is in offline mode or not.booleanDetrmine whether remote class loading is enabled.protected org.jppf.classloader.JPPFResourceWrapperloadResource(Map<org.jppf.classloader.ResourceIdentifier, Object> map) Load the specified class from a socket connection.protected abstract voidreset()Reset and reinitialize the connection to the server.voidReset this class loader's resource cache.voidsetRemoteClassLoadingDisabled(boolean disabled) Specify whether remote class loading is disabled.toString()Methods inherited from class java.net.URLClassLoader
definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods 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, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
dynamic
protected boolean dynamicDetermines whether this class loader should handle dynamic class updating. -
uuidPath
The unique identifier for the submitting application. -
resourceCache
The cache handling resources temporarily stored to file. -
notFoundCache
The cache handling resources that were not found by this class loader. -
instanceNumber
protected final int instanceNumberUniquely identifies this class loader instance. -
connection
The connection to the driver. -
offline
protected final boolean offlineDetermines whether this class laoder is in connected mode or not. -
remoteClassLoadingDisabled
Determines whether this remote class loading is enabled.- Since:
- 4.2
-
hookFactory
protected final org.jppf.utils.hooks.HookFactory hookFactoryTo create and invoke hook instances.
-
-
Constructor Details
-
AbstractJPPFClassLoaderLifeCycle
protected AbstractJPPFClassLoaderLifeCycle(ClassLoaderConnection<?> connection, ClassLoader parent, List<String> uuidPath, org.jppf.utils.hooks.HookFactory hookFactory) Initialize this class loader with a parent class loader.- Parameters:
parent- a ClassLoader instance.connection- the connection to the driver.uuidPath- unique identifier for the submitting application.hookFactory- aHookFactoryinstance.
-
-
Method Details
-
init
protected void init()Initialize the connection to the driver. -
reset
protected abstract void reset()Reset and reinitialize the connection to the server. -
loadResource
protected org.jppf.classloader.JPPFResourceWrapper loadResource(Map<org.jppf.classloader.ResourceIdentifier, Object> map) throws ClassNotFoundExceptionLoad the specified class from a socket connection.- Parameters:
map- contains the necessary resource request data.- Returns:
- a
JPPFResourceWrappercontaining the resource content. - Throws:
ClassNotFoundException- if the class could not be loaded from the remote server.
-
addURL
- Overrides:
addURLin classURLClassLoader
-
toString
-
findMultipleResources
Get multiple resources, specified by their names, from the classpath. This method functions like #getResource(String), except that it look up and returns multiple URLs.- Parameters:
names- the names of te resources to find.- Returns:
- an array of URLs, one for each looked up resources. Some URLs may be null, however the returned array is never null, and results are in the same order as the specified resource names.
-
getMultipleResources
Get multiple resources, specified by their names, from the classpath. This method functions like #getResource(String), except that it looks up and returns multiple URLs.- Parameters:
names- the names of te resources to find.- Returns:
- an array of URLs, one for each looked up resources. Some URLs may be null, however the returned array is never null, and results are in the same order as the specified resource names.
-
getConnection
Get the connection to the driver.- Returns:
- a
ClassLoaderConnectioninstance.
-
getClientUuid
Get the uuid of the JPPF client this class loader gets resources from.- Returns:
- a client uuid as a string, or
nullif this class cloader is not a client class loader.
-
resetResourceCache
public void resetResourceCache()Reset this class loader's resource cache. This method actually clears the cache, including removing the locally stored temp files, then creates a new cache instance. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classURLClassLoader
-
isOffline
public boolean isOffline()Determine whether this class loader is in offline mode or not.- Returns:
trueif this class loader is offline,falseotherwise.
-
setRemoteClassLoadingDisabled
public void setRemoteClassLoadingDisabled(boolean disabled) Specify whether remote class loading is disabled.- Parameters:
disabled-trueto disable remote class loading,falseto enable it.- Since:
- 4.2
-
isRemoteClassLoadingDisabled
public boolean isRemoteClassLoadingDisabled()Detrmine whether remote class loading is enabled.- Returns:
trueif remote class loading is disabled,falseif enabled.- Since:
- 4.2
-
getResourceCache
Get the resource cache handled by this class loader.- Returns:
- an instance of
ResourceCache.
-
getHookFactory
public org.jppf.utils.hooks.HookFactory getHookFactory()Get the factory that creates and invoke hook instances for this node.- Returns:
- a
HookFactoryinstance.
-