org.gridlab.gat.io
Interface Endpoint

All Superinterfaces:
Advertisable, Monitorable, Serializable

public interface Endpoint
extends Monitorable, Advertisable, Serializable

An Endpoint represents an endpoint of a Pipe. An Endpoint can be created, and listened to, and connected to. An Endpoint represents an end of a byte stream. Depending on how a Endpoint gets created, it can be listened to or connected to. In both cases, the endpoint returns a Pipe. Hence, a Endpoint acts in fact as a Pipe factory: multiple Pipes can be created from it by repeatedly listening for incoming connections. The behaviour is similar to listening on a BSD socket. Endpoints obtained from the AdvertService cannot be listened to. Pipes created from endpoints continue to live after the Endpoint instance is destroyed.

Author:
rob

Method Summary
 Pipe connect()
          Connect to the Endpoint.
 Pipe listen()
          Listen for a new connection to the Endpoint.
 Pipe listen(int timeout)
          Listen for a new connection to the Endpoint.
 void listen(PipeListener pipeListener)
          Listen for a new connection to the Endpoint.
 void listen(PipeListener pipeListener, int timeout)
          Listen for a new connection to the Endpoint.
 
Methods inherited from interface org.gridlab.gat.monitoring.Monitorable
addMetricListener, getMeasurement, getMetricDefinitionByName, getMetricDefinitions, removeMetricListener
 
Methods inherited from interface org.gridlab.gat.advert.Advertisable
marshal
 

Method Detail

connect

Pipe connect()
             throws GATInvocationException
Connect to the Endpoint. When a Endpoint is obtained from an AdvertService, it can be used to create a Pipe connected to the advertising application, by calling connect on the Endpoint instance.

Returns:
a new Pipe connected to the Endpoint.
Throws:
GATInvocationException - if no connection could be made.

listen

Pipe listen()
            throws GATInvocationException
Listen for a new connection to the Endpoint. The creator of an Endpoint can use the Endpoint to create Pipes, which represent incoming connections. This is done by calling listen on the Endpoint instance. This call is synchronous, and blocks until a connection has been made.

Returns:
a new Pipe connected to the Endpoint.
Throws:
GATInvocationException - if no connection could be made.

listen

Pipe listen(int timeout)
            throws GATInvocationException
Listen for a new connection to the Endpoint. The creator of an Endpoint can use the Endpoint to create Pipes, which represent incoming connections. This is done by calling listen on the Endpoint instance. This call is synchronous, and blocks until a connection has been made or until the specified timeout expires.

Parameters:
timeout - the specified timeout in milliseconds
Returns:
a new Pipe connected to the Endpoint.
Throws:
GATInvocationException - if no connection could be made.

listen

void listen(PipeListener pipeListener)
            throws GATInvocationException
Listen for a new connection to the Endpoint. The creator of an Endpoint can use the Endpoint to create Pipes, which represent incoming connections. This is done by calling listen on the Endpoint instance. This call is asynchronous, and returns immediately. When a new connection has been made, the pipeListener will be informed.

Parameters:
pipeListener - the listener that will be informed
Throws:
GATInvocationException - if no connection could be made.

listen

void listen(PipeListener pipeListener,
            int timeout)
            throws GATInvocationException
Listen for a new connection to the Endpoint. The creator of an Endpoint can use the Endpoint to create Pipes, which represent incoming connections. This is done by calling listen on the Endpoint instance. This call is asynchronous, and returns immediately. When a new connection has been made, the PipeListener will be informed.

Parameters:
pipeListener - the PipeListener that will be informed
timeout - the specified timeout in milliseconds
Throws:
GATInvocationException - if no connection could be made.