Package i5.las2peer.classLoaders
Class ClassManager
java.lang.Object
i5.las2peer.classLoaders.ClassManager
The main class for loading classes in the las2peer environment. This ClassManager handles library registering and
resolving (i.e. loading) dependencies as well as hotplugging.
The main idea is to keep each service separate but load each needed library only once.
-
Constructor Summary
ConstructorDescriptionClassManager
(Repository[] repositories, ClassLoader platformLoader, ClassLoaderPolicy policy) create a new L2PClassLoader, which uses the given repositoriesClassManager
(Repository repository, ClassLoader platformLoader, ClassLoaderPolicy policy) create a new L2pClassLoader, which uses the given repositoryClassManager
(List<Repository> repositories, ClassLoader platformLoader, ClassLoaderPolicy policy) create a new L2PClassLoader, which uses the given repositories -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRepository
(Repository repository) Adds a repository.static final String
getPackageName
(String className) extract the package name from a class nameClass<?>
getServiceClass
(ServiceNameVersion service) get a service class in the specified version a service has to be provided in a bundle of the package containing the servicevoid
registerService
(ServiceNameVersion serviceIdentifier) Register a service with the given identifier.void
unregisterService
(ServiceNameVersion service) Unregister a service class loader.
-
Constructor Details
-
ClassManager
create a new L2pClassLoader, which uses the given repository- Parameters:
repository
- A repository to load classes fromplatformLoader
- A platform class loaderpolicy
- A class loader policy
-
ClassManager
public ClassManager(Repository[] repositories, ClassLoader platformLoader, ClassLoaderPolicy policy) create a new L2PClassLoader, which uses the given repositories- Parameters:
repositories
- A bunch of repositories to load classes fromplatformLoader
- A platform class loaderpolicy
- A class loader policy
-
ClassManager
public ClassManager(List<Repository> repositories, ClassLoader platformLoader, ClassLoaderPolicy policy) create a new L2PClassLoader, which uses the given repositories- Parameters:
repositories
- A bunch of repositories to load classes fromplatformLoader
- A platform class loaderpolicy
- A class loader policy
-
-
Method Details
-
registerService
Register a service with the given identifier.- Parameters:
serviceIdentifier
- A service name and version identifier- Throws:
ClassLoaderException
- If the library for this service could not be found
-
unregisterService
Unregister a service class loader.- Parameters:
service
- A service name and version- Throws:
NotRegisteredException
- If the library for this service could not be found
-
getServiceClass
get a service class in the specified version a service has to be provided in a bundle of the package containing the service- Parameters:
service
- A service name and version- Returns:
- a class definition of the requested service
- Throws:
ClassLoaderException
- If the library for this service could not be found
-
getPackageName
extract the package name from a class name- Parameters:
className
- A canonical class name- Returns:
- the package name of a complete class name
-
addRepository
Adds a repository. Repositories cannot be removed.- Parameters:
repository
- a repository
-