com.sun.sgs.impl.io
Class SocketAcceptor

java.lang.Object
  extended by com.sun.sgs.impl.io.SocketAcceptor
All Implemented Interfaces:
Acceptor<SocketAddress>

 class SocketAcceptor
extends Object
implements Acceptor<SocketAddress>

This is an implementation of an Acceptor that uses a MINA IoAcceptor to accept incoming connections.

Its constructor is package-private, so use ServerEndpoint.createAcceptor() to create an instance. This implementation is thread-safe.


Nested Class Summary
(package private) static class SocketAcceptor.AcceptHandler
          Internal adaptor class to handle events from the acceptor itself.
 
Constructor Summary
SocketAcceptor(ServerSocketEndpoint endpoint, org.apache.mina.common.IoAcceptor acceptor)
          Constructs a SocketAcceptor with the given MINA IoAcceptor.
 
Method Summary
 ServerSocketEndpoint getBoundEndpoint()
          Returns the ServerEndpoint on which this Acceptor is listening.
 ServerSocketEndpoint getEndpoint()
          Returns the ServerEndpoint this Acceptor was created with.
 void listen(AcceptorListener listener)
          Passively accepts incoming connections on the associated ServerEndpoint.
 void shutdown()
          Shuts down this Acceptor, releasing any resources in use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketAcceptor

SocketAcceptor(ServerSocketEndpoint endpoint,
               org.apache.mina.common.IoAcceptor acceptor)
Constructs a SocketAcceptor with the given MINA IoAcceptor.

Parameters:
endpoint - the local address to which to listen
acceptor - the MINA IoAcceptor to use for the underlying IO processing
Method Detail

listen

public void listen(AcceptorListener listener)
            throws IOException
Passively accepts incoming connections on the associated ServerEndpoint. This call may block until listening succeeds, but does not block to wait for incoming connections. Each accepted connection will result in an asynchronous call to newConnection on the given listener.

This implementation ensures that only complete messages are delivered on the connections that it accepts.

Specified by:
listen in interface Acceptor<SocketAddress>
Parameters:
listener - the listener that will be notified of new connections
Throws:
IOException - if there was a problem listening on the ServerEndpoint

getEndpoint

public ServerSocketEndpoint getEndpoint()
Returns the ServerEndpoint this Acceptor was created with.

Specified by:
getEndpoint in interface Acceptor<SocketAddress>
Returns:
the ServerEndpoint this Acceptor was created with

getBoundEndpoint

public ServerSocketEndpoint getBoundEndpoint()
Returns the ServerEndpoint on which this Acceptor is listening.

Specified by:
getBoundEndpoint in interface Acceptor<SocketAddress>
Returns:
the ServerEndpoint on which this Acceptor is listening

shutdown

public void shutdown()
Shuts down this Acceptor, releasing any resources in use. Once shutdown, an Acceptor cannot be restarted.

Specified by:
shutdown in interface Acceptor<SocketAddress>

Project Darkstar, Version 0.9.9.2
2013-07-29 20:45:08

Copyright © 2007-2013 Sun Microsystems, Inc. All rights reserved