Eclipse Platform
Release 3.6

org.eclipse.equinox.p2.repository.artifact.spi
Class AbstractArtifactRepository

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.equinox.p2.repository.spi.AbstractRepository<IArtifactKey>
          extended by org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository
All Implemented Interfaces:
IAdaptable, IQueryable<IArtifactKey>, IArtifactRepository, IRepository<IArtifactKey>

public abstract class AbstractArtifactRepository
extends AbstractRepository<IArtifactKey>
implements IArtifactRepository

The common base class for all artifact repository implementations. Clients must subclass this class to create their own repository implementations.

This base class provides default implementations of all methods that modify the repository. These default methods throw an exception if AbstractRepository.isModifiable() returns false. Therefore a client can implement a read-only repository by overriding only the abstract methods.

Since:
2.0

Field Summary
 
Fields inherited from interface org.eclipse.equinox.p2.repository.artifact.IArtifactRepository
CODE_RETRY
 
Fields inherited from interface org.eclipse.equinox.p2.repository.IRepository
ENABLED, NONE, PREFERENCE_NODE, PROP_COMPRESSED, PROP_DESCRIPTION, PROP_MIRRORS_BASE_URL, PROP_MIRRORS_URL, PROP_NAME, PROP_NICKNAME, PROP_PASSWORD, PROP_SYSTEM, PROP_TIMESTAMP, PROP_USERNAME, TYPE_ARTIFACT, TYPE_METADATA
 
Constructor Summary
protected AbstractArtifactRepository(IProvisioningAgent agent, String name, String type, String version, URI location, String description, String provider, Map<String,String> properties)
           
 
Method Summary
 void addDescriptor(IArtifactDescriptor descriptor)
          Add the given descriptor to the set of descriptors in this repository.
 void addDescriptors(IArtifactDescriptor[] descriptors)
          Add the given artifact descriptors to this repository
abstract  boolean contains(IArtifactDescriptor descriptor)
          Returns true if this repository contains the given descriptor.
abstract  boolean contains(IArtifactKey key)
          Returns true if this repository contains the given artifact key.
 IArtifactDescriptor createArtifactDescriptor(IArtifactKey key)
          Create an instance of IArtifactDescriptor based on the given key
 IArtifactKey createArtifactKey(String classifier, String id, Version version)
          Create an instance of IArtifactKey
 boolean equals(Object o)
           
 IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor)
          Executes a runnable against this repository.
abstract  IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor)
          Writes to the given output stream the bytes represented by the artifact descriptor.
abstract  IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key)
          Return the set of artifact descriptors describing the ways that this repository can supply the artifact associated with the given artifact key
abstract  IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor)
          Executes the given artifact requests on this byte server.
abstract  OutputStream getOutputStream(IArtifactDescriptor descriptor)
          Open an output stream to which a client can write the data for the given artifact descriptor.
 int hashCode()
           
 void removeAll()
          Remove the all keys, descriptors, and contents from this repository.
 void removeDescriptor(IArtifactDescriptor descriptor)
          Remove the given descriptor and its corresponding content in this repository.
 void removeDescriptor(IArtifactKey key)
          Remove the given key and all related content and descriptors from this repository.
 
Methods inherited from class org.eclipse.equinox.p2.repository.spi.AbstractRepository
assertModifiable, getDescription, getLocation, getName, getProperties, getProperty, getProvider, getProvisioningAgent, getType, getVersion, isModifiable, setDescription, setLocation, setName, setProperties, setProperty, setProvider, setType, setVersion
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.equinox.p2.repository.artifact.IArtifactRepository
descriptorQueryable, getRawArtifact
 
Methods inherited from interface org.eclipse.equinox.p2.repository.IRepository
getDescription, getLocation, getName, getProperties, getProperty, getProvider, getProvisioningAgent, getType, getVersion, isModifiable, setProperty
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 
Methods inherited from interface org.eclipse.equinox.p2.query.IQueryable
query
 

Constructor Detail

AbstractArtifactRepository

protected AbstractArtifactRepository(IProvisioningAgent agent,
                                     String name,
                                     String type,
                                     String version,
                                     URI location,
                                     String description,
                                     String provider,
                                     Map<String,String> properties)
Method Detail

contains

public abstract boolean contains(IArtifactDescriptor descriptor)
Description copied from interface: IArtifactRepository
Returns true if this repository contains the given descriptor.

Specified by:
contains in interface IArtifactRepository
Parameters:
descriptor - the descriptor to query
Returns:
true if the given descriptor is already in this repository

contains

public abstract boolean contains(IArtifactKey key)
Description copied from interface: IArtifactRepository
Returns true if this repository contains the given artifact key.

Specified by:
contains in interface IArtifactRepository
Parameters:
key - the key to query
Returns:
true if the given key is already in this repository

getArtifact

public abstract IStatus getArtifact(IArtifactDescriptor descriptor,
                                    OutputStream destination,
                                    IProgressMonitor monitor)
Description copied from interface: IArtifactRepository
Writes to the given output stream the bytes represented by the artifact descriptor. Any processing steps defined by the descriptor will be applied to the artifact bytes before they are sent to the provided output stream.

Specified by:
getArtifact in interface IArtifactRepository
Parameters:
descriptor - the descriptor to transfer
destination - the stream to write the final artifact output to
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Returns:
the result of the artifact transfer

getArtifactDescriptors

public abstract IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key)
Description copied from interface: IArtifactRepository
Return the set of artifact descriptors describing the ways that this repository can supply the artifact associated with the given artifact key

Specified by:
getArtifactDescriptors in interface IArtifactRepository
Parameters:
key - the artifact key to lookup
Returns:
the descriptors associated with the given key

getArtifacts

public abstract IStatus getArtifacts(IArtifactRequest[] requests,
                                     IProgressMonitor monitor)
Description copied from interface: IArtifactRepository
Executes the given artifact requests on this byte server.

Specified by:
getArtifacts in interface IArtifactRepository
Parameters:
requests - The artifact requests
Returns:
a status object that is OK if requests were processed successfully. Otherwise, a status indicating information, warnings, or errors that occurred while executing the artifact requests

getOutputStream

public abstract OutputStream getOutputStream(IArtifactDescriptor descriptor)
                                      throws ProvisionException
Description copied from interface: IArtifactRepository
Open an output stream to which a client can write the data for the given artifact descriptor.

Specified by:
getOutputStream in interface IArtifactRepository
Parameters:
descriptor - the descriptor describing the artifact data to be written to the resultant stream
Returns:
the stream to which the artifact content can be written. The returned output stream may implement IStateful.
Throws:
ProvisionException - if the output stream could not be created. Reasons include:

addDescriptor

public void addDescriptor(IArtifactDescriptor descriptor)
Description copied from interface: IArtifactRepository
Add the given descriptor to the set of descriptors in this repository. This is a relatively low-level operation that should be used only when the actual related content is in this repository and the given descriptor accurately describes that content.

Specified by:
addDescriptor in interface IArtifactRepository
Parameters:
descriptor - the descriptor to add.

addDescriptors

public void addDescriptors(IArtifactDescriptor[] descriptors)
Description copied from interface: IArtifactRepository
Add the given artifact descriptors to this repository

Specified by:
addDescriptors in interface IArtifactRepository
Parameters:
descriptors - the artifact descriptors to add

removeDescriptor

public void removeDescriptor(IArtifactDescriptor descriptor)
Description copied from interface: IArtifactRepository
Remove the given descriptor and its corresponding content in this repository.

Specified by:
removeDescriptor in interface IArtifactRepository
Parameters:
descriptor - the descriptor to remove.

removeDescriptor

public void removeDescriptor(IArtifactKey key)
Description copied from interface: IArtifactRepository
Remove the given key and all related content and descriptors from this repository.

Specified by:
removeDescriptor in interface IArtifactRepository
Parameters:
key - the key to remove.

removeAll

public void removeAll()
Description copied from interface: IArtifactRepository
Remove the all keys, descriptors, and contents from this repository.

Specified by:
removeAll in interface IArtifactRepository

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

createArtifactDescriptor

public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key)
Description copied from interface: IArtifactRepository
Create an instance of IArtifactDescriptor based on the given key

Specified by:
createArtifactDescriptor in interface IArtifactRepository
Parameters:
key - IArtifactKey
Returns:
a new instanceof of IArtifactDescriptor

createArtifactKey

public IArtifactKey createArtifactKey(String classifier,
                                      String id,
                                      Version version)
Description copied from interface: IArtifactRepository
Create an instance of IArtifactKey

Specified by:
createArtifactKey in interface IArtifactRepository
Returns:
a new IArtifactKey

executeBatch

public IStatus executeBatch(IRunnableWithProgress runnable,
                            IProgressMonitor monitor)
Description copied from interface: IArtifactRepository
Executes a runnable against this repository. It is up to the repository implementor to determine what "batch process" means, for example, it may mean that the repository index is not stored until after the runnable completes. The runnable should not execute anything in a separate thread.

Specified by:
executeBatch in interface IArtifactRepository
Parameters:
runnable - The runnable to execute
monitor - A progress monitor that will be passed to the runnable
Returns:
The result of running the runnable. Any exceptions thrown during the execution will be returned in the status.

Eclipse Platform
Release 3.6

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.