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 class
Class 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 JSONCodec
private URLConnectionHandler
private boolean
protected static final RepositoryPlugin.DownloadListener[]
private Executor
private File
private File
(package private) final Semaphore
private final List<ResourceRepository.Listener>
private static final org.slf4j.Logger
(package private) final MultiMap<File,
RepositoryPlugin.DownloadListener> private Reporter
private static Comparator<SearchableRepository.ResourceDescriptor>
private static final long
Fields inherited from interface aQute.bnd.service.repository.ResourceRepository
FILENAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(String repoId, SearchableRepository.ResourceDescriptor rd) Add a resource descriptor to the index.void
Add a new event listener(package private) void
delete
(byte[] id) Delete a resource from the text file (not from the cache)boolean
boolean
deleteCache
(byte[] id) Delete a cache entry(package private) void
download
(SearchableRepository.ResourceDescriptor rds, File path) (package private) void
private void
event
(ResourceRepository.TYPE type, SearchableRepository.ResourceDescriptor rds, Exception exception) Dispatch the events(package private) void
fail
(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) void
ok
(RepositoryPlugin.DownloadListener[] blockers, File file) Just report success to all download listenersvoid
Remove an event listenerprivate void
save()
Save the index file.void
private void
setDirty()
Set dirty for save.void
setExecutor
(Executor executor) void
setIndexFile
(File file) void
setReporter
(Reporter processor) void
setURLConnector
(URLConnectionHandler connector) private boolean
sleep
(int i) Sleep function that does not throwInterruptedException
toString()
-
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:
filter
in interfaceResourceRepository
filter
- 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:
delete
in interfaceResourceRepository
- Throws:
Exception
-
deleteCache
Delete a cache entry- Specified by:
deleteCache
in interfaceResourceRepository
- Throws:
Exception
-
add
Add a resource descriptor to the index.- Specified by:
add
in interfaceResourceRepository
- Throws:
Exception
-
getResource
Get the file belonging to a Resource Descriptor- Specified by:
getResource
in interfaceResourceRepository
- Throws:
Exception
-
addListener
Add a new event listener- Specified by:
addListener
in 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:
getResourceDescriptor
in 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:
find
in interfaceResourceRepository
- Throws:
Exception
-
getCacheDir
- Specified by:
getCacheDir
in interfaceResourceRepository
-
toString
-