|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.rmi.server.RemoteObject | +--java.rmi.server.RemoteServer | +--java.rmi.server.UnicastRemoteObject | +--com.niggle.data.AbstractDataSource | +--com.niggle.data.inmemory.InMemoryIndex
An object that listens to the insert/update/delete events of a RecordManager and maintains a lookup table based on a certain field. It works for both one-to-one and one-to-many lookups The primary record manager does lookup by the uniqueID. This object does lookups by other fields such as username. MemoryDataSource finds out about changes via the DataListener interface. There is one MemoryDataSource per field indexed.
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Constructor Summary | |
InMemoryIndex()
|
|
InMemoryIndex(java.lang.String name,
java.lang.String field,
java.lang.Class cl,
boolean multipleAllowed)
A convenience constructor largely for backward compatibility. |
|
InMemoryIndex(java.lang.String name,
java.lang.String field,
RecordFilter filter,
boolean multipleAllowed)
Constructor Create an MemoryDataSource that caches on the given keyField If type is non-null, it will ignore all records that are not of this type |
Method Summary | |
void |
attach(MutableDataSource dataSource)
Called to run over a RecordManager's entire set of elements and index them. |
protected void |
cacheRecord(Record newRec)
add a record, and index it. |
void |
clear()
clear the cache -- wipe out the entire index structure. |
void |
close()
A method that should be called to free any resources associated with the data source. |
Record |
get(java.lang.String type,
java.lang.Object key)
|
java.lang.String |
getName()
|
java.util.List |
getRecords(java.lang.Object key)
Use this routine to lookup if there may be multiple records with the same key. |
void |
init(java.util.Properties props)
TODO |
java.util.List |
keys(java.lang.String type)
Return the keys to the index. |
void |
recordDeleted(DataEvent event)
Listener notified when a record has been deleted. |
void |
recordInserted(DataEvent event)
Listener notified when a record has been added. |
void |
recordUpdated(DataEvent event)
invoked when the RecordManager whose events we are listening to has just updated an existing record. |
Methods inherited from class com.niggle.data.AbstractDataSource |
get, keys |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone, exportObject, exportObject, exportObject, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
equals, getRef, hashCode, toString, toStub |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public InMemoryIndex(java.lang.String name, java.lang.String field, RecordFilter filter, boolean multipleAllowed) throws java.io.IOException
field
- the name of the field to use as the lookup keytype
- the object type to index. If this is null, we just try to index everything.multipleAllowed
- determines whether we maintain a one-to-many or one-to-one cache.public InMemoryIndex(java.lang.String name, java.lang.String field, java.lang.Class cl, boolean multipleAllowed) throws java.io.IOException
public InMemoryIndex() throws java.io.IOException
Method Detail |
public void recordUpdated(DataEvent event) throws java.io.IOException
DataListener
recordUpdated
in interface DataListener
public void recordDeleted(DataEvent event) throws java.io.IOException
recordDeleted
in interface DataListener
event
- describes the record deleted.protected void cacheRecord(Record newRec)
newRec
- the record to add.public void recordInserted(DataEvent event) throws java.io.IOException
recordInserted
in interface DataListener
event
- describes the record added.public java.util.List keys(java.lang.String type) throws java.io.IOException
java.io.IOException
- thrown in case of a low-level error.public Record get(java.lang.String type, java.lang.Object key) throws java.io.IOException
com.niggle.data.DataSource
type
- the type of the record, if this is null,
then any type will do.key
- the lookup keypublic java.util.List getRecords(java.lang.Object key) throws java.io.IOException
key
- the key on which the record is indexed.public java.lang.String getName()
getName
in class AbstractDataSource
com.niggle.data.DataSource
public void attach(MutableDataSource dataSource) throws java.io.IOException
rm
- primary record manager that contains the records.public void clear() throws java.io.IOException
public void init(java.util.Properties props) throws java.io.IOException
AbstractDataSource
init
in class AbstractDataSource
public void close() throws java.io.IOException
DataSource
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |