|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--org.oreodata.AbstractDataSource
A convenient base class for OreoDataSource implementations. Implements some methods that are likely to be used by most.
| Field Summary | |
protected java.lang.String |
defaultCharEncoding
The character encoding to use for XML streams |
protected java.util.Date |
lastLogRotation
time of last log rotation |
protected int |
transactionCount
Number of transactions since last log rotation |
| Fields inherited from class java.rmi.server.RemoteObject |
ref |
| Constructor Summary | |
AbstractDataSource()
Our constructor must throw the exception since the superclass's constructor does. |
|
| Method Summary | |
void |
addDataListener(DataListener dl)
Add a listener that gets notified if ever a record is inserted, updated or deleted. |
void |
close()
A method that should be called to free any resources associated with the data source. |
Record |
delete(Record rec)
Delete a record. |
Record |
delete(java.lang.String type,
java.lang.Object key)
Delete a record. |
protected void |
fireDataEvent(DataEvent event)
Fire a data event to the listeners. |
protected boolean |
fireEvents()
|
protected void |
freeze(Record rec)
This is equivalent to calling freeze(rec, true); |
protected void |
freeze(Record rec,
boolean validate)
Called to mark the record as immutable. |
Record |
get(java.lang.Object key)
|
java.lang.String |
getName()
|
void |
handleEvent(DataEvent event)
handle the event when the OreoDataSource we are listening to has modified data |
void |
init(java.util.Properties props)
A method that initializes a DataSource with a set of initialization properties. |
Record |
insert(Record rec)
Adds a new record to the managed pool. |
java.util.List |
keys()
This is equivalent to calling keys(null) where no record type is specified. |
java.util.List |
keys(java.lang.String type)
|
java.util.List |
lookup(java.lang.Object lookupKey)
Some datasources may support a multiple lookup by key functionality. |
protected void |
markStale(Record rec)
Mark the record as "stale". |
protected static java.lang.Object |
normalizeKey(java.lang.String type,
java.lang.String key)
|
void |
reload(org.xml.sax.InputSource input)
loads data from an InputSource, meant to be used in a startup phase. |
void |
reload(Record rec)
loads a Record without any notification to listeners or any synchronization. |
void |
removeDataListener(DataListener dl)
Remove a listener that gets notified if ever a record is inserted, updated or deleted. |
java.util.List |
select(RecordFilter filter)
This is equivalent to calling select(filter, null) |
java.util.List |
select(RecordFilter filter,
RecordComparator comparator)
Fetches a list of records matching filter. |
protected void |
setFireEvents(boolean fireEvents)
|
protected void |
setUseXML(boolean useXML)
|
Record |
update(Record oldRec,
Record newRec)
Replaces an existing version of a record with a new updated version. |
protected boolean |
useXML()
|
void |
wipeCache()
If this data source is backed by some external mechanism, like an RDBMS, wipes the in-memory cache, if one is being maintained. |
void |
writeElement(java.io.Writer writer,
java.lang.String type,
java.lang.Object key,
boolean recurse)
This is used to write out an XML tree. |
void |
writeSnapshot(java.io.OutputStream out)
This method outputs the entire contents of the data source as an XML tree. |
| 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 |
| Methods inherited from interface org.oreodata.OreoDataSource |
get |
| Field Detail |
protected java.lang.String defaultCharEncoding
protected int transactionCount
protected java.util.Date lastLogRotation
| Constructor Detail |
public AbstractDataSource()
throws java.io.IOException
| Method Detail |
public void addDataListener(DataListener dl)
OreoDataSource
addDataListener in interface OreoDataSourcedl - the listenerpublic void removeDataListener(DataListener dl)
OreoDataSource
removeDataListener in interface OreoDataSourcedl - the listener
protected void fireDataEvent(DataEvent event)
throws java.io.IOException
java.io.IOException
protected void freeze(Record rec,
boolean validate)
throws java.io.IOException
rec - the Record to freezevalidate - You can make this true if you don't want validation to take place.
Be careful with this. You might use this if you are absolutely sure that there
is no way that the data you are slurping in could be invalid. Thus you avoid
superfluous checks.
java.io.IOException
protected final void freeze(Record rec)
throws java.io.IOException
java.io.IOExceptionprotected void markStale(Record rec)
protected static java.lang.Object normalizeKey(java.lang.String type,
java.lang.String key)
throws java.io.IOException
java.io.IOException
public void handleEvent(DataEvent event)
throws java.io.IOException
DataListener
handleEvent in interface DataListenerjava.io.IOException
public void writeSnapshot(java.io.OutputStream out)
throws java.io.IOException
writeSnapshot in interface OreoDataSourcejava.io.IOException
public void writeElement(java.io.Writer writer,
java.lang.String type,
java.lang.Object key,
boolean recurse)
throws java.io.IOException
writeElement in interface OreoDataSourcewriter - the character stream to write to.type - the record type.key - the primary key of the record.recurse - whether to write out the child elements recursively (if
this applies)
java.io.IOException
public void reload(org.xml.sax.InputSource input)
throws org.xml.sax.SAXException,
java.io.IOException
OreoDataSource
reload in interface OreoDataSourceorg.xml.sax.SAXException
java.io.IOExceptionprotected void setUseXML(boolean useXML)
protected boolean useXML()
protected boolean fireEvents()
protected void setFireEvents(boolean fireEvents)
public java.lang.String getName()
throws java.io.IOException
getName in interface OreoDataSourcejava.io.IOException
public void init(java.util.Properties props)
throws java.io.IOException
OreoDataSource
init in interface OreoDataSourcejava.io.IOException
public final Record get(java.lang.Object key)
throws java.io.IOException
get in interface OreoDataSourcekey - the lookup key
method that exists for backward compatibility
This is equivalent to get(null, key);
java.io.IOException
public final java.util.List keys()
throws java.io.IOException
OreoDataSource
keys in interface OreoDataSourcejava.io.IOException
public void wipeCache()
throws java.io.IOException
OreoDataSource
wipeCache in interface OreoDataSourcejava.io.IOException
public void close()
throws java.io.IOException
OreoDataSource
close in interface OreoDataSourcejava.io.IOException
public final java.util.List select(RecordFilter filter)
throws java.io.IOException
OreoDataSourceselect(filter, null)
select in interface OreoDataSourcejava.io.IOException
public java.util.List select(RecordFilter filter,
RecordComparator comparator)
throws java.io.IOException
OreoDataSource
select in interface OreoDataSourcefilter - the record filter, or null.comparator - defines an ordering for the records.
java.io.IOException
public Record insert(Record rec)
throws java.io.IOException
OreoDataSource
insert in interface OreoDataSourcerec - the record to add
java.io.IOException - if the record cannot be
initialized (i.e. has missing fields or invalid
field values, etc.), or in case of a low-level error.
public Record update(Record oldRec,
Record newRec)
throws java.io.IOException
OreoDataSource
update in interface OreoDataSourceoldRec - the record to replace.newRec - the new record.
java.io.IOException - thrown in case of any other database or
communication error.
public Record delete(Record rec)
throws java.io.IOException
OreoDataSource
delete in interface OreoDataSourcerec - the record to delete.
java.io.IOException
public Record delete(java.lang.String type,
java.lang.Object key)
throws java.io.IOException
OreoDataSource
delete in interface OreoDataSourcetype - the type of the record, if this is null,
then any type will do.key - the primary key of the record to delete.
java.io.IOException
public java.util.List keys(java.lang.String type)
throws java.io.IOException
keys in interface OreoDataSourcetype - the record type we are interested,
under some circumstances, this may be null.
java.io.IOException
public java.util.List lookup(java.lang.Object lookupKey)
throws java.io.IOException
OreoDataSource
lookup in interface OreoDataSourcejava.io.IOException
public void reload(Record rec)
throws java.io.IOException
OreoDataSource
reload in interface OreoDataSourcejava.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||