ch.epfl.lsr.apex.connection
Class APEXMeshConnection

java.lang.Object
  extended bych.epfl.lsr.apex.connection.APEXConnection
      extended bych.epfl.lsr.apex.connection.APEXMeshConnection
All Implemented Interfaces:
Runnable

public class APEXMeshConnection
extends APEXConnection

An APEXMeshConnection handles the connection between two nodes in the APEX Mesh (relay-relay) and adds manager specific (actually only relay) policies for the connection.

Author:
Marc Stoecklin

Field Summary
static int BOUND
           
 
Fields inherited from class ch.epfl.lsr.apex.connection.APEXConnection
authenticatedAs, CHANNEL_ESTABLISHED, channelID, CONNECTION_INITIATION, connectionEstablished, connectionThread, currentConnections, entity, internalIDs, knownChannels, manager, messageFile, pollingIntervall, profile, running, task, transID, trialNb
 
Method Summary
 void addBoundAs(String administrativeDomain)
          Updates the authenticatedAs table if the manager is successfully bound as the specified administrative domain.
 void bind(String administrativeDomain, APEXStatus s)
          Binds as the administrative domain on this connection, say at the entity, and adds the status listener to the attach message.
 void bindRelay(String domain, int transID)
          Adds the newly bound relay to the internal id file.
protected  void channelEstablished()
          Is called by the connection thread if an APEX channel is successfully established - allows to update the status of the connection.
protected  void disconnected()
          Is called if a disconnection is noticed and initiates appropriate solutions (policies for relay).
static APEXMeshConnection getAPEXMeshConnection(APEXManager manager, APEXRoutingPoint arp)
           APEXEdgeConnectionFACTORY Returns either a new APEXEdgeConnection or an existing stored in the connection table.
static APEXMeshConnection getAPEXMeshConnection(APEXManager manager, String entity, Channel c, Object receivingChannelID)
           APEXMeshConnectionFACTORY Returns either a new APEXMeshConnection or an existing, stored in the connection table.
static APEXMeshConnection getAPEXMeshConnection(String entity)
           APEXMeshConnectionFACTORY Returns either an existing APEXMeshConnection stored in the connection table or null.
(package private) static APEXMeshConnection getConnectionForChannel(Channel c)
          Returns a APEXMeshConnection or null for a given org.beepcore.beep.core.Channel.
protected  void handleReply(Message replyMessage, APEXMessage message)
          Handles a received reply message to a correspondent (sent) APEX message (attach, bind, terminate, or data).
protected  boolean isAuthenticated(APEXDataMessage m)
          Returns a boolean which depends if the message is authentcated to be sent or not to the hop (either attached or bound).
protected  void messageNotSent(APEXMessage message)
           Is called by the connection thread if the session is down an the message has not been sent.
protected  void noConnectionEstablished()
          Is called by the connection thread if no connection is established and initiates correspondent actions (according the connection type and the underlying manager).
 void removeBoundAs(String administrativeDomain)
          Updates the authenticatedAs table if an the manager is not bound (any more) as the specified administrative domain.
static void removeMeshConnection(String entity)
          Removes the edge connection entry in the connection table for the specified entity name.
protected  void requestedChannelNotStarted()
          Is called by the connection thread if no APEX channel is established and initiates correspondent actions (according the connection type and the underlying manager).
 void run()
           
 boolean sendMessage(APEXMessage m)
          Sends a message on this connection.
 void terminate(int transID, int code, String content, String xmlLang, APEXStatus s)
          Terminates a transaction on this connection, say at the entity, and adds the status listener to the terminate message.
 void terminate(String relay, int code, String content, String xmlLang, APEXStatus s)
          Terminates the relay binding on this connection, say at this / this entity, adds the status listener to the terminate message, and removes the endpoint address of the authenticatedAs table.
 
Methods inherited from class ch.epfl.lsr.apex.connection.APEXConnection
addFirstMessage, addMessage, clearMessageFile, getChannelID, getMessage, getUniqueTransID, newAttachmentOrBinding, updateTransID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOUND

public static final int BOUND
See Also:
Constant Field Values
Method Detail

getAPEXMeshConnection

public static APEXMeshConnection getAPEXMeshConnection(APEXManager manager,
                                                       String entity,
                                                       Channel c,
                                                       Object receivingChannelID)

APEXMeshConnectionFACTORY

Returns either a new APEXMeshConnection or an existing, stored in the connection table.

Parameters:
manager - The manager
entity - The entity name
c - The existing channel
receivingChannelID - The receiver's channel identifier
Returns:
A resulting mesh connection

getAPEXMeshConnection

public static APEXMeshConnection getAPEXMeshConnection(String entity)

APEXMeshConnectionFACTORY

Returns either an existing APEXMeshConnection stored in the connection table or null.

Parameters:
entity - The entity name
Returns:
A mesh connection or null

getAPEXMeshConnection

public static APEXMeshConnection getAPEXMeshConnection(APEXManager manager,
                                                       APEXRoutingPoint arp)

APEXEdgeConnectionFACTORY

Returns either a new APEXEdgeConnection or an existing stored in the connection table.

Parameters:
manager - The manager (endpoint)
arp - A routing point element
Returns:
The resulting mesh connection

removeMeshConnection

public static void removeMeshConnection(String entity)
Removes the edge connection entry in the connection table for the specified entity name.

Parameters:
entity - The entity name

getConnectionForChannel

static APEXMeshConnection getConnectionForChannel(Channel c)
Returns a APEXMeshConnection or null for a given org.beepcore.beep.core.Channel.

Parameters:
c - The channel
Returns:
A APEXMeshConnection or null

isAuthenticated

protected boolean isAuthenticated(APEXDataMessage m)
Description copied from class: APEXConnection
Returns a boolean which depends if the message is authentcated to be sent or not to the hop (either attached or bound).

Specified by:
isAuthenticated in class APEXConnection

addBoundAs

public void addBoundAs(String administrativeDomain)
Updates the authenticatedAs table if the manager is successfully bound as the specified administrative domain.

Parameters:
administrativeDomain - The bound administrative domain

removeBoundAs

public void removeBoundAs(String administrativeDomain)
Updates the authenticatedAs table if an the manager is not bound (any more) as the specified administrative domain.

Parameters:
administrativeDomain - The not bound administrative domain

bind

public void bind(String administrativeDomain,
                 APEXStatus s)
Binds as the administrative domain on this connection, say at the entity, and adds the status listener to the attach message.

Parameters:
administrativeDomain - The administrative domain to be bound
s - The status listener or null for none

bindRelay

public void bindRelay(String domain,
                      int transID)
Adds the newly bound relay to the internal id file.

Parameters:
domain - The entity's domain
transID - The transaction identifier

terminate

public void terminate(String relay,
                      int code,
                      String content,
                      String xmlLang,
                      APEXStatus s)
Terminates the relay binding on this connection, say at this / this entity, adds the status listener to the terminate message, and removes the endpoint address of the authenticatedAs table.

Parameters:
relay - The relay address to be terminated
code - An optional (applicational) code or 0
content - The content or null for none
xmlLang - The xml:lang or null for none
s - The status listener or null for none

terminate

public void terminate(int transID,
                      int code,
                      String content,
                      String xmlLang,
                      APEXStatus s)
Terminates a transaction on this connection, say at the entity, and adds the status listener to the terminate message.

Parameters:
transID -
code - An optional (applicational) code or 0
content - The content or null for none
xmlLang - The xml:lang or null for none
s - The status listener or null for none

handleReply

protected void handleReply(Message replyMessage,
                           APEXMessage message)
Description copied from class: APEXConnection
Handles a received reply message to a correspondent (sent) APEX message (attach, bind, terminate, or data).

Specified by:
handleReply in class APEXConnection
Parameters:
replyMessage - The received reply message
message - The sent APEX message

messageNotSent

protected void messageNotSent(APEXMessage message)
Description copied from class: APEXConnection

Is called by the connection thread if the session is down an the message has not been sent.

Dependent on the underlying manager and the connection type (edge or mesh), this method either tries to reconnect or calls the discardMessage method of its manager.

Specified by:
messageNotSent in class APEXConnection
Parameters:
message - The unsent message

noConnectionEstablished

protected void noConnectionEstablished()
Description copied from class: APEXConnection
Is called by the connection thread if no connection is established and initiates correspondent actions (according the connection type and the underlying manager).

Specified by:
noConnectionEstablished in class APEXConnection

disconnected

protected void disconnected()
Is called if a disconnection is noticed and initiates appropriate solutions (policies for relay).


requestedChannelNotStarted

protected void requestedChannelNotStarted()
Description copied from class: APEXConnection
Is called by the connection thread if no APEX channel is established and initiates correspondent actions (according the connection type and the underlying manager).

Specified by:
requestedChannelNotStarted in class APEXConnection

channelEstablished

protected void channelEstablished()
Description copied from class: APEXConnection
Is called by the connection thread if an APEX channel is successfully established - allows to update the status of the connection.

Specified by:
channelEstablished in class APEXConnection

sendMessage

public boolean sendMessage(APEXMessage m)
Sends a message on this connection.

Parameters:
m - The message to be sent
Returns:
A boolean indication is always true since a relay polcies force to automatically bind

run

public void run()