org.kth.dks.dks_marshal
Class ObjectAdapter

java.lang.Object
  extended by org.kth.dks.dks_marshal.ObjectAdapter
All Implemented Interfaces:
java.lang.Runnable

public class ObjectAdapter
extends java.lang.Object
implements java.lang.Runnable

Runs inside a thread, supposedly one per DKSNode. Keeps a synchronized buffer, and dispatches messages to the right DKSNode handler.

Title: DKS

Description: DKS Middleware

Copyright: Copyright (c) 2004

Company: KTH-IMIT/SICS

Version:
1.0
Author:
not attributable

Constructor Summary
ObjectAdapter()
           
 
Method Summary
 boolean addMsgHandler(java.lang.String messageClassZ, java.lang.String handlerClassZ, java.lang.String handlerMethodZ, java.lang.Object handlerObject)
          Maps a message class, e.g.
 boolean callMessageHandler(DKSMessage dksMsg, DKSRef source)
          Takes a narrowed DKSMessage and dispatches it to a handler
 org.kth.dks.dks_marshal.ObjectAdapter.MessagePair getMessagePair()
          Synchronized get method that returns a DKSMessage and the assoicated sender of the message
 boolean putMessagePair(DKSMessage m, DKSRef s)
          Synchronized method to put a message together with its sender in the queue
 void run()
          Takes a bite off the msgQueue and dispatches it to the right DKSNode handler Stops if stop() is called.
 void stop()
          Stop the running thread (for termination).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectAdapter

public ObjectAdapter()
Method Detail

run

public void run()
Takes a bite off the msgQueue and dispatches it to the right DKSNode handler Stops if stop() is called.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Stop the running thread (for termination).


putMessagePair

public boolean putMessagePair(DKSMessage m,
                              DKSRef s)
Synchronized method to put a message together with its sender in the queue

Parameters:
m - DKSMessage marshalled message
s - DKSRef reference to the sending node
Returns:
boolean true if successful, otherwise false.

getMessagePair

public org.kth.dks.dks_marshal.ObjectAdapter.MessagePair getMessagePair()
Synchronized get method that returns a DKSMessage and the assoicated sender of the message

Returns:
MessagePair containing the message and the sender, null if interrupted (on exit)

addMsgHandler

public boolean addMsgHandler(java.lang.String messageClassZ,
                             java.lang.String handlerClassZ,
                             java.lang.String handlerMethodZ,
                             java.lang.Object handlerObject)
Maps a message class, e.g. "dks_marshal.LookupMsg", to a method of a class Z and an object of type Z

Parameters:
messageClassZ - String represeting the DKSMessage class
handlerClassZ - String representing the class of the method
handlerMethodZ - String method name
handlerObject - Object object of type handlerClassZ which has method handlerMethodZ

callMessageHandler

public boolean callMessageHandler(DKSMessage dksMsg,
                                  DKSRef source)
Takes a narrowed DKSMessage and dispatches it to a handler

Parameters:
dksMsg - DKSMessage narroved message


Copyright © 2010. All Rights Reserved.