public class BlackboardImpl extends java.lang.Object implements Blackboard
Blackboard.Get
Constructor and Description |
---|
BlackboardImpl(RecordFilterHelper filterHelper)
create instance.
|
Modifier and Type | Method and Description |
---|---|
void |
commit()
commit ALL records on this blackboard to storages (if any) and release resources.
|
void |
commitRecord(java.lang.String id)
All changes are written to the storages before the record is removed.
|
Record |
filterRecord(Record record,
java.lang.String filterName)
Filter record metadata.
|
Attachment |
getAttachment(java.lang.String id,
java.lang.String name)
Gets the attachment.
|
byte[] |
getAttachmentAsBytes(java.lang.String id,
java.lang.String name)
Gets the attachment.
|
java.io.InputStream |
getAttachmentAsStream(java.lang.String id,
java.lang.String name)
Gets the attachment as stream.
|
DataFactory |
getDataFactory() |
java.io.Serializable |
getGlobalNote(java.lang.String name)
Gets the global note.
|
AnyMap |
getMetadata(java.lang.String id)
Shortcut for
Blackboard.getRecord(String) + Record.getMetadata() . |
Record |
getRecord(java.lang.String id)
Get current version of record with given ID.
|
Record |
getRecord(java.lang.String id,
Blackboard.Get mode)
get a reference to the record on the blackboard.
|
Record |
getRecord(java.lang.String id,
java.lang.String filterName)
Shortcut for
Blackboard.getRecord(String) + #filterRecord(Record, String)) : Gets the blackboard record and
applies the named filter. |
Record |
getRecordCopy(java.lang.String id,
boolean withAttachments)
get a shallow copy of the record on the blackboard.
|
java.io.Serializable |
getRecordNote(java.lang.String id,
java.lang.String name)
Gets the record note.
|
boolean |
hasAttachment(java.lang.String id,
java.lang.String name)
Checks for attachment.
|
boolean |
hasGlobalNote(java.lang.String name)
Checks for global note.
|
boolean |
hasRecordNote(java.lang.String id,
java.lang.String name)
Checks for record note.
|
void |
removeAll()
remove all records currently stored on blackboard.
|
void |
removeAttachment(java.lang.String id,
java.lang.String name)
Removes the attachment.
|
void |
removeRecord(java.lang.String id)
remove record completely from blackboard.
|
void |
setAttachment(java.lang.String id,
Attachment attachment)
Sets the attachment.
|
void |
setAttachment(java.lang.String id,
java.lang.String name,
byte[] attachment)
Sets the attachment.
|
void |
setAttachmentFromFile(java.lang.String id,
java.lang.String name,
java.io.File attachmentFile)
Sets attachment from file.
|
void |
setAttachmentFromStream(java.lang.String id,
java.lang.String name,
java.io.InputStream attachmentStream)
Sets the attachment from stream.
|
protected void |
setBinaryStorage(BinaryStorageService binaryStorage)
Set the binary service for blackboard.
|
void |
setGlobalNote(java.lang.String name,
java.io.Serializable object)
Sets the global note.
|
void |
setRecord(Record record)
Sets a record on the blackboard.
|
void |
setRecordNote(java.lang.String id,
java.lang.String name,
java.io.Serializable object)
Sets the record note.
|
protected void |
setRecordStorage(RecordStorage recordStorage)
Set the record service for blackboard.
|
void |
synchronizeRecord(Record record)
Synchronize: copy all attributes and attachments from the incoming record to the blackboard record with the same
ID.
|
void |
unload()
remove ALL records from blackboard and release all associated resources.
|
void |
unloadRecord(java.lang.String id)
The record is removed from the blackboard.
|
public BlackboardImpl(RecordFilterHelper filterHelper)
filterHelper
- record filter manager.public DataFactory getDataFactory()
getDataFactory
in interface Blackboard
public Record getRecord(java.lang.String id, Blackboard.Get mode) throws BlackboardAccessException
Blackboard
Blackboard.Get
for details on the
mode parameter.getRecord
in interface Blackboard
id
- the idmode
- configure behavior of method.BlackboardAccessException
public Record getRecord(java.lang.String id) throws BlackboardAccessException
Blackboard
Blackboard.getRecord(String, Get)
with Blackboard.Get.EXISTING
.
This method is usually the correct one to use in pipelets or workers to process a record.getRecord
in interface Blackboard
id
- the idBlackboardAccessException
- error accessing attached storagespublic AnyMap getMetadata(java.lang.String id) throws BlackboardAccessException
Blackboard
Blackboard.getRecord(String)
+ Record.getMetadata()
. If Blackboard.getRecord(String)
would yield
null, this method yields null, too.getMetadata
in interface Blackboard
id
- the idBlackboardAccessException
- error accessing attached storagespublic Record getRecord(java.lang.String id, java.lang.String filterName) throws RecordFilterNotFoundException, BlackboardAccessException
Blackboard
Blackboard.getRecord(String)
+ #filterRecord(Record, String))
: Gets the blackboard record and
applies the named filter.getRecord
in interface Blackboard
id
- the idfilterName
- the filter nameRecordFilterNotFoundException
- named record filter does not existBlackboardAccessException
- error accessing storages for reading the recordpublic Record filterRecord(Record record, java.lang.String filterName) throws RecordFilterNotFoundException
Blackboard
filterRecord
in interface Blackboard
record
- the recordfilterName
- the filter nameRecordFilterNotFoundException
- named record filter does not existpublic Record getRecordCopy(java.lang.String id, boolean withAttachments) throws BlackboardAccessException
Blackboard
getRecordCopy
in interface Blackboard
id
- the idBlackboardAccessException
public void setRecord(Record record) throws BlackboardAccessException
Blackboard
setRecord
in interface Blackboard
record
- the recordBlackboardAccessException
- error accessing storages for reading the record or writing attachmentspublic void synchronizeRecord(Record record) throws BlackboardAccessException
Blackboard
synchronizeRecord
in interface Blackboard
record
- the recordBlackboardAccessException
- error accessing storages for reading the record or writing attachmentspublic void removeRecord(java.lang.String id)
Blackboard
Blackboard.commit()
or Blackboard.commitRecord(String)
is called.removeRecord
in interface Blackboard
id
- record idpublic void removeAll()
Blackboard
Blackboard.commit()
or Blackboard.commitRecord(String)
is called.removeAll
in interface Blackboard
public boolean hasAttachment(java.lang.String id, java.lang.String name) throws BlackboardAccessException
Blackboard
hasAttachment
in interface Blackboard
id
- the idname
- the nameBlackboardAccessException
- error accessing storages for checkpublic Attachment getAttachment(java.lang.String id, java.lang.String name) throws BlackboardAccessException
Blackboard
getAttachment
in interface Blackboard
id
- the idname
- the nameBlackboardAccessException
- error accessing storages for reading the record or attachmentpublic byte[] getAttachmentAsBytes(java.lang.String id, java.lang.String name) throws BlackboardAccessException
Blackboard
getAttachmentAsBytes
in interface Blackboard
id
- the idname
- the nameBlackboardAccessException
- error accessing storages for reading the record or attachmentpublic java.io.InputStream getAttachmentAsStream(java.lang.String id, java.lang.String name) throws BlackboardAccessException
Blackboard
getAttachmentAsStream
in interface Blackboard
id
- the idname
- the nameBlackboardAccessException
- error accessing storages for reading the record or attachmentpublic void setAttachment(java.lang.String id, Attachment attachment) throws BlackboardAccessException
Blackboard
setAttachment
in interface Blackboard
id
- the idattachment
- the attachmentBlackboardAccessException
- error if record does not exist or on errors accessing storages for reading the record or writing the
attachmentpublic void setAttachment(java.lang.String id, java.lang.String name, byte[] attachment) throws BlackboardAccessException
Blackboard
setAttachment
in interface Blackboard
id
- the idname
- the nameattachment
- the attachmentBlackboardAccessException
- error if record does not exist or on errors accessing storages for reading the record or writing the
attachmentpublic void setAttachmentFromStream(java.lang.String id, java.lang.String name, java.io.InputStream attachmentStream) throws BlackboardAccessException
Blackboard
setAttachmentFromStream
in interface Blackboard
id
- the idname
- the nameattachmentStream
- the attachment streamBlackboardAccessException
- error if record does not exist or on errors accessing storages for reading the record or writing the
attachmentpublic void setAttachmentFromFile(java.lang.String id, java.lang.String name, java.io.File attachmentFile) throws BlackboardAccessException
Blackboard
setAttachmentFromFile
in interface Blackboard
id
- the idname
- the nameattachmentFile
- attachment fileBlackboardAccessException
- error if record does not exist or on errors accessing storages for reading the record or writing the
attachmentpublic void removeAttachment(java.lang.String id, java.lang.String name) throws BlackboardAccessException
Blackboard
removeAttachment
in interface Blackboard
id
- the idname
- the nameBlackboardAccessException
- error if record does not exist or on errors accessing storages for reading the record or deleting the
attachmentpublic boolean hasGlobalNote(java.lang.String name)
Blackboard
hasGlobalNote
in interface Blackboard
name
- the namepublic java.io.Serializable getGlobalNote(java.lang.String name)
Blackboard
getGlobalNote
in interface Blackboard
name
- the namepublic void setGlobalNote(java.lang.String name, java.io.Serializable object)
Blackboard
setGlobalNote
in interface Blackboard
name
- the nameobject
- the objectpublic boolean hasRecordNote(java.lang.String id, java.lang.String name)
Blackboard
hasRecordNote
in interface Blackboard
id
- the idname
- the namepublic java.io.Serializable getRecordNote(java.lang.String id, java.lang.String name)
Blackboard
getRecordNote
in interface Blackboard
id
- the idname
- the namepublic void setRecordNote(java.lang.String id, java.lang.String name, java.io.Serializable object)
Blackboard
setRecordNote
in interface Blackboard
id
- the idname
- the nameobject
- the objectpublic void commitRecord(java.lang.String id) throws BlackboardAccessException
Blackboard
commitRecord
in interface Blackboard
id
- the idBlackboardAccessException
- the blackboard access exceptionpublic void unloadRecord(java.lang.String id)
Blackboard
unloadRecord
in interface Blackboard
id
- the idpublic void commit() throws BlackboardAccessException
Blackboard
commit ALL records on this blackboard to storages (if any) and release resources.
The records will not be unloaded from the blackboard.
The operation throws an exception if at least one record could not be committed (e.g. written to storages) successfully. However, the implementation should try to commit as many records as possible and not stop on the first failed commit and invalidate the remaining records.
commit
in interface Blackboard
BlackboardAccessException
- at least one record could not be committed.public void unload()
Blackboard
unload
in interface Blackboard
protected void setRecordStorage(RecordStorage recordStorage)
recordStorage
- RecordStorage - the record storage service interfaceprotected void setBinaryStorage(BinaryStorageService binaryStorage)
binaryStorage
- BinaryStorageService - the binary storage service interface