org.simantics.databoard.accessor.wire
Class WireServer

java.lang.Object
  extended by org.simantics.databoard.accessor.wire.WireServer
All Implemented Interfaces:
IWireServer

public class WireServer
extends java.lang.Object
implements IWireServer

WireServer exposes an accessor over TCP/IP socket.

Author:
Toni Kalajainen

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.simantics.databoard.accessor.wire.IWireServer
IWireServer.AccessorInfo, IWireServer.ApplyResult
 
Constructor Summary
WireServer(Accessor accessor)
           
 
Method Summary
 int add(int accId, int index, MutableVariant value)
           
 int addAll(int accId, int index, MutableVariant array)
          add objects to array
 int addListener(int accId, InterestSet interestSet, ChildReference path)
          Create listener
 IWireServer.ApplyResult apply(int accId, Event[] changeSet, boolean rollback)
          Apply a list of changes to the node.
 int clear(int accId)
          Remove all array or map elements
 int closeAccessors(java.lang.Integer[] accIds)
          Close a group of accessor handles.
 boolean containsKey(int accId, MutableVariant key)
           
 boolean containsValue(int accId, MutableVariant value)
           
 MutableVariant getArrayElement(int accId, int index)
          Get array element value
 MutableVariant getCeilingKey(int accId, MutableVariant key)
           
 org.simantics.databoard.accessor.wire.WireServer.ClientRecord getClient()
          Get or create new client handler associated with current thread.
 MutableVariant getFirstKey(int accId)
           
 MutableVariant getFloorKey(int accId, MutableVariant key)
           
 MutableVariant getHigherKey(int accId, MutableVariant key)
           
 MutableVariant getLastKey(int accId)
           
 MutableVariant getLowerKey(int accId, MutableVariant key)
           
 MutableVariant getMapKeys(int accId)
          Get map keys as array
 MutableVariant getMapValue(int accId, MutableVariant key)
          Get map entry value
 MutableVariant getMapValues(int accId)
          Get map values as array
 MethodInterface getMethodInterface()
           
 int getTag(int accId)
          Get tag index of a Union node
 MutableVariant getValue(int accId)
          Read the value as whole.
 boolean hasValue(int accId)
          Get value status of an Optional node
 IWireServer.AccessorInfo openAccessor(ChildReference ref)
          Open a handle to an accessor.
 int removeListener(int lisId)
          Remove listener
 int size(int accId)
          Get size of an array, map, record or union
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WireServer

public WireServer(Accessor accessor)
Method Detail

getMethodInterface

public MethodInterface getMethodInterface()

getClient

public org.simantics.databoard.accessor.wire.WireServer.ClientRecord getClient()
                                                                        throws WireException
Get or create new client handler associated with current thread. The result value depends on the current thread.

Returns:
client handler
Throws:
WireException

openAccessor

public IWireServer.AccessorInfo openAccessor(ChildReference ref)
                                      throws WireException
Description copied from interface: IWireServer
Open a handle to an accessor.

Specified by:
openAccessor in interface IWireServer
Parameters:
ref - accessor refence or null for root
Returns:
accessor info
Throws:
WireException

closeAccessors

public int closeAccessors(java.lang.Integer[] accIds)
                   throws WireException
Description copied from interface: IWireServer
Close a group of accessor handles. Open listener and lock handles are released.

Specified by:
closeAccessors in interface IWireServer
Parameters:
accIds - accessor ids
Throws:
WireException

getValue

public MutableVariant getValue(int accId)
                        throws WireException
Description copied from interface: IWireServer
Read the value as whole. If accessor is locked, read operation delays until lock is released.

Specified by:
getValue in interface IWireServer
Returns:
value
Throws:
WireException

apply

public IWireServer.ApplyResult apply(int accId,
                                     Event[] changeSet,
                                     boolean rollback)
Description copied from interface: IWireServer
Apply a list of changes to the node. If rollback is true, a rollback log is returned. Rollback log is a list of events that revert modifications if applied.

In case of error rollback log is filled with events that counter modification that were already applied before the error occured.

Specified by:
apply in interface IWireServer
Returns:
apply result

addListener

public int addListener(int accId,
                       InterestSet interestSet,
                       ChildReference path)
                throws WireException
Description copied from interface: IWireServer
Create listener

Specified by:
addListener in interface IWireServer
Returns:
lisId
Throws:
WireException

removeListener

public int removeListener(int lisId)
                   throws WireException
Description copied from interface: IWireServer
Remove listener

Specified by:
removeListener in interface IWireServer
Throws:
WireException

size

public int size(int accId)
         throws WireException
Description copied from interface: IWireServer
Get size of an array, map, record or union

Specified by:
size in interface IWireServer
Throws:
WireException

clear

public int clear(int accId)
          throws WireException
Description copied from interface: IWireServer
Remove all array or map elements

Specified by:
clear in interface IWireServer
Throws:
WireException

containsKey

public boolean containsKey(int accId,
                           MutableVariant key)
                    throws WireException
Specified by:
containsKey in interface IWireServer
Throws:
WireException

containsValue

public boolean containsValue(int accId,
                             MutableVariant value)
                      throws WireException
Specified by:
containsValue in interface IWireServer
Throws:
WireException

getFirstKey

public MutableVariant getFirstKey(int accId)
                           throws WireException
Specified by:
getFirstKey in interface IWireServer
Throws:
WireException

getLastKey

public MutableVariant getLastKey(int accId)
                          throws WireException
Specified by:
getLastKey in interface IWireServer
Throws:
WireException

getLowerKey

public MutableVariant getLowerKey(int accId,
                                  MutableVariant key)
                           throws WireException
Specified by:
getLowerKey in interface IWireServer
Throws:
WireException

getFloorKey

public MutableVariant getFloorKey(int accId,
                                  MutableVariant key)
                           throws WireException
Specified by:
getFloorKey in interface IWireServer
Throws:
WireException

getCeilingKey

public MutableVariant getCeilingKey(int accId,
                                    MutableVariant key)
                             throws WireException
Specified by:
getCeilingKey in interface IWireServer
Throws:
WireException

getHigherKey

public MutableVariant getHigherKey(int accId,
                                   MutableVariant key)
                            throws WireException
Specified by:
getHigherKey in interface IWireServer
Throws:
WireException

hasValue

public boolean hasValue(int accId)
                 throws WireException
Description copied from interface: IWireServer
Get value status of an Optional node

Specified by:
hasValue in interface IWireServer
Returns:
true if there is value in the node
Throws:
WireException

getTag

public int getTag(int accId)
           throws WireException
Description copied from interface: IWireServer
Get tag index of a Union node

Specified by:
getTag in interface IWireServer
Returns:
tag index
Throws:
WireException

addAll

public int addAll(int accId,
                  int index,
                  MutableVariant array)
           throws WireException
Description copied from interface: IWireServer
add objects to array

Specified by:
addAll in interface IWireServer
index - insert pos, -1 = at the end
Returns:
actual insert pos
Throws:
WireException

add

public int add(int accId,
               int index,
               MutableVariant value)
        throws WireException
Specified by:
add in interface IWireServer
index - insert pos, -1 = at the end
Returns:
actual insert pos
Throws:
WireException

getArrayElement

public MutableVariant getArrayElement(int accId,
                                      int index)
                               throws WireException
Description copied from interface: IWireServer
Get array element value

Specified by:
getArrayElement in interface IWireServer
Returns:
value
Throws:
WireException

getMapValue

public MutableVariant getMapValue(int accId,
                                  MutableVariant key)
                           throws WireException
Description copied from interface: IWireServer
Get map entry value

Specified by:
getMapValue in interface IWireServer
Returns:
value
Throws:
WireException

getMapValues

public MutableVariant getMapValues(int accId)
                            throws WireException
Description copied from interface: IWireServer
Get map values as array

Specified by:
getMapValues in interface IWireServer
Returns:
values in array inside a variant
Throws:
WireException

getMapKeys

public MutableVariant getMapKeys(int accId)
                          throws WireException
Description copied from interface: IWireServer
Get map keys as array

Specified by:
getMapKeys in interface IWireServer
Returns:
keys in array inside a variant
Throws:
WireException