org.exolab.jms.net.socket
Class SocketManagedConnectionAcceptor

java.lang.Object
  |
  +--org.exolab.jms.net.socket.SocketManagedConnectionAcceptor
All Implemented Interfaces:
ManagedConnectionAcceptor

public abstract class SocketManagedConnectionAcceptor
extends java.lang.Object
implements ManagedConnectionAcceptor

A ManagedConnectionAcceptor for accepting socket connections.

Version:
$Revision: 1.8 $ $Date: 2006/12/16 12:37:17 $
Author:
Tim Anderson

Constructor Summary
SocketManagedConnectionAcceptor(Authenticator authenticator, SocketRequestInfo info)
          Construct a new SocketManagedConnectionAcceptor.
 
Method Summary
 void accept(ManagedConnectionAcceptorListener listener)
          Start accepting connections.
 void close()
          Stop accepting connection requests, and clean up any allocated resources.
protected abstract  ManagedConnection createManagedConnection(URI uri, java.net.Socket socket, Authenticator authenticator)
          Create a new server-side ManagedConnection for an accepted socket connection.
protected  java.net.ServerSocket createServerSocket(int port, int backlog, java.net.InetAddress host)
          Create a new server socket.
 SocketRequestInfo getRequestInfo()
          Returns the connection request info used to construct this.
 URI getURI()
          Returns the URI that this acceptor is accepting connections on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketManagedConnectionAcceptor

public SocketManagedConnectionAcceptor(Authenticator authenticator,
                                       SocketRequestInfo info)
                                throws ResourceException
Construct a new SocketManagedConnectionAcceptor.

This creates a server socket with the specified port and listen backlog.

If SocketRequestInfo.getBindAll() flag can be used on multi-homed hosts to limit the addresses on which connections are accepted. If false, the socket will only accept connections on the address specified by URIRequestInfo.getHostAddress(). If true it will accept connections on all local addresses.

The port returned by URIRequestInfo.getPort() must be between 0 and 65535, inclusive

Parameters:
authenticator - the connection authenticator
info - the connection request info
Throws:
ResourceException - if a server socket cannot be created
Method Detail

accept

public void accept(ManagedConnectionAcceptorListener listener)
            throws ResourceException
Start accepting connections.
Specified by:
accept in interface ManagedConnectionAcceptor
Parameters:
listener - the listener to delegate accepted connections to
Throws:
ResourceException - if connections cannot be accepted

getRequestInfo

public SocketRequestInfo getRequestInfo()
Returns the connection request info used to construct this.
Returns:
the connection request info

getURI

public URI getURI()
Returns the URI that this acceptor is accepting connections on.
Specified by:
getURI in interface ManagedConnectionAcceptor
Returns:
the URI that this acceptor is accepting connections on

close

public void close()
           throws ResourceException
Stop accepting connection requests, and clean up any allocated resources.
Specified by:
close in interface ManagedConnectionAcceptor
Throws:
ResourceException - generic exception if the operation fails

createServerSocket

protected java.net.ServerSocket createServerSocket(int port,
                                                   int backlog,
                                                   java.net.InetAddress host)
                                            throws java.io.IOException
Create a new server socket.
Parameters:
port - the port to listen on
backlog - the listen backlog
host - if non-null, specifies to only accept connections to the specified address. If null, accept connections on any/all local addresses.
Returns:
a new server socket, listening on port
Throws:
java.io.IOException - if the socket can't be created

createManagedConnection

protected abstract ManagedConnection createManagedConnection(URI uri,
                                                             java.net.Socket socket,
                                                             Authenticator authenticator)
                                                      throws ResourceException
Create a new server-side ManagedConnection for an accepted socket connection.
Parameters:
uri - the URI denoting this acceptor
socket - the accepted socket connection
authenticator - the connection authenticator
Returns:
a new server-side managed connection
Throws:
ResourceException - if the managed connection can't be created


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.