public class ConnectionBroker extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ConnectionBroker.Transport
Enumeration indicating whether plain or ssl connection is used.
|
Modifier and Type | Field and Description |
---|---|
protected int |
backlog
Maximum socket queue backlog.
|
protected InetAddress |
bindAddress
Interface address to bind the socket to; if null, bind to all.
|
protected int |
port
Port on which the channel is bound.
|
protected ServerSocket |
socket |
protected ServerSocketFactory |
socketFactory
Factory to be used for creating the channel server socket.
|
Constructor and Description |
---|
ConnectionBroker()
Creates a client-side-only connection broker using plain-text transport.
|
ConnectionBroker(int port)
Creates a server-side connection broker for hosting connections on the
specified port.
|
ConnectionBroker(int port,
InetAddress bindAddress)
Creates a server-side connection broker for hosting connections on the
specified port and adapter.
|
Modifier and Type | Method and Description |
---|---|
Connection |
accept(String name,
ConversationProvider resolver)
Host and accept a connection on the specified network port.
|
Connection |
accept(String name,
ConversationProvider resolver,
ConnectionListener listener)
Host and accept a connection on the specified network port.
|
void |
close()
Close the broker server socket.
|
Connection |
connect(String name,
String host,
int port,
ConnectionBroker.Transport transport,
ConversationProvider resolver)
Make a connection to the given host and on the specified network port.
|
Connection |
connect(String name,
String host,
int port,
ConnectionBroker.Transport transport,
ConversationProvider resolver,
ConnectionListener listener)
Make a connection to the given host and on the specified network port.
|
Connection |
connect(String name,
String host,
int port,
ConversationProvider resolver)
Make a plain-text connection to the given host and on the specified
network port.
|
protected void |
finalize() |
int |
getBacklog()
Get the maximum backlog.
|
InetAddress |
getBindAddress()
Get the address on which this server-side broker socket is (to be) bound.
|
int |
getPort()
Get the port to which this channel is currently bound.
|
ServerSocket |
getSocket()
Get the server socket.
|
ServerSocketFactory |
getSocketFactory()
Get the socket factory used to generate the broker server socket.
|
void |
setBacklog(int backlog)
Set the maximum backlog.
|
void |
setBindAddress(InetAddress bindAddress)
Set the address on which this server-side broker socket is to be bound.
|
void |
setSocketFactory(ServerSocketFactory socketFactory)
Set the socket factory used to generate the broker server socket.
|
protected ServerSocketFactory socketFactory
protected ServerSocket socket
protected int port
protected int backlog
protected InetAddress bindAddress
public ConnectionBroker()
public ConnectionBroker(int port)
port
- tcp/ip port on which to listen for connectionspublic ConnectionBroker(int port, InetAddress bindAddress)
port
- tcp/ip port on which to listen for connectionsbindAddress
- adapter addresspublic ServerSocket getSocket() throws IOException
IOException
- thrown if an error is encountered while creating a
server socketprotected void finalize() throws Throwable
public Connection accept(String name, ConversationProvider resolver, ConnectionListener listener) throws IOException
name
- name to give the accepted connectionresolver
- conversation provider to be assigned to the new
connectionlistener
- connection listener to be assigned to the newly created
connectionIOException
- thrown if an error is encountered while accepting a
connectionpublic Connection accept(String name, ConversationProvider resolver) throws IOException
name
- name to give the accepted connectionresolver
- conversation provider to be assigned to the new
connectionIOException
- thrown if an error is encountered while accepting a
connectionpublic Connection connect(String name, String host, int port, ConversationProvider resolver) throws IOException
name
- name to give the accepted connectionhost
- IP or DNS name of the host to which the connectport
- IP network port to connect toresolver
- conversation provider to be assigned to the new
connectionIOException
- thrown if an error is encountered during connectingpublic Connection connect(String name, String host, int port, ConnectionBroker.Transport transport, ConversationProvider resolver, ConnectionListener listener) throws IOException
name
- name to give the accepted connectionhost
- IP or DNS name of the host to which the connectport
- IP network port to connect totransport
- indicates whether to use a plain-text or SSL socketresolver
- conversation provider to be assigned to the new
connectionlistener
- connection listener to be applied before the connection
is startedIOException
- thrown if an error is encountered during connectingpublic Connection connect(String name, String host, int port, ConnectionBroker.Transport transport, ConversationProvider resolver) throws IOException
name
- name to give the accepted connectionhost
- IP or DNS name of the host to which the connectport
- IP network port to connect totransport
- indicates whether to use a plain-text or SSL socketresolver
- conversation provider to be assigned to the new
connectionIOException
- thrown if an error is encountered during connectingpublic int getPort()
public int getBacklog()
public void setBacklog(int backlog)
backlog
- maximum size of the backlog queuepublic InetAddress getBindAddress()
public void setBindAddress(InetAddress bindAddress)
bindAddress
- adapter address on which to bind the channel socketpublic ServerSocketFactory getSocketFactory()
public void setSocketFactory(ServerSocketFactory socketFactory)
socketFactory
- server socket factorypublic void close() throws IOException
IOException
- thrown if an error is encountered during closing
the connection socketCopyright © 2015. All Rights Reserved.