The Meta-Environment API

toolbus.communication
Class DirectIOHandler

java.lang.Object
  extended by toolbus.communication.DirectIOHandler
All Implemented Interfaces:
IIOHandler

public class DirectIOHandler
extends java.lang.Object
implements IIOHandler

This class enables direct communication (through java method calls) between a client and a server, under the condition that they are running the the same VM. This class does nothing fancy, it just passes messages between the data handler and its I/O handler counter part.

Author:
Arnold Lankamp

Field Summary
private  IDataHandler dataHandler
           
private  DirectIOHandler directIOHandler
           
 
Constructor Summary
DirectIOHandler(IDataHandler dataHandler)
          Constructor.
 
Method Summary
 void exceptionOccured()
          Notifies the I/O handler that an exception has occured so it can take the nessacary steps.
 void receive(byte operation, aterm.ATerm aTerm)
          Receives a term from the remote location.
 void send(byte operation, aterm.ATerm aTerm)
          Sends a term to the remote location.
 void setDirectIOHandler(DirectIOHandler directIOHandler)
          Links this I/O handler with its counter part.
 void shutDown()
          Shuts down this ioHandler and it's associated datahandler.
 void terminate()
          Requests the termination of this ioHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataHandler

private final IDataHandler dataHandler

directIOHandler

private volatile DirectIOHandler directIOHandler
Constructor Detail

DirectIOHandler

public DirectIOHandler(IDataHandler dataHandler)
Constructor.

Parameters:
dataHandler - The data handler this I/O handler is associated with.
Method Detail

setDirectIOHandler

public void setDirectIOHandler(DirectIOHandler directIOHandler)
Links this I/O handler with its counter part.

Parameters:
directIOHandler - The counter part of this I/O handler.

receive

public void receive(byte operation,
                    aterm.ATerm aTerm)
Description copied from interface: IIOHandler
Receives a term from the remote location.

Specified by:
receive in interface IIOHandler
Parameters:
operation - The operation associated with the term we received.
aTerm - The term that was received.
See Also:
IIOHandler.receive(byte, ATerm)

send

public void send(byte operation,
                 aterm.ATerm aTerm)
Description copied from interface: IIOHandler
Sends a term to the remote location.

Specified by:
send in interface IIOHandler
Parameters:
operation - The operation associated with the term we need to send.
aTerm - The term that needs to be send.
See Also:
IIOHandler.send(byte, ATerm)

terminate

public void terminate()
Description copied from interface: IIOHandler
Requests the termination of this ioHandler.

Specified by:
terminate in interface IIOHandler
See Also:
IIOHandler.terminate()

shutDown

public void shutDown()
Description copied from interface: IIOHandler
Shuts down this ioHandler and it's associated datahandler. IMPORTANT: This method should not be called from outside the ioHandler. Manual invokation will lead to undefined behaviour.

Specified by:
shutDown in interface IIOHandler
See Also:
IIOHandler.shutDown()

exceptionOccured

public void exceptionOccured()
Description copied from interface: IIOHandler
Notifies the I/O handler that an exception has occured so it can take the nessacary steps.

Specified by:
exceptionOccured in interface IIOHandler
See Also:
IIOHandler.exceptionOccured()

The Meta-Environment API