org.mortbay.jetty
Interface Connector

All Superinterfaces:
Buffers, LifeCycle
All Known Implementing Classes:
AbstractConnector, AbstractNIOConnector, BlockingChannelConnector, LocalConnector, SelectChannelConnector, SocketConnector, SslSocketConnector

public interface Connector
extends LifeCycle, Buffers

HTTP Connector. Implementations of this interface provide connectors for the HTTP protocol. A connector receives requests (normally from a socket) and calls the handle method of the Handler object. These operations are performed using threads from the ThreadPool set on the connector. When a connector is registered with an instance of Server, then the server will set itself as both the ThreadPool and the Handler. Note that a connector can be used without a Server if a thread pool and handler are directly provided.

Author:
gregw

Method Summary
 void close()
           
 void customize(EndPoint endpoint, Request request)
          Customize a request for an endpoint.
 int getConfidentialPort()
           
 String getConfidentialScheme()
           
 Object getConnection()
           
 int getConnections()
           
 long getConnectionsDurationAve()
           
 long getConnectionsDurationMax()
           
 long getConnectionsDurationMin()
           
 long getConnectionsDurationTotal()
           
 int getConnectionsOpen()
           
 int getConnectionsOpenMax()
           
 int getConnectionsOpenMin()
           
 int getConnectionsRequestsAve()
           
 int getConnectionsRequestsMax()
           
 int getConnectionsRequestsMin()
           
 int getHeaderBufferSize()
           
 String getHost()
           
 int getIntegralPort()
           
 String getIntegralScheme()
           
 int getLocalPort()
           
 int getLowResourceMaxIdleTime()
           
 int getMaxIdleTime()
           
 String getName()
           
 int getPort()
           
 int getRequestBufferSize()
           
 int getRequests()
           
 boolean getResolveNames()
           
 int getResponseBufferSize()
           
 Server getServer()
           
 boolean getStatsOn()
           
 long getStatsOnMs()
           
 boolean isConfidential(Request request)
           
 boolean isIntegral(Request request)
           
 Continuation newContinuation()
           
 void open()
          Opens the connector
 void persist(EndPoint endpoint)
          Persist an endpoint.
 void setHeaderBufferSize(int headerBufferSize)
          Set the size of the buffer to be used for request and response headers.
 void setHost(String hostname)
           
 void setLowResourceMaxIdleTime(int ms)
           
 void setMaxIdleTime(int ms)
           
 void setPort(int port)
           
 void setRequestBufferSize(int requestBufferSize)
          Set the size of the content buffer for receiving requests.
 void setResponseBufferSize(int responseBufferSize)
          Set the size of the content buffer for sending responses.
 void setServer(Server server)
           
 void setStatsOn(boolean on)
           
 void statsReset()
          Reset statistics.
 
Methods inherited from interface org.mortbay.component.LifeCycle
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop
 
Methods inherited from interface org.mortbay.io.Buffers
getBuffer, returnBuffer
 

Method Detail

getName

String getName()
Returns:
the name of the connector. Defaults to the HostName:port

open

void open()
          throws IOException
Opens the connector

Throws:
IOException

close

void close()
           throws IOException
Throws:
IOException

setServer

void setServer(Server server)

getServer

Server getServer()

getHeaderBufferSize

int getHeaderBufferSize()
Returns:
Returns the headerBufferSize.

setHeaderBufferSize

void setHeaderBufferSize(int headerBufferSize)
Set the size of the buffer to be used for request and response headers. An idle connection will at most have one buffer of this size allocated.

Parameters:
headerBufferSize - The headerBufferSize to set.

getRequestBufferSize

int getRequestBufferSize()
Returns:
Returns the requestBufferSize.

setRequestBufferSize

void setRequestBufferSize(int requestBufferSize)
Set the size of the content buffer for receiving requests. These buffers are only used for active connections that have requests with bodies that will not fit within the header buffer.

Parameters:
requestBufferSize - The requestBufferSize to set.

getResponseBufferSize

int getResponseBufferSize()
Returns:
Returns the responseBufferSize.

setResponseBufferSize

void setResponseBufferSize(int responseBufferSize)
Set the size of the content buffer for sending responses. These buffers are only used for active connections that are sending responses with bodies that will not fit within the header buffer.

Parameters:
responseBufferSize - The responseBufferSize to set.

getIntegralPort

int getIntegralPort()

getIntegralScheme

String getIntegralScheme()

isIntegral

boolean isIntegral(Request request)

getConfidentialPort

int getConfidentialPort()

getConfidentialScheme

String getConfidentialScheme()

isConfidential

boolean isConfidential(Request request)

customize

void customize(EndPoint endpoint,
               Request request)
               throws IOException
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).

Parameters:
endpoint -
request -
Throws:
IOException

persist

void persist(EndPoint endpoint)
             throws IOException
Persist an endpoint. Called after every request if the connection is to remain open.

Parameters:
endpoint -
request -
Throws:
IOException

newContinuation

Continuation newContinuation()

getHost

String getHost()

setHost

void setHost(String hostname)

setPort

void setPort(int port)
Parameters:
port - The port fto listen of for connections or 0 if any available port may be used.

getPort

int getPort()
Returns:
The configured port for the connector or 0 if any available port may be used.

getLocalPort

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

getMaxIdleTime

int getMaxIdleTime()

setMaxIdleTime

void setMaxIdleTime(int ms)

getLowResourceMaxIdleTime

int getLowResourceMaxIdleTime()

setLowResourceMaxIdleTime

void setLowResourceMaxIdleTime(int ms)

getConnection

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

getResolveNames

boolean getResolveNames()
Returns:
true if names resolution should be done.

getRequests

int getRequests()
Returns:
Get the number of requests handled by this connector since last call of statsReset(). If setStatsOn(false) then this is undefined.

getConnectionsDurationMin

long getConnectionsDurationMin()
Returns:
Returns the connectionsDurationMin.

getConnectionsDurationTotal

long getConnectionsDurationTotal()
Returns:
Returns the connectionsDurationTotal.

getConnectionsOpenMin

int getConnectionsOpenMin()
Returns:
Returns the connectionsOpenMin.

getConnectionsRequestsMin

int getConnectionsRequestsMin()
Returns:
Returns the connectionsRequestsMin.

getConnections

int getConnections()
Returns:
Number of connections accepted by the server since statsReset() called. Undefined if setStatsOn(false).

getConnectionsOpen

int getConnectionsOpen()
Returns:
Number of connections currently open that were opened since statsReset() called. Undefined if setStatsOn(false).

getConnectionsOpenMax

int getConnectionsOpenMax()
Returns:
Maximum number of connections opened simultaneously since statsReset() called. Undefined if setStatsOn(false).

getConnectionsDurationAve

long getConnectionsDurationAve()
Returns:
Average duration in milliseconds of open connections since statsReset() called. Undefined if setStatsOn(false).

getConnectionsDurationMax

long getConnectionsDurationMax()
Returns:
Maximum duration in milliseconds of an open connection since statsReset() called. Undefined if setStatsOn(false).

getConnectionsRequestsAve

int getConnectionsRequestsAve()
Returns:
Average number of requests per connection since statsReset() called. Undefined if setStatsOn(false).

getConnectionsRequestsMax

int getConnectionsRequestsMax()
Returns:
Maximum number of requests per connection since statsReset() called. Undefined if setStatsOn(false).

statsReset

void statsReset()
Reset statistics.


setStatsOn

void setStatsOn(boolean on)

getStatsOn

boolean getStatsOn()
Returns:
True if statistics collection is turned on.

getStatsOnMs

long getStatsOnMs()
Returns:
Timestamp stats were started at.