Module org.glassfish.hk2.core
Class AbstractRepositoryImpl
java.lang.Object
com.sun.enterprise.module.common_impl.AbstractRepositoryImpl
- All Implemented Interfaces:
Repository
- Direct Known Subclasses:
DirectoryBasedRepository
Partial implementation of
Repository
that statically enumerates all ModuleDefinition
upfront.- Author:
- Kohsuke Kawaguchi, Jerome Dochez, Sanjeeb.Sahoo@Sun.COM
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadd(ModuleDefinition def) protected voidaddLibrary(URI location) booleanaddListener(RepositoryChangeListener listener) Add a listener to changes happening to this repository.Finds and returns aDefaultModuleDefinitioninstance for a module given the name and version constraints.findAll()Returns a list of all modules available in this repositoryFinds and returns a list of all the available versions of a module given its name.Returns the plain jar files installed in this repository.Returns the repository locationgetName()Returns the repository namevoidInitialize the repository for use.protected ModuleDefinitionLoads a jar file and builds aModuleDefinition.protected abstract voidloadModuleDefs(Map<ModuleId, ModuleDefinition> moduleDefs, List<URI> libraries) Called frominitialize()to load allModuleDefinitions and libraries defintionsprotected ModuleDefinitionnewModuleDefinition(File jar, Attributes attr) Extensibility point for subclasses to create a different instance ofModuleDefinition.protected voidremove(ModuleDefinition def) protected voidremoveLibrary(URI location) booleanremoveListener(RepositoryChangeListener listener) Removes a previously registered listenervoidshutdown()Shutdown the repository.toString()
-
Field Details
-
listeners
-
-
Constructor Details
-
AbstractRepositoryImpl
-
-
Method Details
-
getName
Description copied from interface:RepositoryReturns the repository name- Specified by:
getNamein interfaceRepository- Returns:
- repository name
-
getLocation
Description copied from interface:RepositoryReturns the repository location- Specified by:
getLocationin interfaceRepository- Returns:
- the URI for the repository location
-
find
Description copied from interface:RepositoryFinds and returns aDefaultModuleDefinitioninstance for a module given the name and version constraints.- Specified by:
findin interfaceRepository- Parameters:
name- the requested module nameversion- the module version. Can be null if the caller doesn't care about the version.- Returns:
- a
DefaultModuleDefinitionor null if not found in this repository.
-
findAll
Description copied from interface:RepositoryReturns a list of all modules available in this repository- Specified by:
findAllin interfaceRepository- Returns:
- a list of available modules
-
findAll
Description copied from interface:RepositoryFinds and returns a list of all the available versions of a module given its name.- Specified by:
findAllin interfaceRepository- Parameters:
name- the requested module name
-
initialize
Description copied from interface:RepositoryInitialize the repository for use. This need to be called at least once before any find methods is invoked.- Specified by:
initializein interfaceRepository- Throws:
IOException- if an error occur accessing the repository
-
loadModuleDefs
protected abstract void loadModuleDefs(Map<ModuleId, ModuleDefinition> moduleDefs, List<URI> libraries) throws IOExceptionCalled frominitialize()to load allModuleDefinitions and libraries defintions- Throws:
IOException
-
loadJar
Loads a jar file and builds aModuleDefinition.The system allows
ModuleDefinitions to be built in any way, but in practice module jars need to be built in a way agnostic toRepositoryimplementations (so that same module could be used in differentRepositorys), so it makes sense to try to stick to the "common" loading scheme.- Parameters:
jar- Either a jar file or a directory that has the same structure as a jar file.- Throws:
IOException
-
add
-
remove
-
addLibrary
-
removeLibrary
-
shutdown
Description copied from interface:RepositoryShutdown the repository. After this call return, the find methods cannot be used until initialize() is called again.- Specified by:
shutdownin interfaceRepository- Throws:
IOException- if an error occur accessing the repository
-
toString
-
getJarLocations
Returns the plain jar files installed in this repository. Plain jar files are not modules, they do not have the module's metadata and can only be used when referenced from a module dependency list or when added to a class loader directly- Specified by:
getJarLocationsin interfaceRepository- Returns:
- jar files location stored in this repository.
-
addListener
Add a listener to changes happening to this repository. Repository can change during the lifetime of an execution (files added/removed/changed)- Specified by:
addListenerin interfaceRepository- Parameters:
listener- implementation listening to this repository changes- Returns:
- true if the listener was added successfully
-
removeListener
Removes a previously registered listener- Specified by:
removeListenerin interfaceRepository- Parameters:
listener- the previously registered listener- Returns:
- true if the listener was successfully unregistered
-
newModuleDefinition
Extensibility point for subclasses to create a different instance ofModuleDefinition.- Parameters:
jar- The module jar file for whichModuleDefinitionwill be created. Never null.- Throws:
IOException
-