|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ace.repository.ext.impl.CachedRepositoryImpl
public class CachedRepositoryImpl
Provides a CachedRepository, which uses either a Repository
and a BackupRepository
as remote and local storage, or a URL location and two files, from which it will create a Repository
and a FileBasedBackupRepository
. Note that this class is not thread-safe, and should be synchronized
by the caller.
Field Summary | |
---|---|
static long |
UNCOMMITTED_VERSION
|
Constructor Summary | |
---|---|
CachedRepositoryImpl(org.osgi.service.useradmin.User user,
org.apache.ace.repository.Repository remote,
BackupRepository backup,
long mostRecentVersion)
Creates a cached repository using. |
|
CachedRepositoryImpl(org.osgi.service.useradmin.User user,
URL remote,
String customer,
String name,
File local,
File backup,
long mostRecentVersion)
Creates a cached repository which uses remote , customer and
name to create a RemoteRepository , and uses the Files s
passed in as a for local storage and backup. |
Method Summary | |
---|---|
InputStream |
checkout(boolean fail)
Checks our the most current version from the actual repository. |
InputStream |
checkout(long version)
|
boolean |
commit()
Commits the most current version to the actual repository. |
boolean |
commit(InputStream data,
long fromVersion)
|
boolean |
commit(long fromVersion)
|
InputStream |
getLocal(boolean fail)
Gets the most recent version of the object. |
long |
getMostRecentVersion()
Gets the most recent version of this repository, that is, the most recent version number that is either committed (successfully) or checked out. |
org.apache.ace.range.SortedRangeSet |
getRange()
|
boolean |
isCurrent()
Checks whether the version we have locally is current with respect to the version on the server. |
boolean |
revert()
Undoes all changes made using writeLocal() since the
last commit or checkout . |
void |
writeLocal(InputStream data)
Writes the most recent version of the object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long UNCOMMITTED_VERSION
Constructor Detail |
---|
public CachedRepositoryImpl(org.osgi.service.useradmin.User user, URL remote, String customer, String name, File local, File backup, long mostRecentVersion)
remote
, customer
and
name
to create a RemoteRepository
, and uses the Files
s
passed in as a for local storage and backup.
user
- A user object, which is allowed to access remote
.remote
- The location of the remote repository.customer
- The customer name to be used with the remote repository.name
- The name to be used with the remote repository.local
- A local file to be used for storage of changes to the repository.backup
- A local file to be used as a local backup of what was on the server.mostRecentVersion
- The version from which backup
was checked out or committed.
If no version has been committed yet, use UNCOMMITTED_VERSION
.public CachedRepositoryImpl(org.osgi.service.useradmin.User user, org.apache.ace.repository.Repository remote, BackupRepository backup, long mostRecentVersion)
user
- A user object, which is allowed to access remote
.remote
- A repository which holds committed versions.backup
- A backup repository for local changes.mostRecentVersion
- The version from which backup
was checked out or committed.
If no version has been committed yet, use UNCOMMITTED_VERSION
.Method Detail |
---|
public InputStream checkout(boolean fail) throws IOException, IllegalArgumentException
CachedRepository
checkout
in interface CachedRepository
fail
- Indicates that this method should throw an IOException when no data
is available. Setting it to false
will make it return an
empty stream in that case.
IOException
- Is thrown when the actual repository's commit does.
IllegalArgumentException
public InputStream checkout(long version) throws IOException, IllegalArgumentException
checkout
in interface org.apache.ace.repository.Repository
IOException
IllegalArgumentException
public boolean commit(InputStream data, long fromVersion) throws IOException, IllegalArgumentException
commit
in interface org.apache.ace.repository.Repository
IOException
IllegalArgumentException
public boolean commit() throws IOException
CachedRepository
commit
in interface CachedRepository
IOException
- Is thrown when the actual repository's commit does.public boolean commit(long fromVersion) throws IOException, IllegalArgumentException
IOException
IllegalArgumentException
public org.apache.ace.range.SortedRangeSet getRange() throws IOException
getRange
in interface org.apache.ace.repository.Repository
IOException
public InputStream getLocal(boolean fail) throws IllegalArgumentException, IOException
CachedRepository
getLocal
in interface CachedRepository
fail
- Indicates that this method should throw an IOException when no data
is available. Setting it to false
will make it return an
empty stream in that case.
IOException
- Thrown when there is a problem retrieving the data.
IllegalArgumentException
public boolean revert() throws IOException
CachedRepository
writeLocal()
since the
last commit
or checkout
.
revert
in interface CachedRepository
IOException
public void writeLocal(InputStream data) throws IllegalArgumentException, IOException
CachedRepository
writeLocal
in interface CachedRepository
IOException
- Thrown when there is a problem storing the data.
IllegalArgumentException
public long getMostRecentVersion()
CachedRepository
getMostRecentVersion
in interface CachedRepository
public boolean isCurrent() throws IOException
CachedRepository
isCurrent
in interface CachedRepository
IOException
- Thrown when an error occurs communicating with the server.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |