SMILA (incubation) API documentation

org.eclipse.smila.blackboard.impl
Class PersistingBlackboardImpl

java.lang.Object
  extended by org.eclipse.smila.blackboard.impl.TransientBlackboardImpl
      extended by org.eclipse.smila.blackboard.impl.PersistingBlackboardImpl
All Implemented Interfaces:
Blackboard

public class PersistingBlackboardImpl
extends TransientBlackboardImpl

Blackboard implementation which is able to persist records and their attachments in storages.


Constructor Summary
PersistingBlackboardImpl(RecordFilterHelper filterHelper, java.io.File attachmentsTempDir)
          create instance.
 
Method Summary
 void commit(java.lang.String id)
          All changes are written to the storages before the record is removed.
 byte[] getAttachment(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.
 void invalidate(java.lang.String id)
          The record is removed from the blackboard.
 Record load(java.lang.String id)
          loads the record from store for the given Id.
 void removeAttachment(java.lang.String id, java.lang.String name)
          Removes the attachment.
 void removeRecord(java.lang.String id)
          remove record completely from blackboard and persistence.
 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.
 void setBinaryStorage(BinaryStorageService binaryStorage)
          Set the binary service for blackboard.
 void setRecord(Record record)
          Stores a record on the blackboard.
 void setRecordStorage(RecordStorage recordStorage)
          Set the record service for blackboard.
 
Methods inherited from class org.eclipse.smila.blackboard.impl.TransientBlackboardImpl
checkCachedFileAttachment, commit, containsRecord, copyAttributes, copyRecord, create, filterRecord, getAttachmentAsFile, getAttachmentId, getCachedRecord, getDataFactory, getGlobalNote, getIds, getMetadata, getRecord, getRecord, getRecordNote, hasAttachment, hasGlobalNote, hasRecordNote, invalidate, setGlobalNote, setRecordNote, synchronizeRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistingBlackboardImpl

public PersistingBlackboardImpl(RecordFilterHelper filterHelper,
                                java.io.File attachmentsTempDir)
create instance.

Parameters:
filterHelper - record filters
attachmentsTempDir - directory for temp files for file based access to attachment.
Method Detail

setRecordStorage

public void setRecordStorage(RecordStorage recordStorage)
Set the record service for blackboard. To be used by Declarative Services as the bind method.

Parameters:
recordStorage - RecordStorage - the record storage service interface

setBinaryStorage

public void setBinaryStorage(BinaryStorageService binaryStorage)
Set the binary service for blackboard. To be used by Declarative Services as the bind method.

Parameters:
binaryStorage - BinaryStorageService - the binary storage service interface

load

public Record load(java.lang.String id)
            throws BlackboardAccessException
loads the record from store for the given Id. In case a record store is configured and the record isn't found nothing happens but a debug log message is printed to the log.

In case no record store is configured/present then this will create a new record! same as TransientBlackboardImpl.create(String). Loads record data for the given ID from persistence (or prepare it to be loaded). Used by a client to indicate that it wants to process this record. The behavior is very implementation specific so check the the impl's doc.

Specified by:
load in interface Blackboard
Overrides:
load in class TransientBlackboardImpl
Parameters:
id - the id
Returns:
a newly created or existing record, or in some cases null if record isn't found (implementation specific)
Throws:
BlackboardAccessException - the blackboard access exception

setRecord

public void setRecord(Record record)
               throws BlackboardAccessException
Stores a record on the blackboard. If a record with the same Id already exists, it will be replaced.

Specified by:
setRecord in interface Blackboard
Overrides:
setRecord in class TransientBlackboardImpl
Parameters:
record - the record
Throws:
BlackboardAccessException - the blackboard access exception

commit

public void commit(java.lang.String id)
            throws BlackboardAccessException
All changes are written to the storages before the record is removed. The record is unlocked in the database.

Specified by:
commit in interface Blackboard
Overrides:
commit in class TransientBlackboardImpl
Parameters:
id - the id
Throws:
BlackboardAccessException - the blackboard access exception

invalidate

public void invalidate(java.lang.String id)
The record is removed from the blackboard. The record is unlocked in the database. If the record was created new (not overwritten) on this blackboard it should be removed from the storage completely.

Specified by:
invalidate in interface Blackboard
Overrides:
invalidate in class TransientBlackboardImpl
Parameters:
id - the id

removeRecord

public void removeRecord(java.lang.String id)
remove record completely from blackboard and persistence.

Specified by:
removeRecord in interface Blackboard
Overrides:
removeRecord in class TransientBlackboardImpl
Parameters:
id - record id

getAttachment

public byte[] getAttachment(java.lang.String id,
                            java.lang.String name)
                     throws BlackboardAccessException
Gets the attachment.

Specified by:
getAttachment in interface Blackboard
Overrides:
getAttachment in class TransientBlackboardImpl
Parameters:
id - the id
name - the name
Returns:
the attachment
Throws:
BlackboardAccessException - the blackboard access exception

getAttachmentAsStream

public java.io.InputStream getAttachmentAsStream(java.lang.String id,
                                                 java.lang.String name)
                                          throws BlackboardAccessException
Gets the attachment as stream.

Specified by:
getAttachmentAsStream in interface Blackboard
Overrides:
getAttachmentAsStream in class TransientBlackboardImpl
Parameters:
id - the id
name - the name
Returns:
the attachment as stream
Throws:
BlackboardAccessException - the blackboard access exception

setAttachment

public void setAttachment(java.lang.String id,
                          java.lang.String name,
                          byte[] attachment)
                   throws BlackboardAccessException
Sets the attachment.

Specified by:
setAttachment in interface Blackboard
Overrides:
setAttachment in class TransientBlackboardImpl
Parameters:
id - the id
name - the name
attachment - the attachment
Throws:
BlackboardAccessException - the blackboard access exception

setAttachmentFromStream

public void setAttachmentFromStream(java.lang.String id,
                                    java.lang.String name,
                                    java.io.InputStream attachmentStream)
                             throws BlackboardAccessException
Sets the attachment from stream.

Specified by:
setAttachmentFromStream in interface Blackboard
Overrides:
setAttachmentFromStream in class TransientBlackboardImpl
Parameters:
id - the id
name - the name
attachmentStream - the attachment stream
Throws:
BlackboardAccessException - the blackboard access exception

setAttachmentFromFile

public void setAttachmentFromFile(java.lang.String id,
                                  java.lang.String name,
                                  java.io.File attachmentFile)
                           throws BlackboardAccessException
Sets attachment from file.

Specified by:
setAttachmentFromFile in interface Blackboard
Overrides:
setAttachmentFromFile in class TransientBlackboardImpl
Parameters:
id - the id
name - the name
attachmentFile - attachment file
Throws:
BlackboardAccessException - BlackboardAccessException

removeAttachment

public void removeAttachment(java.lang.String id,
                             java.lang.String name)
                      throws BlackboardAccessException
Removes the attachment.

Specified by:
removeAttachment in interface Blackboard
Overrides:
removeAttachment in class TransientBlackboardImpl
Parameters:
id - the id
name - the name
Throws:
BlackboardAccessException - the blackboard access exception
See Also:
org.eclipse.smila.blackboard.Blackboard#removeAttachment(org.eclipse.smila.datamodel.id.Id, java.lang.String)

SMILA (incubation) API documentation