Package aQute.bnd.resource.repository
Class ResourceRepositoryImpl
java.lang.Object
aQute.bnd.resource.repository.ResourceRepositoryImpl
- All Implemented Interfaces:
ResourceRepository
This class implements a hidden repository. This repo is kept in a text file
that is under scm control. Files are fetched on demand. The idea is that bnd
will bootstrap from this repo and downloads plugins. These plugins then
provide faces on this hidden repository.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass maintains the info stored in the text file in the cnf directory that holds our contents.Nested classes/interfaces inherited from interface aQute.bnd.service.repository.ResourceRepository
ResourceRepository.Listener, ResourceRepository.ResourceRepositoryEvent, ResourceRepository.TYPE -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File(package private) static JSONCodecprivate URLConnectionHandlerprivate booleanprotected static final RepositoryPlugin.DownloadListener[]private Executorprivate Fileprivate File(package private) final Semaphoreprivate final List<ResourceRepository.Listener>private static final org.slf4j.Logger(package private) final MultiMap<File,RepositoryPlugin.DownloadListener> private Reporterprivate static Comparator<SearchableRepository.ResourceDescriptor>private static final longFields inherited from interface aQute.bnd.service.repository.ResourceRepository
FILENAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(String repoId, SearchableRepository.ResourceDescriptor rd) Add a resource descriptor to the index.voidAdd a new event listener(package private) voiddelete(byte[] id) Delete a resource from the text file (not from the cache)booleanbooleandeleteCache(byte[] id) Delete a cache entry(package private) voiddownload(SearchableRepository.ResourceDescriptor rds, File path) (package private) voidprivate voidevent(ResourceRepository.TYPE type, SearchableRepository.ResourceDescriptor rds, Exception exception) Dispatch the events(package private) voidfail(Exception e, RepositoryPlugin.DownloadListener[] blockers, File file) List the resources.find(String repoId, String bsn, VersionRange range) getCacheDir(String name) getIndex()Get the index, load it if necessarygetResource(byte[] rd, RepositoryPlugin.DownloadListener... blockers) Get the file belonging to a Resource DescriptorgetResourceDescriptor(byte[] rd) List the resources.(package private) voidok(RepositoryPlugin.DownloadListener[] blockers, File file) Just report success to all download listenersvoidRemove an event listenerprivate voidsave()Save the index file.voidprivate voidsetDirty()Set dirty for save.voidsetExecutor(Executor executor) voidsetIndexFile(File file) voidsetReporter(Reporter processor) voidsetURLConnector(URLConnectionHandler connector) private booleansleep(int i) Sleep function that does not throwInterruptedExceptiontoString()
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
RESOURCE_DESCRIPTOR_COMPARATOR
-
THRESHOLD
private static final long THRESHOLD- See Also:
-
EMPTY_LISTENER
-
codec
-
listeners
-
dirty
private boolean dirty -
index
-
failures
-
cache
-
hosting
-
reporter
-
executor
-
indexFile
-
connector
-
queues
-
limitDownloads
-
-
Constructor Details
-
ResourceRepositoryImpl
public ResourceRepositoryImpl()
-
-
Method Details
-
filter
List the resources. We skip the filter for now.- Specified by:
filterin interfaceResourceRepositoryfilter- An OSGi filter matched against theSearchableRepository.ResourceDescriptor- Returns:
- an immutable list of resource descriptors
- Throws:
Exception
-
delete
Delete a resource from the text file (not from the cache)- Throws:
Exception
-
delete
- Specified by:
deletein interfaceResourceRepository- Throws:
Exception
-
deleteCache
Delete a cache entry- Specified by:
deleteCachein interfaceResourceRepository- Throws:
Exception
-
add
Add a resource descriptor to the index.- Specified by:
addin interfaceResourceRepository- Throws:
Exception
-
getResource
Get the file belonging to a Resource Descriptor- Specified by:
getResourcein interfaceResourceRepository- Throws:
Exception
-
addListener
Add a new event listener- Specified by:
addListenerin interfaceResourceRepository
-
removeListener
Remove an event listener -
setDirty
private void setDirty()Set dirty for save. Save is a noop if not dirty -
getResourceDescriptor
List the resources. We skip the filter for now.- Specified by:
getResourceDescriptorin interfaceResourceRepository- Throws:
Exception
-
ok
Just report success to all download listeners- Parameters:
blockers-file-
-
fail
-
download
- Throws:
Exception
-
download0
- Throws:
Exception
-
event
private void event(ResourceRepository.TYPE type, SearchableRepository.ResourceDescriptor rds, Exception exception) Dispatch the events- Parameters:
type-rds-exception-
-
sleep
private boolean sleep(int i) Sleep function that does not throwInterruptedException- Parameters:
i-
-
save
Save the index file.- Throws:
Exception
-
getIndex
Get the index, load it if necessary- Throws:
Exception
-
setReporter
-
setIndexFile
-
setCache
-
setExecutor
- Throws:
Exception
-
setURLConnector
- Throws:
Exception
-
find
public SortedSet<SearchableRepository.ResourceDescriptor> find(String repoId, String bsn, VersionRange range) throws Exception - Specified by:
findin interfaceResourceRepository- Throws:
Exception
-
getCacheDir
- Specified by:
getCacheDirin interfaceResourceRepository
-
toString
-