net.sf.taverna.raven.repository
Interface Repository

All Known Implementing Classes:
DummyRepository, EclipseRepository, LocalRepository

public interface Repository

A local repository containing Artifact instances in various states. The repository implementation may or may not cache artifacts from the remote sites but is not required to. If it does then it should use a local directory structure compatible with that used by Maven2

Author:
Tom

Method Summary
 void addArtifact(Artifact a)
          Add a new artifact to this repository.
 void addRemoteRepository(java.net.URL repositoryURL)
          Add a reference to a remote repository to be used to fetch pom and jar files.
 void addRepositoryListener(RepositoryListener l)
          Add a listener to be notified on changes to the repository status
 Artifact artifactForClass(java.lang.Class<?> c)
          Given a Class object return the Artifact whose LocalArtifactClassLoader created it.
 java.util.List<Artifact> getArtifacts()
          Get the list of known Artifacts for this Repository
 java.util.List<Artifact> getArtifacts(ArtifactStatus s)
          Get the list of known Artifacts for this Repository with the specified ArtifactStatus
 DownloadStatus getDownloadStatus(Artifact a)
          Fetch the DownloadStatus for the given Artifact, only valid for PomFetching and JarFetching Artifact states.
 java.lang.ClassLoader getLoader(Artifact a, java.lang.ClassLoader parent)
          Get a ClassLoader for the specified artifact
 ArtifactStatus getStatus(Artifact a)
          Fetch the ArtifactStatus represengint the state of the given Artifact in this Repository, if the artifact is not found then this method will return ArtifactStatus.Unknown
 void removeRepositoryListener(RepositoryListener l)
          Remove a listener from the list of interested observers
 void update()
          Scan the status table, perform actions on each item based on the status.
 

Method Detail

addArtifact

void addArtifact(Artifact a)
Add a new artifact to this repository. If the artifact already exists no action will be taken, otherwise it will be created and given the status ArtifactStatus.Queued

Parameters:
a - Artifact to query status

addRemoteRepository

void addRemoteRepository(java.net.URL repositoryURL)
Add a reference to a remote repository to be used to fetch pom and jar files. Repositories are scanned in turn until a match is found.

Parameters:
repositoryURL -

addRepositoryListener

void addRepositoryListener(RepositoryListener l)
Add a listener to be notified on changes to the repository status


artifactForClass

Artifact artifactForClass(java.lang.Class<?> c)
                          throws ArtifactNotFoundException
Given a Class object return the Artifact whose LocalArtifactClassLoader created it. If the classloader was not an instance of LocalArtifactClassLoader an ArtifactNotFoundException is thrown

Throws:
ArtifactNotFoundException

getArtifacts

java.util.List<Artifact> getArtifacts()
Get the list of known Artifacts for this Repository

Returns:
a copy of the current list of all known Artifacts within the Repository

getArtifacts

java.util.List<Artifact> getArtifacts(ArtifactStatus s)
Get the list of known Artifacts for this Repository with the specified ArtifactStatus

Returns:
a list of all known Artifacts with the given ArtifactStatus within this Repository

getDownloadStatus

DownloadStatus getDownloadStatus(Artifact a)
                                 throws ArtifactStateException,
                                        ArtifactNotFoundException
Fetch the DownloadStatus for the given Artifact, only valid for PomFetching and JarFetching Artifact states.

Parameters:
a - Artifact to query
Returns:
DownloadStatus corresponding to the state of the download in progress for this artifact, if any. The artifact must be in the state ArtifactStatus.PomFetching or ArtifactStatus.JarFetching
Throws:
ArtifactStateException - if the artifact is not in an appropriate state
ArtifactNotFoundException

getLoader

java.lang.ClassLoader getLoader(Artifact a,
                                java.lang.ClassLoader parent)
                                throws ArtifactNotFoundException,
                                       ArtifactStateException
Get a ClassLoader for the specified artifact

Parameters:
a - The artifact to set up the classloader for
parent - Optional parent ClassLoader, may be null for no parent
Returns:
ClassLoader for the specified artifact
Throws:
ArtifactNotFoundException
ArtifactStateException

getStatus

ArtifactStatus getStatus(Artifact a)
Fetch the ArtifactStatus represengint the state of the given Artifact in this Repository, if the artifact is not found then this method will return ArtifactStatus.Unknown

Parameters:
a - Artifact to query
Returns:
ArtifactStatus corresponding to the state of the specified artifact in relation to this Repository

removeRepositoryListener

void removeRepositoryListener(RepositoryListener l)
Remove a listener from the list of interested observers


update

void update()
Scan the status table, perform actions on each item based on the status. If an item is Queued then start downloading the POM If the item has a downloaded POM then parse it, add any unknown dependencies to the status with Queued state and start downloading the jar file If the item has a jar file then traverse dependencies and determine whether all transitive dependencies are satisfied in which case mark as Ready state Repeat this until all dependencies are resolved or failed