org.kth.dks.dks_marshal
Class DKSMarshal

java.lang.Object
  extended by org.kth.dks.dks_marshal.DKSMarshal

public class DKSMarshal
extends java.lang.Object


Field Summary
static byte TRANSDEFAULT
           
static byte TRANSTYPEBINARY
           
static byte TRANSTYPEXML
           
 
Constructor Summary
DKSMarshal(ConnectionManager cm)
           
 
Method Summary
 boolean addMsgHandler(DKSOverlayAddress addr, java.lang.String messageClassZ, java.lang.String handlerClassZ, java.lang.String handlerMethodZ, java.lang.Object handlerObject)
           
 boolean addMsgHandlerPrefixed(DKSOverlayAddress addr, java.lang.String messageClassZ, java.lang.String handlerClassZ, java.lang.String handlerMethodZ, java.lang.Object handlerObject)
           
 boolean dispatchOA(DKSMessage dksMsg, DKSRef source, DKSOverlayAddress dest)
          Takes an unmarshalled message from source to dest and dispatches it to the correct ObjectAdapter
 void end()
          Cleans the object adapter map such that the object adapters and their corresponding buffers can be GC:d
 void failureHandler(MsgSrcDestWrapper triple)
          Takes an unmarshalled message from source to dest and dispatches it to the correct ObjectAdapter
 byte[] marshalMsgSrcDestWrapper(MsgSrcDestWrapper wr)
           
 void registerDKSNode(DKSOverlayAddress addr)
           
 boolean send(DKSRef src, DKSRef dest, DKSMessage msg)
          Sends the message inside msg from src to dest.
 boolean unmarshalDispatch(byte transType, byte[] input, DKSNetAddress source)
          Calls the unmarshaller and unmarshalls the byte stream to DKSMessage, and dispatches it to the right handler
 void unregisterDKSNode(DKSOverlayAddress addr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSTYPEXML

public static final byte TRANSTYPEXML
See Also:
Constant Field Values

TRANSTYPEBINARY

public static final byte TRANSTYPEBINARY
See Also:
Constant Field Values

TRANSDEFAULT

public static final byte TRANSDEFAULT
See Also:
Constant Field Values
Constructor Detail

DKSMarshal

public DKSMarshal(ConnectionManager cm)
Method Detail

unmarshalDispatch

public boolean unmarshalDispatch(byte transType,
                                 byte[] input,
                                 DKSNetAddress source)
Calls the unmarshaller and unmarshalls the byte stream to DKSMessage, and dispatches it to the right handler

Parameters:
input - byte[] raw byte array representing a full XML document
source - DKSRef reference of the node that sent to message. The reference is passed to the handler method when dispatching the event

dispatchOA

public boolean dispatchOA(DKSMessage dksMsg,
                          DKSRef source,
                          DKSOverlayAddress dest)
Takes an unmarshalled message from source to dest and dispatches it to the correct ObjectAdapter

Parameters:
dksMsg - DKSMessage already marshalled message
source - DKSRef source node
dest - DKSOverlayAddress destination node

failureHandler

public void failureHandler(MsgSrcDestWrapper triple)
Takes an unmarshalled message from source to dest and dispatches it to the correct ObjectAdapter

Parameters:
dksMsg - MsgSrcDestWrapper triple wrapper containing DKSMessage, Source, Destination
dest - DKSOverlayAddress destination node

registerDKSNode

public void registerDKSNode(DKSOverlayAddress addr)
                     throws DKSNodeAlreadyRegistered
Throws:
DKSNodeAlreadyRegistered

unregisterDKSNode

public void unregisterDKSNode(DKSOverlayAddress addr)

addMsgHandlerPrefixed

public boolean addMsgHandlerPrefixed(DKSOverlayAddress addr,
                                     java.lang.String messageClassZ,
                                     java.lang.String handlerClassZ,
                                     java.lang.String handlerMethodZ,
                                     java.lang.Object handlerObject)
See Also:
All class names are rooted at this.BASEPACKAGE

addMsgHandler

public boolean addMsgHandler(DKSOverlayAddress addr,
                             java.lang.String messageClassZ,
                             java.lang.String handlerClassZ,
                             java.lang.String handlerMethodZ,
                             java.lang.Object handlerObject)
See Also:
ObjectAdapter.addMsgHandler()

send

public boolean send(DKSRef src,
                    DKSRef dest,
                    DKSMessage msg)
Sends the message inside msg from src to dest. If the destination is local it is just given to that node without any marshaling/unmarshaling. If the destination is remote, the message is unmarshalled before being sent.

Parameters:
src - DKSRef
dest - DKSRef
msg - DKSMessage
Returns:
boolean true if successful

marshalMsgSrcDestWrapper

public byte[] marshalMsgSrcDestWrapper(MsgSrcDestWrapper wr)

end

public void end()
Cleans the object adapter map such that the object adapters and their corresponding buffers can be GC:d



Copyright © 2010. All Rights Reserved.