org.mortbay.jetty.bio
Class SocketConnector

java.lang.Object
  extended byorg.mortbay.component.AbstractLifeCycle
      extended byorg.mortbay.jetty.AbstractConnector
          extended byorg.mortbay.jetty.bio.SocketConnector
All Implemented Interfaces:
Buffers, Connector, LifeCycle
Direct Known Subclasses:
SslSocketConnector

public class SocketConnector
extends AbstractConnector

Socket Connector. This connector implements a traditional blocking IO and threading model. Normal JRE sockets are used and a thread is allocated per connection. Buffers are managed so that large buffers are only allocated to active connections. This Connector should only be used if NIO is not available.

Author:
gregw

Nested Class Summary
protected  class SocketConnector.Connection
           
 
Field Summary
protected  ServerSocket _serverSocket
           
 
Fields inherited from class org.mortbay.jetty.AbstractConnector
_lowResourceMaxIdleTime, _maxIdleTime, _soLingerTime
 
Constructor Summary
SocketConnector()
          Constructor.
 
Method Summary
 void accept(int acceptorID)
           
 void close()
           
 void customize(EndPoint endpoint, Request request)
          Customize a request for an endpoint.
 Object getConnection()
           
 int getLocalPort()
           
protected  Buffer newBuffer(int size)
           
protected  ServerSocket newServerSocket(String host, int port, int backlog)
           
 void open()
          Opens the connector
 
Methods inherited from class org.mortbay.jetty.AbstractConnector
configure, connectionClosed, connectionOpened, doStart, doStop, getAcceptors, getAcceptQueueSize, getBuffer, getConfidentialPort, getConfidentialScheme, getConnections, getConnectionsDurationAve, getConnectionsDurationMax, getConnectionsDurationMin, getConnectionsDurationTotal, getConnectionsOpen, getConnectionsOpenMax, getConnectionsOpenMin, getConnectionsRequestsAve, getConnectionsRequestsMax, getConnectionsRequestsMin, getHeaderBufferSize, getHost, getIntegralPort, getIntegralScheme, getLowResourceMaxIdleTime, getMaxIdleTime, getName, getPort, getRequestBufferSize, getRequests, getResolveNames, getResponseBufferSize, getServer, getSoLingerTime, getStatsOn, getStatsOnMs, getThreadPool, isConfidential, isIntegral, join, newContinuation, returnBuffer, setAcceptors, setAcceptQueueSize, setConfidentialPort, setConfidentialScheme, setHeaderBufferSize, setHost, setIntegralPort, setIntegralScheme, setLowResourceMaxIdleTime, setMaxIdleTime, setName, setPort, setRequestBufferSize, setResolveNames, setResponseBufferSize, setServer, setSoLingerTime, setStatsOn, setThreadPool, statsReset, toString
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mortbay.component.LifeCycle
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop
 

Field Detail

_serverSocket

protected ServerSocket _serverSocket
Constructor Detail

SocketConnector

public SocketConnector()
Constructor.

Method Detail

getConnection

public Object getConnection()
Returns:
the underlying socket, channel, buffer etc. for the connector.

open

public void open()
          throws IOException
Description copied from interface: Connector
Opens the connector

Specified by:
open in interface Connector
Specified by:
open in class AbstractConnector
Throws:
IOException

newServerSocket

protected ServerSocket newServerSocket(String host,
                                       int port,
                                       int backlog)
                                throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException

accept

public void accept(int acceptorID)
            throws IOException,
                   InterruptedException
Specified by:
accept in class AbstractConnector
Throws:
IOException
InterruptedException

newBuffer

protected Buffer newBuffer(int size)
Specified by:
newBuffer in class AbstractConnector

customize

public void customize(EndPoint endpoint,
                      Request request)
               throws IOException
Description copied from interface: Connector
Customize a request for an endpoint. Called on every request to allow customization of the request for the particular endpoint (eg security properties from a SSL connection).

Specified by:
customize in interface Connector
Overrides:
customize in class AbstractConnector
Throws:
IOException

getLocalPort

public int getLocalPort()
Returns:
The actual port the connector is listening on or -1 if there is no port or the connector is not open.