|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ungoverned.oscar.util.DefaultBundleCache
public class DefaultBundleCache
This class, combined with DefaultBundleArchive, implements the default file system-based bundle cache for Oscar. It is possible to configure the default behavior of this class by setting system properties or passing properties into Oscar's constructor. The configuration properties for this class are:
For specific information on how to configure Oscar using system properties, refer to the Oscar usage documentation.
DefaultBundleArchive
Field Summary | |
---|---|
protected static int |
BUFSIZE
|
protected static java.lang.String |
BUNDLE_DIR_PREFIX
|
static java.lang.String |
CACHE_BUFSIZE_PROP
|
protected static java.lang.String |
CACHE_DIR_NAME
|
static java.lang.String |
CACHE_DIR_PROP
|
static java.lang.String |
CACHE_PROFILE_DIR_PROP
|
static java.lang.String |
CACHE_PROFILE_PROP
|
Constructor Summary | |
---|---|
DefaultBundleCache()
|
Method Summary | |
---|---|
BundleArchive |
create(long id,
java.lang.String location,
java.io.InputStream is)
Creates a new bundle archive for the specified bundle identifier using the supplied location string and input stream. |
BundleArchive |
getArchive(long id)
Returns the bundle archive associated with the specified bundle indentifier. |
BundleArchive[] |
getArchives()
Returns all cached bundle archives. |
void |
initialize(Oscar oscar)
This method is called before using the BundleCache implementation to initialize it and to pass it a reference to its associated Oscar instance. |
void |
purge(BundleArchive ba)
Purges all old revisions of the specified bundle from the cache. |
void |
remove(BundleArchive ba)
Removes the specified bundle from the cache. |
void |
update(BundleArchive ba,
java.io.InputStream is)
Saves an updated revision of the specified bundle to the bundle cache using the supplied input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CACHE_BUFSIZE_PROP
public static final java.lang.String CACHE_DIR_PROP
public static final java.lang.String CACHE_PROFILE_DIR_PROP
public static final java.lang.String CACHE_PROFILE_PROP
protected static transient int BUFSIZE
protected static final transient java.lang.String CACHE_DIR_NAME
protected static final transient java.lang.String BUNDLE_DIR_PREFIX
Constructor Detail |
---|
public DefaultBundleCache()
Method Detail |
---|
public void initialize(Oscar oscar) throws java.lang.Exception
BundleCache
This method is called before using the BundleCache implementation to initialize it and to pass it a reference to its associated Oscar instance. The main purpose for passing the BundleCache implementation a reference to its Oscar instance is to allow it to use Oscar.getConfigProperty() to access system property values; the BundleCache implementation should not use System.getProperty() directly. Oscar.getConfigProperty() provides access to properties passed into the Oscar instance's constructor. If no properties were passed in to the constructor then it searches System.getProperty(). This approach allows multiple instances of Oscar to exist in memory at the same time, but for them to be configured differently. For example, an application may want two instances of Oscar, where each instance stores their cache in a different location in the file system. When using multiple instances of Oscar in memory at the same time, system properties should be avoided and all properties should be passed in to Oscar's constructor.
initialize
in interface BundleCache
oscar
- the Oscar instance associated with the bundle cache.
java.lang.Exception
- if any error occurs.public BundleArchive[] getArchives() throws java.lang.Exception
BundleCache
Returns all cached bundle archives.
getArchives
in interface BundleCache
java.lang.Exception
- if any error occurs.public BundleArchive getArchive(long id) throws java.lang.Exception
BundleCache
Returns the bundle archive associated with the specified bundle indentifier.
getArchive
in interface BundleCache
id
- the identifier of the bundle archive to retrieve.
java.lang.Exception
- if any error occurs.public BundleArchive create(long id, java.lang.String location, java.io.InputStream is) throws java.lang.Exception
BundleCache
Creates a new bundle archive for the specified bundle identifier using the supplied location string and input stream. The contents of the bundle JAR file should be read from the supplied input stream, which will not be null. The input stream is closed by the caller; the implementation is only responsible for closing streams it opens. If this method completes successfully, then it means that the initial bundle revision of the specified bundle was successfully cached.
create
in interface BundleCache
id
- the identifier of the bundle associated with the new archive.location
- the location of the bundle associated with the new archive.is
- the input stream to the bundle's JAR file.
java.lang.Exception
- if any error occurs.public void update(BundleArchive ba, java.io.InputStream is) throws java.lang.Exception
BundleCache
Saves an updated revision of the specified bundle to the bundle cache using the supplied input stream. The contents of the updated bundle JAR file should be read from the supplied input stream, which will not be null. The input stream is closed by the caller; the implementation is only responsible for closing streams it opens. Updating a bundle in the cache does not replace the current revision of the bundle, it makes a new revision available. If this method completes successfully, then it means that the number of revisions of the specified bundle has increased by one.
update
in interface BundleCache
ba
- the bundle archive of the bundle to update.is
- the input stream to the bundle's updated JAR file.
java.lang.Exception
- if any error occurs.public void purge(BundleArchive ba) throws java.lang.Exception
BundleCache
Purges all old revisions of the specified bundle from the cache. If this method completes successfully, then it means that only the most current revision of the bundle should exist in the cache.
purge
in interface BundleCache
ba
- the bundle archive of the bundle to purge.
java.lang.Exception
- if any error occurs.public void remove(BundleArchive ba) throws java.lang.Exception
BundleCache
Removes the specified bundle from the cache. If this method completes successfully, there should be no trace of the removed bundle in the cache.
remove
in interface BundleCache
ba
- the bundle archive of the bundle to remove.
java.lang.Exception
- if any error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |