T
- the resource reference typepublic abstract class AbstractResourceScavenger<T> extends Object implements ResourceScavenger<T>
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_RESOURCE_ID
Resource identifier in one resource mode.
|
Constructor and Description |
---|
AbstractResourceScavenger(File scavengeLocation,
String instanceLocPath)
Create a scavenger instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowAddResource()
Determines if adding a resource generally is allowed/possible.
|
void |
deleteResource(String resourceId)
Delete the resource with the given identifier.
|
File |
getHuntingGrounds()
Get the scavenger's hunting grounds.
|
T |
getReference(String resourceId)
Get the resource reference with the given identifier.
|
Set<String> |
getResources()
Get the identifiers of the available resources.
|
protected abstract T |
loadReference(File resourceFolder,
String resourceFileName,
String resourceId)
Load a resource reference.
|
protected abstract void |
onAdd(T reference,
String resourceId)
Called when a resource has been added, either when adding the resource on
the first scan or if it was added afterwards.
|
protected abstract void |
onRemove(T reference,
String resourceId)
Called when a resource has been removed.
|
void |
releaseResourceId(String resourceId)
Release a previously reserved resource identifier.
|
Pair<String,File> |
reserveResource(String desiredId)
Reserve a resource identifier, if the desired identifier is already
taken, an identifier will be generated.
|
File |
reserveResourceId(String resourceId)
Reserve a resource identifier, e.g.
|
void |
triggerScan()
Check if there are any new projects available.
|
protected abstract void |
updateResource(T reference,
String resourceId)
Called when an existing resource is visited during a scan.
|
public static final String DEFAULT_RESOURCE_ID
public AbstractResourceScavenger(File scavengeLocation, String instanceLocPath)
triggerScan()
after to initialize the scavenger.scavengeLocation
- the location to scan, if the location does not
exist or is not accessible, a default location inside the
platform instance location is usedinstanceLocPath
- the instance location sub-path to use if the
scavengeLocation is invalid or null
, may be
null
if the platform instance location should not
be used as fall-backpublic void triggerScan()
ResourceScavenger
triggerScan
in interface ResourceScavenger<T>
ResourceScavenger.triggerScan()
protected abstract void onAdd(T reference, String resourceId)
reference
- the resource referenceresourceId
- the resource identifierprotected abstract void onRemove(T reference, String resourceId)
reference
- the resource referenceresourceId
- the resource identifierprotected abstract void updateResource(T reference, String resourceId)
reference
- the resource reference to updateresourceId
- the resource identifierprotected abstract T loadReference(File resourceFolder, String resourceFileName, String resourceId) throws IOException
resourceFolder
- the resource folderresourceFileName
- the name of the resource file in that folder, may
be null
if unknownresourceId
- the resource identifierIOException
- if the resource cannot be accessed or loadedpublic File reserveResourceId(String resourceId) throws ScavengerException
ResourceScavenger
reserveResourceId
in interface ResourceScavenger<T>
resourceId
- the resource identifierScavengerException
- if the resourceId is already taken/reserved or
adding new resources is not possiblepublic Pair<String,File> reserveResource(String desiredId) throws ScavengerException
ResourceScavenger
reserveResource
in interface ResourceScavenger<T>
desiredId
- the desired identifier, may be null
ScavengerException
- if adding a new resource is not possiblepublic void releaseResourceId(String resourceId)
ResourceScavenger
releaseResourceId
in interface ResourceScavenger<T>
resourceId
- the resource identifierResourceScavenger.releaseResourceId(String)
public void deleteResource(String resourceId)
ResourceScavenger
deleteResource
in interface ResourceScavenger<T>
resourceId
- the resource identifierpublic boolean allowAddResource()
ResourceScavenger
allowAddResource
in interface ResourceScavenger<T>
public Set<String> getResources()
ResourceScavenger
getResources
in interface ResourceScavenger<T>
public T getReference(String resourceId)
ResourceScavenger
getReference
in interface ResourceScavenger<T>
resourceId
- the resource identifiernull
if it does not existpublic File getHuntingGrounds()
ResourceScavenger
getHuntingGrounds
in interface ResourceScavenger<T>
Build 2013-10-07_11-27-38
Revision 99b27713a799a59a21b0b166eaaea8aaefbf125a