SharedClassHelperFactory provides an interface that is used to create various types of SharedClassHelper for ClassLoaders.
ClassLoaders and each type of SharedClassHelpers have a one-to-one relationship.
There are 3 different types of SharedClassHelper:- SharedClassTokenHelper
Stores and finds classes using a String token generated by the ClassLoader. For use by ClassLoaders that require complete control over cache contents. - SharedClassURLHelper
Stores and finds classes using a URL location. Any URL can be used to store or find classes.
For use by ClassLoaders that do not have the concept of a classpath, which load classes from multiple locations.
Classes can only be stored using jar/zip or file URLs. Classes are automatically kept up-to-date by the cache.
Classes stored using SharedClassURLClasspathHelper can be found by using this helper, and vice versa. - SharedClassURLClasspathHelper
Stores and finds classes using a URL classpath. URLs can be appended to the classpath at any time. The classpath can also be modified under certain circumstances (see SharedClassURLClasspathHelper javadoc).
For use by ClassLoaders that load classes by using a URL classpath.
Classes can only be stored using jar/zip or file URLs. Classes are automatically kept up-to-date by the cache.
Classes stored using SharedClassURLHelper can be found using this helper, and vice versa.
-
Method Summary
Modifier and TypeMethodDescriptionfindHelperForClassLoader
(ClassLoader loader) Deprecated.Use findHelpersForClassLoader(ClassLoader loader) instead.findHelpersForClassLoader
(ClassLoader loader) Utility function that returns a set of SharedClassHelper for a given ClassLoader.getTokenHelper
(ClassLoader loader) Returns a SharedClassTokenHelper for a given ClassLoader.getTokenHelper
(ClassLoader loader, SharedClassFilter filter) Returns a SharedClassTokenHelper for a given ClassLoader.getURLClasspathHelper
(ClassLoader loader, URL[] classpath) Returns a SharedClassURLClasspathHelper for a given ClassLoader.getURLClasspathHelper
(ClassLoader loader, URL[] classpath, SharedClassFilter filter) Returns a SharedClassURLClasspathHelper for a given ClassLoader.getURLHelper
(ClassLoader loader) Returns a SharedClassURLHelper for a given ClassLoader.getURLHelper
(ClassLoader loader, SharedClassFilter filter) Returns a SharedClassURLHelper for a given ClassLoader.
-
Method Details
-
getTokenHelper
Returns a SharedClassTokenHelper for a given ClassLoader.
Creates a new SharedClassTokenHelper if one cannot be found, otherwise returns an existing SharedClassTokenHelper.
Throws a HelperAlreadyDefinedException if the ClassLoader already has a different type of helper.
Returns null if a SecurityManager is installed and there is no SharedClassPermission for the ClassLoader specified.
- Parameters:
loader
- ClassLoader. ClassLoader to which this SharedClassTokenHelper will belong- Returns:
- SharedClassTokenHelper. A new or existing SharedClassTokenHelper
- See Also:
-
getURLHelper
Returns a SharedClassURLHelper for a given ClassLoader.
Creates a new SharedClassURLHelper if one cannot be found, otherwise returns existing SharedClassURLHelper.
Throws a HelperAlreadyDefinedException if the ClassLoader already has a different type of helper.
Returns null if a SecurityManager is installed and there is no SharedClassPermission for the ClassLoader specified.
- Parameters:
loader
- ClassLoader. ClassLoader to which this SharedClassURLHelper will belong- Returns:
- SharedClassURLHelper. A new or existing SharedClassURLHelper
- See Also:
-
getURLClasspathHelper
SharedClassURLClasspathHelper getURLClasspathHelper(ClassLoader loader, URL[] classpath) throws HelperAlreadyDefinedException Returns a SharedClassURLClasspathHelper for a given ClassLoader.
Creates a new SharedClassURLClasspathHelper if one cannot be found, otherwise if the classpath specified matches the classpath of an existing helper, returns existing SharedClassURLClasspathHelper.
Throws a HelperAlreadyDefinedException if the ClassLoader already has a different type of helper, or if the ClassLoader has a SharedClassURLClasspathHelper with a different classpath.
Returns null if a SecurityManager is installed and there is no SharedClassPermission for the ClassLoader specified.
- Parameters:
loader
- ClassLoader. ClassLoader to which this SharedClassURLClasspathHelper will belongclasspath
- URL[]. The current URL classpath of this ClassLoader- Returns:
- SharedClassURLClasspathHelper. A new or existing SharedClassURLClasspathHelper
- Throws:
HelperAlreadyDefinedException
- when another SharedClassURLClasspathHelper has been already defined for this class loader- See Also:
-
findHelperForClassLoader
@Deprecated(forRemoval=false, since="9") SharedClassHelper findHelperForClassLoader(ClassLoader loader) Deprecated.Use findHelpersForClassLoader(ClassLoader loader) instead.Utility function that returns a SharedClassHelper for a given ClassLoader.
Can be used to determine whether a given ClassLoader already has a helper, before calling a getter method.
Returns an existing SharedClassHelper or null.
- Parameters:
loader
- ClassLoader. ClassLoader which may or may not have a SharedClassHelper- Returns:
- SharedClassHelper. A helper if one exists for this ClassLoader or null otherwise.
- Throws:
IllegalStateException
- If this ClassLoader has more than one helper.- See Also:
-
findHelpersForClassLoader
Utility function that returns a set of SharedClassHelper for a given ClassLoader.
Can be used to determine whether a given ClassLoader already has a specific helper, before calling a getter method.
- Parameters:
loader
- ClassLoader. ClassLoader which may or may not have a SharedClassHelper- Returns:
- Set<SharedClassHelper>. A set of helpers exist for this ClassLoader.
- See Also:
-