aQute.lib.deployer.obr
Class AbstractBaseOBR

java.lang.Object
  extended by aQute.lib.deployer.obr.AbstractBaseOBR
All Implemented Interfaces:
OBRIndexProvider, Plugin, RegistryPlugin, RemoteRepositoryPlugin, RepositoryPlugin
Direct Known Subclasses:
OBR

public abstract class AbstractBaseOBR
extends Object
implements RegistryPlugin, Plugin, RemoteRepositoryPlugin, OBRIndexProvider

Abstract base class for OBR-based repositories.

The repository implementation is read-only by default. To implement a writable repository, subclasses should override canWrite() and put(Jar).

Author:
Neil Bartlett

Nested Class Summary
 
Nested classes/interfaces inherited from interface aQute.bnd.service.RepositoryPlugin
RepositoryPlugin.Strategy
 
Field Summary
protected  String name
           
static String PROP_NAME
           
static String PROP_RESOLUTION_MODE
           
static String PROP_RESOLUTION_MODE_ANY
           
protected  Registry registry
           
protected  Reporter reporter
           
static String REPOSITORY_FILE_NAME
           
protected  Set<OBRResolutionMode> supportedModes
           
 
Constructor Summary
AbstractBaseOBR()
           
 
Method Summary
protected  void addResourceToIndex(Resource resource)
           
 boolean canWrite()
          Answer if this repository can be used to store files.
 File[] get(String bsn, String range)
          Return a URL to a matching version of the given bundle.
 File get(String bsn, String range, RepositoryPlugin.Strategy strategy, Map<String,String> properties)
          Return a URL to a matching version of the given bundle.
 ResourceHandle getHandle(String bsn, String range, RepositoryPlugin.Strategy strategy, Map<String,String> properties)
          Retrieve a resource handle from the repository.
protected  ResourceHandle[] getHandles(String bsn, String rangeStr)
           
 String getName()
           
 Set<OBRResolutionMode> getSupportedModes()
           
protected  void init()
           
protected  void initialiseIndexes()
          Initialize the indexes prior to main initialisation of internal data structures.
 List<String> list(String regex)
          Return a list of bsns that are present in the repository.
protected static List<URL> parseLocations(String locationsStr)
          Utility function for parsing lists of URLs.
 File put(Jar jar)
          Put a JAR file in the repository.
protected static File[] requestAll(ResourceHandle[] handles)
           
protected  void reset()
           
 void setProperties(Map<String,String> map)
          Give the plugin the remaining properties.
 void setRegistry(Registry registry)
           
 void setReporter(Reporter reporter)
          Set the current reporter.
 List<Version> versions(String bsn)
          Return a list of versions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface aQute.bnd.service.RemoteRepositoryPlugin
getCacheDirectory
 
Methods inherited from interface aQute.bnd.service.OBRIndexProvider
getOBRIndexes
 

Field Detail

PROP_NAME

public static final String PROP_NAME
See Also:
Constant Field Values

PROP_RESOLUTION_MODE

public static final String PROP_RESOLUTION_MODE
See Also:
Constant Field Values

PROP_RESOLUTION_MODE_ANY

public static final String PROP_RESOLUTION_MODE_ANY
See Also:
Constant Field Values

REPOSITORY_FILE_NAME

public static final String REPOSITORY_FILE_NAME
See Also:
Constant Field Values

registry

protected Registry registry

reporter

protected Reporter reporter

name

protected String name

supportedModes

protected Set<OBRResolutionMode> supportedModes
Constructor Detail

AbstractBaseOBR

public AbstractBaseOBR()
Method Detail

addResourceToIndex

protected void addResourceToIndex(Resource resource)

reset

protected void reset()

initialiseIndexes

protected void initialiseIndexes()
                          throws Exception
Initialize the indexes prior to main initialisation of internal data structures. This implementation does nothing, but subclasses may override if they need to perform such initialisation.

Throws:
Exception

init

protected final void init()
                   throws Exception
Throws:
Exception

setRegistry

public final void setRegistry(Registry registry)
Specified by:
setRegistry in interface RegistryPlugin

setProperties

public void setProperties(Map<String,String> map)
Description copied from interface: Plugin
Give the plugin the remaining properties. When a plugin is declared, the clause can contain extra properties. All the properties and directives are given to the plugin to use.

Specified by:
setProperties in interface Plugin
Parameters:
map - attributes and directives for this plugin's clause

get

public File[] get(String bsn,
                  String range)
           throws Exception
Description copied from interface: RepositoryPlugin
Return a URL to a matching version of the given bundle.

Specified by:
get in interface RepositoryPlugin
Parameters:
bsn - Bundle-SymbolicName of the searched bundle
range - Version range for this bundle,"latest" if you only want the latest, or null when you want all.
Returns:
A list of URLs sorted on version, lowest version is at index 0. null is returned when no files with the given bsn ould be found.
Throws:
Exception - when anything goes wrong

requestAll

protected static File[] requestAll(ResourceHandle[] handles)
                            throws IOException
Throws:
IOException

getHandles

protected ResourceHandle[] getHandles(String bsn,
                                      String rangeStr)
                               throws Exception
Throws:
Exception

setReporter

public void setReporter(Reporter reporter)
Description copied from interface: Plugin
Set the current reporter. This is called at init time. This plugin should report all errors and warnings to this reporter.

Specified by:
setReporter in interface Plugin

get

public File get(String bsn,
                String range,
                RepositoryPlugin.Strategy strategy,
                Map<String,String> properties)
         throws Exception
Description copied from interface: RepositoryPlugin
Return a URL to a matching version of the given bundle.

Specified by:
get in interface RepositoryPlugin
Parameters:
bsn - Bundle-SymbolicName of the searched bundle
range - Version range for this bundle,"latest" if you only want the latest, or null when you want all.
strategy - Get the highest or the lowest
Returns:
A list of URLs sorted on version, lowest version is at index 0. null is returned when no files with the given bsn ould be found.
Throws:
Exception - when anything goes wrong

getHandle

public ResourceHandle getHandle(String bsn,
                                String range,
                                RepositoryPlugin.Strategy strategy,
                                Map<String,String> properties)
                         throws Exception
Description copied from interface: RemoteRepositoryPlugin
Retrieve a resource handle from the repository. For all implementations of this interface, calling getFile(bsn, range, strategy, props) should always return the same result as getResource(bsn, range, strategy, props).request().

Specified by:
getHandle in interface RemoteRepositoryPlugin
Returns:
Throws:
Exception

canWrite

public boolean canWrite()
Description copied from interface: RepositoryPlugin
Answer if this repository can be used to store files.

Specified by:
canWrite in interface RepositoryPlugin
Returns:
true if writable

put

public File put(Jar jar)
         throws Exception
Description copied from interface: RepositoryPlugin
Put a JAR file in the repository.

Specified by:
put in interface RepositoryPlugin
Throws:
Exception

list

public List<String> list(String regex)
                  throws Exception
Description copied from interface: RepositoryPlugin
Return a list of bsns that are present in the repository.

Specified by:
list in interface RepositoryPlugin
Parameters:
regex - if not null, match against the bsn and if matches, return otherwise skip
Returns:
A list of bsns that match the regex parameter or all if regex is null
Throws:
Exception

versions

public List<Version> versions(String bsn)
                       throws Exception
Description copied from interface: RepositoryPlugin
Return a list of versions.

Specified by:
versions in interface RepositoryPlugin
Throws:
Exception

getName

public String getName()
Specified by:
getName in interface RepositoryPlugin
Returns:
The name of the repository

parseLocations

protected static List<URL> parseLocations(String locationsStr)
                                   throws MalformedURLException
Utility function for parsing lists of URLs.

Parameters:
locationsStr - Comma-separated list of URLs
Throws:
MalformedURLException

getSupportedModes

public Set<OBRResolutionMode> getSupportedModes()
Specified by:
getSupportedModes in interface OBRIndexProvider


Copyright © 2012 aQute SARL. All Rights Reserved.