net.sf.taverna.raven.repository.impl
Class DummyRepository

java.lang.Object
  extended by net.sf.taverna.raven.repository.impl.DummyRepository
All Implemented Interfaces:
Repository
Direct Known Subclasses:
EclipseRepository

public class DummyRepository
extends java.lang.Object
implements Repository

Nasty hack, but does allow Taverna to be run within say eclipse for the purposes of debugging and writing new code for a specific component - allowing code changes to be picked up immediately without the need to 'mvn install' and refresh the repository Cache. It does this by replacing the normal LocalRepository and enforsing that the class loader used is always the SystemClassLoader. It also returns a dummy artifact for getArtifacts(ArtifactStatus) when status is Ready, to trick the SpiRegistry into thinking there are new artifacts and thereby looks for new SPI's using teh system classloader. The use of this repository is triggered by the presence of the system property 'raven.eclipse' IMPORTANT NOTE: This is a nasty experimental hack for development purposes only and shouldn't be used to run the system for real. Any changes that *appear* to work using this Repository should also be checked by running the code outside as Eclipse.

Author:
sowen

Constructor Summary
DummyRepository()
           
 
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DummyRepository

public DummyRepository()
Method Detail

addArtifact

public void addArtifact(Artifact a)
Description copied from interface: Repository
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

Specified by:
addArtifact in interface Repository
Parameters:
a - Artifact to query status

addRemoteRepository

public void addRemoteRepository(java.net.URL repositoryURL)
Description copied from interface: Repository
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.

Specified by:
addRemoteRepository in interface Repository

addRepositoryListener

public void addRepositoryListener(RepositoryListener l)
Description copied from interface: Repository
Add a listener to be notified on changes to the repository status

Specified by:
addRepositoryListener in interface Repository

artifactForClass

public Artifact artifactForClass(java.lang.Class c)
                          throws ArtifactNotFoundException
Description copied from interface: Repository
Given a Class object return the Artifact whose LocalArtifactClassLoader created it. If the classloader was not an instance of LocalArtifactClassLoader an ArtifactNotFoundException is thrown

Specified by:
artifactForClass in interface Repository
Throws:
ArtifactNotFoundException

getArtifacts

public java.util.List<Artifact> getArtifacts()
Description copied from interface: Repository
Get the list of known Artifacts for this Repository

Specified by:
getArtifacts in interface Repository
Returns:
a copy of the current list of all known Artifacts within the Repository

getArtifacts

public java.util.List<Artifact> getArtifacts(ArtifactStatus s)
Description copied from interface: Repository
Get the list of known Artifacts for this Repository with the specified ArtifactStatus

Specified by:
getArtifacts in interface Repository
Returns:
a list of all known Artifacts with the given ArtifactStatus within this Repository

getDownloadStatus

public DownloadStatus getDownloadStatus(Artifact a)
                                 throws ArtifactStateException,
                                        ArtifactNotFoundException
Description copied from interface: Repository
Fetch the DownloadStatus for the given Artifact, only valid for PomFetching and JarFetching Artifact states.

Specified by:
getDownloadStatus in interface Repository
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

public java.lang.ClassLoader getLoader(Artifact a,
                                       java.lang.ClassLoader parent)
                                throws ArtifactNotFoundException,
                                       ArtifactStateException
Description copied from interface: Repository
Get a ClassLoader for the specified artifact

Specified by:
getLoader in interface Repository
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

public ArtifactStatus getStatus(Artifact a)
Description copied from interface: Repository
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

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

removeRepositoryListener

public void removeRepositoryListener(RepositoryListener l)
Description copied from interface: Repository
Remove a listener from the list of interested observers

Specified by:
removeRepositoryListener in interface Repository

update

public void update()
Description copied from interface: Repository
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

Specified by:
update in interface Repository