All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sics.agentbase.sap.SapConnection

java.lang.Object
   |
   +----sics.agentbase.sap.SapConnection

public class SapConnection
extends Object
This class allows JAVA programs to connect to any program/agent in Java that speaks the SAP protocol. The JAVA program requests for a synchroniouze connection to be made the other program/agent. It also allows sending asynchroniouze messages to Java programs/agents. It should be noted that program that uses this class can NOT receive asynchroniouze messages. Built on the original SapConnection.java by Niklas Kaltea (nicke@sics.se) for communication between JAVA programs and Prolog programs/agents.


Constructor Index

 o SapConnection()
 o SapConnection(Socket)

Method Index

 o connect(String, String, int, String)
Makes a synchroniouze connection to a Java agent/program.
 o disconnect()
Disconnect from an open connection.
 o finalize()
 o isConnected()
Tests if we have an open connection.
 o receiveSap()
Receive a message on an open connection.
 o sendAsyncSap(String, String, int, String, Object)
Sends a asynchroniouze message.
 o sendSap(Object)
Send a message on the open connection.
 o shutdown()
closedown all open streams.

Constructors

 o SapConnection
 public SapConnection()
 o SapConnection
 public SapConnection(Socket connection) throws IOException

Methods

 o connect
 public boolean connect(String owner,
                        String host,
                        int port,
                        String agent)
Makes a synchroniouze connection to a Java agent/program. The connection is made to agent at host:port. This method should be used instead of the Constructor.

Parameters:
owner - The name of the one who sends the message.
host - The host we want to send to.
port - The port we want to send to.
agent - The agent we want to send to.
Returns:
Returns a referens to the connection or null if we failed to open a connection.
 o disconnect
 public void disconnect()
Disconnect from an open connection.

 o isConnected
 public boolean isConnected()
Tests if we have an open connection.

Returns:
true or false.
 o sendSap
 public void sendSap(Object sap) throws IOException
Send a message on the open connection.

Parameters:
sap - A serializable object.
See Also:
SAP
 o sendAsyncSap
 public static boolean sendAsyncSap(String owner,
                                    String host,
                                    int port,
                                    String agent,
                                    Object msg) throws IOException
Sends a asynchroniouze message. The message is sent to agent on host:port.

Parameters:
owner - The name of the one who sends the message.
host - The host we want to send to.
port - The port we want to send to.
agent - The agent we want to send to.
msg - The message object we want to send.
Returns:
Returns true if we succeeds to send the message, false otherwise.
 o receiveSap
 public Object receiveSap() throws IOException
Receive a message on an open connection. This metod blocks until it has read a message from the input stream.

 o finalize
 protected void finalize()
Overrides:
finalize in class Object
 o shutdown
 public void shutdown()
closedown all open streams.


All Packages  Class Hierarchy  This Package  Previous  Next  Index