|
Project JXTA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.jxta.impl.cm.Cm
public final class Cm
This class implements a limited document caching mechanism intended to provide cache for services that have a need for cache to search and exchange jxta documents. Only Core Services are intended to use this mechanism.
| Field Summary | |
|---|---|
static long |
DEFAULT_GC_MAX_INTERVAL
|
protected File |
rootDir
file descriptor for the root of the cm |
static File |
ROOTDIRBASE
the name we will use for the base directory |
| Constructor Summary | |
|---|---|
Cm(String areaName,
boolean enableOptimize)
Constructor for cm |
|
Cm(ThreadGroup threads,
String areaName,
boolean enableOptimize,
long gcinterval,
boolean trackDeltas)
Constructor for cm |
|
| Method Summary | |
|---|---|
static String |
createTmpName(StructuredDocument doc)
Generates a random file name using doc hashcode |
void |
garbageCollect()
|
Vector |
getDeltas(String dn)
returns all entries that are added since this method was last called |
Vector |
getEntries(String dn,
boolean clearDeltas)
returns all entries that are cached |
long |
getExpirationtime(String dn,
String fn)
Returns the maximum duration in milliseconds for which this document should cached by those other than the publisher. |
protected static IndexQuery |
getIndexQuery(String value)
|
InputStream |
getInputStream(String dn,
String fn)
Returns the inputStream of a specified file, in a specified dir |
long |
getLifetime(String dn,
String fn)
Returns the relative time in milliseconds at which the file will expire. |
Vector |
getRecords(String dn,
int threshold,
Vector values,
Vector expirations)
Gets the list of all the files into the given folder |
Vector |
getRecords(String dn,
int threshold,
Vector values,
Vector expirations,
boolean purge)
|
void |
remove(String dn,
String fn)
Remove a file |
StructuredDocument |
restore(String dn,
String fn)
Restore a saved StructuredDocument. |
byte[] |
restoreBytes(String dn,
String fn)
Restore an advetisement into a byte array. |
void |
run()
|
void |
save(String dn,
String fn,
Advertisement adv)
Stores a StructuredDocument in specified dir, and file name |
void |
save(String dn,
String fn,
Advertisement adv,
long lifetime,
long expiration)
Stores a StructuredDocument in specified dir, and file name, and associated doc timeouts |
void |
save(String dn,
String fn,
byte[] data,
long lifetime,
long expiration)
Store some bytes in specified dir, and file name, and associated doc timeouts |
Vector |
search(String dn,
String attribute,
String value,
int threshold,
Vector expirations)
Search and recovers documents that contains at least a macthing pair of tag/value. |
void |
setTrackDeltas(boolean trackDeltas)
|
void |
stop()
stop the cm |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final File ROOTDIRBASE
public static final long DEFAULT_GC_MAX_INTERVAL
protected File rootDir
| Constructor Detail |
|---|
public Cm(String areaName,
boolean enableOptimize)
areaName - the name of the cm sub-dir to createenableOptimize - whether to enable indexing
NOTE: Default garbage interval once an hour
public Cm(ThreadGroup threads,
String areaName,
boolean enableOptimize,
long gcinterval,
boolean trackDeltas)
areaName - the name of the cm sub-dir to createenableOptimize - whether to enable indexinggcinterval - garbage collect max intervaltrackDeltas - when true deltas are tracked| Method Detail |
|---|
public String toString()
toString in class Objectpublic static String createTmpName(StructuredDocument doc)
doc - to hash to generate a unique name
public Vector getRecords(String dn,
int threshold,
Vector values,
Vector expirations)
dn - contains the name of the folder
public Vector getRecords(String dn,
int threshold,
Vector values,
Vector expirations,
boolean purge)
public void garbageCollect()
public long getLifetime(String dn,
String fn)
dn - contains the name of the folderfn - contains the name of the file
public long getExpirationtime(String dn,
String fn)
dn - contains the name of the folderfn - contains the name of the file
public InputStream getInputStream(String dn,
String fn)
throws IOException
dn - directory namefn - file name
IOException - if an I/O error occurs
public void remove(String dn,
String fn)
throws IOException
dn - directory namefn - file name
IOException - if an I/O error occurs
public StructuredDocument restore(String dn,
String fn)
throws IOException
dn - directory namefn - file name
IOException - if an I/O error occurs
was not possible.
public byte[] restoreBytes(String dn,
String fn)
throws IOException
dn - directory namefn - file name
IOException - if an I/O error occurs
public void save(String dn,
String fn,
Advertisement adv)
throws IOException
dn - directory namefn - file nameadv - Advertisement to store
IOException - if an I/O error occurs
public void save(String dn,
String fn,
Advertisement adv,
long lifetime,
long expiration)
throws IOException
dn - directory namefn - file nameadv - Advertisement to saveexpiration - document expiration time in mslifetime - document lifetime in ms
IOException - if an I/O error occurs
public void save(String dn,
String fn,
byte[] data,
long lifetime,
long expiration)
throws IOException
dn - directory namefn - file namedata - byte array to saveexpiration - document expiration time in mslifetime - document lifetime in ms
IOException - if an I/O error occursprotected static IndexQuery getIndexQuery(String value)
public Vector search(String dn,
String attribute,
String value,
int threshold,
Vector expirations)
dn - contains the name of the folder on which to
perform the searchvalue - contains the value to search on.attribute - attribute to search onthreshold - threshold
public Vector getEntries(String dn,
boolean clearDeltas)
dn - the relative dir name
public Vector getDeltas(String dn)
dn - the relative dir name
public void setTrackDeltas(boolean trackDeltas)
public void stop()
public void run()
run in interface Runnable
|
JXTA J2SE | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||