Top Description Fields Constructors Methods
com.sun.enterprise.module.common_impl

public abstract Class AbstractRepositoryImpl

extends Object
implements Repository
Class Inheritance
All Implemented Interfaces
com.sun.enterprise.module.Repository
Known Direct Subclasses
com.sun.enterprise.module.common_impl.DirectoryBasedRepository
Imports
com.sun.enterprise.module.Repository, .ModuleDefinition, .RepositoryChangeListener, .ManifestConstants, java.io.*, java.net.URI, java.util.*, java.util.concurrent.locks.ReentrantLock, java.util.jar.Attributes, .Manifest

Partial implementation of Repository that statically enumerates all ModuleDefinition upfront.
Authors
Kohsuke Kawaguchi, Jerome Dochez, [email protected]

Field Summary

Modifier and TypeField and Description
private List<URI>
protected List<RepositoryChangeListener>
private final URI
private final ReentrantLock
private Map<ModuleId, ModuleDefinition>
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
addLibrary(URI location)

public boolean

Returns:

true if the listener was added successfully
addListener
(RepositoryChangeListener
implementation listening to this repository changes
listener
)

Implements com.sun.enterprise.module.Repository.addListener.

Add a listener to changes happening to this repository.

public ModuleDefinition
find(String name, String version)

Implements com.sun.enterprise.module.Repository.find.

Finds and returns a DefaultModuleDefinition instance for a module given the name and version constraints.

public List<ModuleDefinition>
findAll()

Implements com.sun.enterprise.module.Repository.findAll.

Returns a list of all modules available in this repository

public List<ModuleDefinition>
findAll(String name)

Implements com.sun.enterprise.module.Repository.findAll.

Finds and returns a list of all the available versions of a module given its name.

public List<URI>

Returns:

jar files location stored in this repository.
getJarLocations
()

Implements com.sun.enterprise.module.Repository.getJarLocations.

Returns the plain jar files installed in this repository.

public URI
getLocation()

Implements com.sun.enterprise.module.Repository.getLocation.

Returns the repository location

public String
getName()

Implements com.sun.enterprise.module.Repository.getName.

Returns the repository name

public void
initialize()

Implements com.sun.enterprise.module.Repository.initialize.

Initialize the repository for use.

protected ModuleDefinition
loadJar(File
Either a jar file or a directory that has the same structure as a jar file.
jar
)

Loads a jar file and builds a ModuleDefinition.

protected abstract void
loadModuleDefs(Map<ModuleId, ModuleDefinition> moduleDefs, List<URI> libraries)

Called from initialize() to load all ModuleDefinitions and libraries defintions

protected ModuleDefinition
newModuleDefinition(File
The module jar file for which ModuleDefinition will be created. Never null.
jar
,
Attributes attr)

Extensibility point for subclasses to create a different instance of ModuleDefinition.

protected void
protected void
removeLibrary(URI location)

public boolean

Returns:

true if the listener was successfully unregistered
removeListener
(RepositoryChangeListener
the previously registered listener
listener
)

Implements com.sun.enterprise.module.Repository.removeListener.

Removes a previously registered listener

public void
shutdown()

Implements com.sun.enterprise.module.Repository.shutdown.

Shutdown the repository.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

librariesback to summary
private List<URI> libraries
listenersback to summary
protected List<RepositoryChangeListener> listeners
locationback to summary
private final URI location
lockback to summary
private final ReentrantLock lock
moduleDefsback to summary
private Map<ModuleId, ModuleDefinition> moduleDefs
nameback to summary
private final String name

Constructor Detail

AbstractRepositoryImplback to summary
public AbstractRepositoryImpl(String name, URI location)

Method Detail

addback to summary
protected void add(ModuleDefinition def)
addLibraryback to summary
protected void addLibrary(URI location)
addListenerback to summary
public boolean addListener(RepositoryChangeListener listener)

Implements com.sun.enterprise.module.Repository.addListener.

Add a listener to changes happening to this repository. Repository can change during the lifetime of an execution (files added/removed/changed)

Parameters
listener:RepositoryChangeListener

implementation listening to this repository changes

Returns:boolean

true if the listener was added successfully

findback to summary
public ModuleDefinition find(String name, String version)

Implements com.sun.enterprise.module.Repository.find.

Doc from com.sun.enterprise.module.Repository.find.

Finds and returns a DefaultModuleDefinition instance for a module given the name and version constraints.

findAllback to summary
public List<ModuleDefinition> findAll()

Implements com.sun.enterprise.module.Repository.findAll.

Doc from com.sun.enterprise.module.Repository.findAll.

Returns a list of all modules available in this repository

findAllback to summary
public List<ModuleDefinition> findAll(String name)

Implements com.sun.enterprise.module.Repository.findAll.

Doc from com.sun.enterprise.module.Repository.findAll.

Finds and returns a list of all the available versions of a module given its name.

getJarLocationsback to summary
public List<URI> getJarLocations()

Implements com.sun.enterprise.module.Repository.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

Returns:List<URI>

jar files location stored in this repository.

getLocationback to summary
public URI getLocation()

Implements com.sun.enterprise.module.Repository.getLocation.

Doc from com.sun.enterprise.module.Repository.getLocation.

Returns the repository location

getNameback to summary
public String getName()

Implements com.sun.enterprise.module.Repository.getName.

Doc from com.sun.enterprise.module.Repository.getName.

Returns the repository name

initializeback to summary
public void initialize() throws IOException

Implements com.sun.enterprise.module.Repository.initialize.

Doc from com.sun.enterprise.module.Repository.initialize.

Initialize the repository for use. This need to be called at least once before any find methods is invoked.

Exceptions
IOException:
if an error occur accessing the repository
loadJarback to summary
protected ModuleDefinition loadJar(File jar) throws IOException

Loads a jar file and builds a 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.

Parameters
jar:File

Either a jar file or a directory that has the same structure as a jar file.

loadModuleDefsback to summary
protected abstract void loadModuleDefs(Map<ModuleId, ModuleDefinition> moduleDefs, List<URI> libraries) throws IOException

Called from initialize() to load all ModuleDefinitions and libraries defintions

newModuleDefinitionback to summary
protected ModuleDefinition newModuleDefinition(File jar, Attributes attr) throws IOException

Extensibility point for subclasses to create a different instance of ModuleDefinition.

Parameters
jar:File

The module jar file for which ModuleDefinition will be created. Never null.

removeback to summary
protected void remove(ModuleDefinition def)
removeLibraryback to summary
protected void removeLibrary(URI location)
removeListenerback to summary
public boolean removeListener(RepositoryChangeListener listener)

Implements com.sun.enterprise.module.Repository.removeListener.

Removes a previously registered listener

Parameters
listener:RepositoryChangeListener

the previously registered listener

Returns:boolean

true if the listener was successfully unregistered

shutdownback to summary
public void shutdown() throws IOException

Implements com.sun.enterprise.module.Repository.shutdown.

Doc from com.sun.enterprise.module.Repository.shutdown.

Shutdown the repository. After this call return, the find methods cannot be used until initialize() is called again.

Exceptions
IOException:
if an error occur accessing the repository
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.