org.jdiameter.client.impl.transport.tcp
Class TCPClientConnection

java.lang.Object
  extended by org.jdiameter.client.impl.transport.tcp.TCPClientConnection
All Implemented Interfaces:
org.jdiameter.api.Wrapper, IConnection
Direct Known Subclasses:
TLSClientConnection

public class TCPClientConnection
extends java.lang.Object
implements IConnection


Field Summary
protected  java.util.concurrent.ConcurrentLinkedQueue<IConnectionListener> listeners
           
protected  IMessageParser parser
           
protected  java.lang.Object zero
           
 
Constructor Summary
  TCPClientConnection(org.jdiameter.api.Configuration config, java.net.InetAddress address, int port, IConnectionListener listener, IMessageParser parser, java.lang.String ref)
           
  TCPClientConnection(org.jdiameter.api.Configuration config, java.net.InetAddress address, int port, IMessageParser parser, java.lang.String ref)
           
  TCPClientConnection(org.jdiameter.api.Configuration config, java.net.Socket socket, IMessageParser p, java.lang.String ref)
           
protected TCPClientConnection(IMessageParser parser)
           
 
Method Summary
 void addConnectionListener(IConnectionListener connectionListener)
          Append connection listener
 void connect()
          Connect with remote host
 void disconnect()
          Disconnect wit remote host
protected  org.jdiameter.client.impl.transport.tcp.TCPTransportClient getClient()
           
 java.lang.String getKey()
          Return identifier of connection.
 java.net.InetAddress getRemoteAddress()
          Return remote host address
 int getRemotePort()
          Return remote socket port
 boolean isConnected()
          Return true if is connection is valid
 boolean isNetworkInitiated()
          Return true if connection is incomming
 boolean isWrapperFor(java.lang.Class<?> aClass)
           
 void release()
          Clear all attachec resources (close socket)
 void remConnectionListener(IConnectionListener connectionListener)
          Remove connection listener
 void sendMessage(IMessage message)
          Send message to remote host
<T> T
unwrap(java.lang.Class<T> aClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

protected IMessageParser parser

zero

protected final java.lang.Object zero

listeners

protected java.util.concurrent.ConcurrentLinkedQueue<IConnectionListener> listeners
Constructor Detail

TCPClientConnection

protected TCPClientConnection(IMessageParser parser)

TCPClientConnection

public TCPClientConnection(org.jdiameter.api.Configuration config,
                           java.net.Socket socket,
                           IMessageParser p,
                           java.lang.String ref)
                    throws java.lang.Exception
Throws:
java.lang.Exception

TCPClientConnection

public TCPClientConnection(org.jdiameter.api.Configuration config,
                           java.net.InetAddress address,
                           int port,
                           IMessageParser parser,
                           java.lang.String ref)

TCPClientConnection

public TCPClientConnection(org.jdiameter.api.Configuration config,
                           java.net.InetAddress address,
                           int port,
                           IConnectionListener listener,
                           IMessageParser parser,
                           java.lang.String ref)
Method Detail

connect

public void connect()
             throws TransportException
Description copied from interface: IConnection
Connect with remote host

Specified by:
connect in interface IConnection
Throws:
TransportException

disconnect

public void disconnect()
                throws java.lang.InternalError
Description copied from interface: IConnection
Disconnect wit remote host

Specified by:
disconnect in interface IConnection
Throws:
java.lang.InternalError

release

public void release()
             throws java.io.IOException
Description copied from interface: IConnection
Clear all attachec resources (close socket)

Specified by:
release in interface IConnection
Throws:
java.io.IOException

sendMessage

public void sendMessage(IMessage message)
                 throws TransportException,
                        org.jdiameter.api.OverloadException
Description copied from interface: IConnection
Send message to remote host

Specified by:
sendMessage in interface IConnection
Parameters:
message - diameter message
Throws:
TransportException
org.jdiameter.api.OverloadException

getClient

protected org.jdiameter.client.impl.transport.tcp.TCPTransportClient getClient()

isNetworkInitiated

public boolean isNetworkInitiated()
Description copied from interface: IConnection
Return true if connection is incomming

Specified by:
isNetworkInitiated in interface IConnection
Returns:
true if connection is incomming

isConnected

public boolean isConnected()
Description copied from interface: IConnection
Return true if is connection is valid

Specified by:
isConnected in interface IConnection
Returns:
true if is connection is valid

getRemoteAddress

public java.net.InetAddress getRemoteAddress()
Description copied from interface: IConnection
Return remote host address

Specified by:
getRemoteAddress in interface IConnection
Returns:
remote host address

getRemotePort

public int getRemotePort()
Description copied from interface: IConnection
Return remote socket port

Specified by:
getRemotePort in interface IConnection
Returns:
remote socket port

addConnectionListener

public void addConnectionListener(IConnectionListener connectionListener)
Description copied from interface: IConnection
Append connection listener

Specified by:
addConnectionListener in interface IConnection
Parameters:
connectionListener - listener instance

remConnectionListener

public void remConnectionListener(IConnectionListener connectionListener)
Description copied from interface: IConnection
Remove connection listener

Specified by:
remConnectionListener in interface IConnection
Parameters:
connectionListener - listener instance

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> aClass)
                     throws org.jdiameter.api.InternalException
Specified by:
isWrapperFor in interface org.jdiameter.api.Wrapper
Throws:
org.jdiameter.api.InternalException

unwrap

public <T> T unwrap(java.lang.Class<T> aClass)
         throws org.jdiameter.api.InternalException
Specified by:
unwrap in interface org.jdiameter.api.Wrapper
Throws:
org.jdiameter.api.InternalException

getKey

public java.lang.String getKey()
Description copied from interface: IConnection
Return identifier of connection. For example: "[remote_host_name]:[remote_port]"

Specified by:
getKey in interface IConnection
Returns:
identifier of connection.


Copyright © 2008. All Rights Reserved.