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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<RepositoryChangeListener> private final URI
private Map
<ModuleId, ModuleDefinition> private final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
add
(ModuleDefinition def) protected void
addLibrary
(URI location) boolean
addListener
(RepositoryChangeListener listener) Add a listener to changes happening to this repository.Finds and returns aDefaultModuleDefinition
instance 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 namevoid
Initialize the repository for use.protected ModuleDefinition
Loads a jar file and builds aModuleDefinition
.protected abstract void
loadModuleDefs
(Map<ModuleId, ModuleDefinition> moduleDefs, List<URI> libraries) Called frominitialize()
to load allModuleDefinition
s and libraries defintionsprotected ModuleDefinition
newModuleDefinition
(File jar, Attributes attr) Extensibility point for subclasses to create a different instance ofModuleDefinition
.protected void
remove
(ModuleDefinition def) protected void
removeLibrary
(URI location) boolean
removeListener
(RepositoryChangeListener listener) Removes a previously registered listenervoid
shutdown()
Shutdown the repository.toString()
-
Field Details
-
name
-
location
-
moduleDefs
-
libraries
-
listeners
-
-
Constructor Details
-
AbstractRepositoryImpl
-
-
Method Details
-
getName
Description copied from interface:Repository
Returns the repository name- Specified by:
getName
in interfaceRepository
- Returns:
- repository name
-
getLocation
Description copied from interface:Repository
Returns the repository location- Specified by:
getLocation
in interfaceRepository
- Returns:
- the URI for the repository location
-
find
Description copied from interface:Repository
Finds and returns aDefaultModuleDefinition
instance for a module given the name and version constraints.- Specified by:
find
in interfaceRepository
- Parameters:
name
- the requested module nameversion
- the module version. Can be null if the caller doesn't care about the version.- Returns:
- a
DefaultModuleDefinition
or null if not found in this repository.
-
findAll
Description copied from interface:Repository
Returns a list of all modules available in this repository- Specified by:
findAll
in interfaceRepository
- Returns:
- a list of available modules
-
findAll
Description copied from interface:Repository
Finds and returns a list of all the available versions of a module given its name.- Specified by:
findAll
in interfaceRepository
- Parameters:
name
- the requested module name
-
initialize
Description copied from interface:Repository
Initialize the repository for use. This need to be called at least once before any find methods is invoked.- Specified by:
initialize
in 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 allModuleDefinition
s and libraries defintions- Throws:
IOException
-
loadJar
Loads a jar file and builds aModuleDefinition
.The system allows
ModuleDefinition
s to be built in any way, but in practice module jars need to be built in a way agnostic toRepository
implementations (so that same module could be used in differentRepository
s), 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:Repository
Shutdown the repository. After this call return, the find methods cannot be used until initialize() is called again.- Specified by:
shutdown
in 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:
getJarLocations
in 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:
addListener
in 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:
removeListener
in 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 whichModuleDefinition
will be created. Never null.- Throws:
IOException
-