|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Accessor
Accessor is an interface to access, modify and monitor a data container. The actual storage format and location is implementation specific. For instance, container could be: a bunch of bytes, a Java object, a file, a folder with files, a network location, or direct memory of a simulation experiment.
The structure is presentable with Databoard type system. The type can be anything but a recursive structure.
The listening model allows placing of listener objects to accessors. Each listener is associated with a InterestSet. It describes a sub-tree of nodes to listen and aspects to monitor. Accessors emit Events on modifications of structure and value. There is a reference in each event, and it is relative to the accessor where the listener was placed. For instance, a listener, that is interested in whole tree, is placed on a root accessor. A modification at a leaf-node spawns an event with a reference path from the root to the leaf. If the listener was placed directly on the leaf, there wouldn't be a path in the evenr object.
Multi-thread-usage is implementation dependent, read the documentation.
Construction and destruction model is also implementation dependent. A rule of thumb in life management of objects is that, the party that constructs an object must destroy it. Both construction and destruction of the container are also outside the scope of the Accessor interface.
However, as general implementation contract, the data container is disposed as whole, individual nodes are not. While the container is alive, individual nodes may be disposed using garbage collection mechanisms. Reference queue mechanism is one implementatio strategy. More common strategy is usage of weak references from parent to child.
Accessors
,
Accessor to Java Object container
,
Accessor to a container in File or Memory
,
ArrayAccessor
,
BooleanAccessor
,
ByteAccessor
,
DoubleAccessor
,
FloatAccessor
,
IntegerAccessor
,
LongAccessor
,
MapAccessor
,
OptionalAccessor
,
RecordAccessor
,
StringAccessor
,
UnionAccessor
,
VariantAccessor
Nested Class Summary | |
---|---|
static interface |
Accessor.Listener
Accessor listener. |
Method Summary | ||
---|---|---|
void |
addListener(Accessor.Listener listener,
InterestSet interestSet,
ChildReference pathPrefix,
java.util.concurrent.Executor executor)
Place a listener to an accessor node. |
|
void |
apply(java.util.List<Event> changeSet,
java.util.LinkedList<Event> rollback)
Apply a change set in a single transaction operation. |
|
|
getComponent(ChildReference path)
Open an accessor to a child. |
|
java.lang.Object |
getValue(Binding binding)
Get a snapshot of the object model as a single data value. |
|
void |
getValue(Binding binding,
java.lang.Object obj)
Read a copy of the accessor's object into an instance. |
|
void |
removeListener(Accessor.Listener listener)
Remove a listener. |
|
void |
setValue(Binding binding,
java.lang.Object newValue)
Set a complete new value to the data container. |
|
Datatype |
type()
Get structural represtentation of the accessor presented in databoard's type system. |
Method Detail |
---|
java.lang.Object getValue(Binding binding) throws AccessorException
Accessor makes type adaption to users binding if possible.
binding
-
AccessorException
void getValue(Binding binding, java.lang.Object obj) throws AccessorException
Accessor makes type adaption to users binding if possible.
binding
- obj
- object to read the value to
AccessorException
void setValue(Binding binding, java.lang.Object newValue) throws AccessorException
If the new value removes old map entries, array entries, optional value, or
changes union or variant value type, it will disengage any existing
sub-accessors and send InvalidatedEvent
.
Writing the current value again may not emit an event. This is implementation specific.
Write is durable, once a the method returns successfully the value has been stored in the implmentation.
binding
- newValue
-
BindingException
- binding error
java.lang.UnsupportedOperationException
- cannot set a new value
AccessorException
<T extends Accessor> T getComponent(ChildReference path) throws AccessorConstructionException
InvalidatedEvent is thrown from the accessor if it is unlinked from the parent hierarchy.
path
- component reference path or null
to return _this_ accessor
AccessorConstructionException
void apply(java.util.List<Event> changeSet, java.util.LinkedList<Event> rollback) throws AccessorException
changeSet
- rollback
- log to be filled with rollback events or null
AccessorException
- failed to apply change setDatatype type()
void addListener(Accessor.Listener listener, InterestSet interestSet, ChildReference pathPrefix, java.util.concurrent.Executor executor) throws AccessorException
When events are emited and in which thread processed is implementation specific. It is also implementation specific, whether the object can be mutated in the listener or whether it has to be done afterwards.
In many implementations there is a pluggable event handling strategy EventEmitter. The default behaviour is to emit events as they are spawned in the current thread.
There is a reference in each event instance that describes the path from the accessor where listener was placed to the node to which the event applies to.
Listener is attached to the object that holds the value at the time at the of the adding. For example, If a listener is attached to an array of element at index 3, and a new value is inserted at position 2, the listener still monitors the same container, which is now at index 4. The references of incoming the events are modified to have the new index.
Also, if a new value is assigned to the parent of an object that is listened, the listener keeps on monitoring the new value at the same reference. This doesn't apply when a new value is set to a union of different tag, to a variant with a new type, or value is removed from Optional type. In these two cases the listener is invalidated.
See ChangeSet
is an implementation that collects events.
Executor argument determines the thread where the onEvents method is
handled. null argument denotes current thread.
listener
- interestSet
- pathPrefix
- path to the accessor or null
. This is used in the events the accessor producesexecutor
-
AccessorException
collects events
void removeListener(Accessor.Listener listener) throws AccessorException
listener
-
AccessorException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |