public abstract class AbstractRepositoryImpl extends java.lang.Object implements Repository
Repository
that statically enumerates all ModuleDefinition
upfront.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<RepositoryChangeListener> |
listeners |
| Constructor and Description |
|---|
AbstractRepositoryImpl(java.lang.String name,
java.net.URI location) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
add(ModuleDefinition def) |
protected void |
addLibrary(java.net.URI location) |
boolean |
addListener(RepositoryChangeListener listener)
Add a listener to changes happening to this repository.
|
ModuleDefinition |
find(java.lang.String name,
java.lang.String version)
Finds and returns a
DefaultModuleDefinition instance
for a module given the name and version constraints. |
java.util.List<ModuleDefinition> |
findAll()
Returns a list of all modules available in this repository
|
java.util.List<ModuleDefinition> |
findAll(java.lang.String name)
Finds and returns a list of all the available versions of a
module given its name.
|
java.util.List<java.net.URI> |
getJarLocations()
Returns the plain jar files installed in this repository.
|
java.net.URI |
getLocation()
Returns the repository location
|
java.lang.String |
getName()
Returns the repository name
|
void |
initialize()
Initialize the repository for use.
|
protected ModuleDefinition |
loadJar(java.io.File jar)
Loads a jar file and builds a
ModuleDefinition. |
protected abstract void |
loadModuleDefs(java.util.Map<ModuleId,ModuleDefinition> moduleDefs,
java.util.List<java.net.URI> libraries)
Called from
initialize() to load all ModuleDefinitions and libraries defintions |
protected ModuleDefinition |
newModuleDefinition(java.io.File jar,
java.util.jar.Attributes attr)
Extensibility point for subclasses to create a different instance
of
ModuleDefinition. |
protected void |
remove(ModuleDefinition def) |
protected void |
removeLibrary(java.net.URI location) |
boolean |
removeListener(RepositoryChangeListener listener)
Removes a previously registered listener
|
void |
shutdown()
Shutdown the repository.
|
java.lang.String |
toString() |
protected java.util.List<RepositoryChangeListener> listeners
public AbstractRepositoryImpl(java.lang.String name,
java.net.URI location)
public java.lang.String getName()
RepositorygetName in interface Repositorypublic java.net.URI getLocation()
RepositorygetLocation in interface Repositorypublic ModuleDefinition find(java.lang.String name, java.lang.String version)
RepositoryDefaultModuleDefinition instance
for a module given the name and version constraints.find in interface Repositoryname - the requested module nameversion - the module version. Can be null if the caller doesn't care about the version.DefaultModuleDefinition or null if not found
in this repository.public java.util.List<ModuleDefinition> findAll()
RepositoryfindAll in interface Repositorypublic java.util.List<ModuleDefinition> findAll(java.lang.String name)
RepositoryfindAll in interface Repositoryname - the requested module namepublic void initialize()
throws java.io.IOException
Repositoryinitialize in interface Repositoryjava.io.IOException - if an error occur accessing the repositoryprotected abstract void loadModuleDefs(java.util.Map<ModuleId,ModuleDefinition> moduleDefs, java.util.List<java.net.URI> libraries) throws java.io.IOException
initialize() to load all ModuleDefinitions and libraries defintionsjava.io.IOExceptionprotected ModuleDefinition loadJar(java.io.File jar) throws java.io.IOException
ModuleDefinition.
The system allows ModuleDefinitions to be built in any way,
but in practice module jars need to be built in a way agnostic
to Repository implementations (so that same module could
be used in different Repositorys), so it makes sense
to try to stick to the "common" loading scheme.
jar - Either a jar file or a directory that has the same structure as a jar file.java.io.IOExceptionprotected void add(ModuleDefinition def)
protected void remove(ModuleDefinition def)
protected void addLibrary(java.net.URI location)
protected void removeLibrary(java.net.URI location)
public void shutdown()
throws java.io.IOException
Repositoryshutdown in interface Repositoryjava.io.IOException - if an error occur accessing the repositorypublic java.lang.String toString()
toString in class java.lang.Objectpublic java.util.List<java.net.URI> getJarLocations()
getJarLocations in interface Repositorypublic boolean addListener(RepositoryChangeListener listener)
addListener in interface Repositorylistener - implementation listening to this repository changespublic boolean removeListener(RepositoryChangeListener listener)
removeListener in interface Repositorylistener - the previously registered listenerprotected ModuleDefinition newModuleDefinition(java.io.File jar, java.util.jar.Attributes attr) throws java.io.IOException
ModuleDefinition.jar - The module jar file for which ModuleDefinition will be created.
Never null.java.io.IOExceptionCopyright © 2013 Oracle Corporation. All Rights Reserved.