fulmine.distribution.connection.tcp
Class TcpConnectionParameters

java.lang.Object
  extended by fulmine.AbstractLifeCycle
      extended by fulmine.distribution.connection.tcp.TcpConnectionParameters
All Implemented Interfaces:
IConnectionParameters, IDestroyable, ILifeCycle
Direct Known Subclasses:
AbstractSocketChannelConnection

public class TcpConnectionParameters
extends AbstractLifeCycle
implements IConnectionParameters

Encapsulates the parameters for the TCP/IP server socket of a remote IFrameworkContext to connect to.

A note on the hierarchy; this only extends AbstractLifeCycle because the TcpConnection sub class requires the ILifeCycle method implementations provided by the AbstractLifeCycle. This is a conceded design choice.

Author:
Ramon Servadei

Constructor Summary
TcpConnectionParameters(String identity, int connectionHashCode, String address, int port)
          Standard constructor for the parameters of a TCP/IP connection to a remote IConnectionBroker.
 
Method Summary
protected  void doDestroy()
          Overridden in subclasses to perform custom logic on destruction.
protected  void doStart()
          Overridden in subclasses to perform custom logic on activation.
 boolean equals(Object obj)
           
 String getAddress()
           
 IDomain getDomain()
           
 String getIdentity()
           
 int getRemoteContextHashCode()
          Get a unique integer for the remote context.
 String getRemoteContextIdentity()
          Get the identity of the IFrameworkContext at the remote end of the connection
protected  String getRemoteHostAddress()
           
protected  int getRemoteHostTcpPort()
           
 IType getType()
           
 int hashCode()
           
 boolean isEqual(IConnectionParameters connectionParameters)
          Checks the connection parameters for equality.
protected  void setIdentity(String identity)
           
protected  void setRemoteContextHashCode(int hashCode)
           
 String toString()
           
 
Methods inherited from class fulmine.AbstractLifeCycle
checkActive, destroy, finalize, getLog, isActive, start
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TcpConnectionParameters

public TcpConnectionParameters(String identity,
                               int connectionHashCode,
                               String address,
                               int port)
Standard constructor for the parameters of a TCP/IP connection to a remote IConnectionBroker.

Parameters:
identity - the connection identity (the identity of the remote context)
connectionHashCode - the hashcode of the connection to the remote context
remoteHostAddress - the IP remoteHostAddress or resolvable host name
remoteHostTcpPort - the remoteHostTcpPort for the socket connection
Method Detail

getRemoteContextIdentity

public final String getRemoteContextIdentity()
Description copied from interface: IConnectionParameters
Get the identity of the IFrameworkContext at the remote end of the connection

Specified by:
getRemoteContextIdentity in interface IConnectionParameters
Returns:
the String identity of the remote context

getRemoteHostAddress

protected String getRemoteHostAddress()
Returns:
The IP address of the host of the remote IConnectionBroker

getRemoteHostTcpPort

protected int getRemoteHostTcpPort()
Returns:
The TCP port of the remote IConnectionBroker

setIdentity

protected void setIdentity(String identity)

getIdentity

public final String getIdentity()

getType

public IType getType()

getDomain

public IDomain getDomain()

getAddress

public String getAddress()

setRemoteContextHashCode

protected void setRemoteContextHashCode(int hashCode)

getRemoteContextHashCode

public int getRemoteContextHashCode()
Description copied from interface: IConnectionParameters
Get a unique integer for the remote context. This must be constant for any connection to the same remote context. This must be completely unique for a remote context instance, regardless of the context identity.

Specified by:
getRemoteContextHashCode in interface IConnectionParameters
Returns:
a unique integer for the remote context

isEqual

public boolean isEqual(IConnectionParameters connectionParameters)
Description copied from interface: IConnectionParameters
Checks the connection parameters for equality. The implementation should not make any class match checks in this method because an IConnection instance extends this.

It is a requirement that, if a connection is outbound ( IConnection.isOutbound()) and based on these parameters, parameters.isEqual(connection) is true.

 IConnectionParameters parameters = ...
 broker.connect(parameters);
 IConnection connection = ... // connection created by the broker 
 // this will be true
 parameters.isEqual(connection);
 

Specified by:
isEqual in interface IConnectionParameters
Parameters:
connectionParameters - the other set of connection parameters to compare with this
Returns:
true if the two parameters represent the same connection attributes

doDestroy

protected void doDestroy()
Description copied from class: AbstractLifeCycle
Overridden in subclasses to perform custom logic on destruction. Any exceptions should be thrown as a RuntimeException or subclass thereof.

Specified by:
doDestroy in class AbstractLifeCycle

doStart

protected void doStart()
Description copied from class: AbstractLifeCycle
Overridden in subclasses to perform custom logic on activation. Any exceptions should be thrown as a RuntimeException or subclass thereof. When this method is called, the AbstractLifeCycle.isActive() method will return true.

Specified by:
doStart in class AbstractLifeCycle

toString

public String toString()
Overrides:
toString in class AbstractLifeCycle

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2007-2009. All Rights Reserved.