org.eclipse.jetty.server
Interface Connector

All Superinterfaces:
LifeCycle
All Known Subinterfaces:
SslConnector
All Known Implementing Classes:
AbstractConnector, AbstractNIOConnector, Ajp13SocketConnector, BlockingChannelConnector, InheritedChannelConnector, LocalConnector, SelectChannelConnector, SocketConnector, SslSelectChannelConnector, SslSocketConnector

public interface Connector
extends LifeCycle

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.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
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()
           
 String getHost()
           
 int getIntegralPort()
           
 String getIntegralScheme()
           
 int getLocalPort()
           
 int getLowResourceMaxIdleTime()
           
 int getMaxIdleTime()
           
 String getName()
           
 int getPort()
           
 Buffers getRequestBuffers()
           
 int getRequestBufferSize()
           
 int getRequestHeaderSize()
           
 int getRequests()
           
 boolean getResolveNames()
           
 Buffers getResponseBuffers()
           
 int getResponseBufferSize()
           
 int getResponseHeaderSize()
           
 Server getServer()
           
 boolean getStatsOn()
           
 long getStatsOnMs()
           
 boolean isConfidential(Request request)
           
 boolean isIntegral(Request request)
           
 boolean isLowResources()
          Check if low on resources.
 void open()
          Opens the connector
 void persist(EndPoint endpoint)
          Persist an endpoint.
 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 setRequestHeaderSize(int size)
          Set the size of the buffer to be used for request headers.
 void setResponseBufferSize(int responseBufferSize)
          Set the size of the content buffer for sending responses.
 void setResponseHeaderSize(int size)
          Set the size of the buffer to be used for request headers.
 void setServer(Server server)
           
 void setStatsOn(boolean on)
           
 void statsReset()
          Reset statistics.
 
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

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()

getRequestHeaderSize

int getRequestHeaderSize()
Returns:
Returns the request header buffer size in bytes.

setRequestHeaderSize

void setRequestHeaderSize(int size)
Set the size of the buffer to be used for request headers.

Parameters:
size - The size in bytes.

getResponseHeaderSize

int getResponseHeaderSize()
Returns:
Returns the response header buffer size in bytes.

setResponseHeaderSize

void setResponseHeaderSize(int size)
Set the size of the buffer to be used for request headers.

Parameters:
size - The size in bytes.

getRequestBuffers

Buffers getRequestBuffers()
Returns:
factory for request buffers

getResponseBuffers

Buffers getResponseBuffers()
Returns:
factory for response buffers

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()
Returns:
The port to use when redirecting a request if a data constraint of integral is required. See org.eclipse.jetty.server.server.security.Constraint#getDataConstraint()

getIntegralScheme

String getIntegralScheme()
Returns:
The schema to use when redirecting a request if a data constraint of integral is required. See org.eclipse.jetty.server.server.security.Constraint#getDataConstraint()

isIntegral

boolean isIntegral(Request request)
Parameters:
request - A request
Returns:
true if the request is integral. This normally means the https schema has been used.

getConfidentialPort

int getConfidentialPort()
Returns:
The port to use when redirecting a request if a data constraint of confidential is required. See org.eclipse.jetty.server.server.security.Constraint#getDataConstraint()

getConfidentialScheme

String getConfidentialScheme()
Returns:
The schema to use when redirecting a request if a data constraint of confidential is required. See org.eclipse.jetty.server.server.security.Constraint#getDataConstraint()

isConfidential

boolean isConfidential(Request request)
Parameters:
request - A request
Returns:
true if the request is confidential. This normally means the https schema has been used.

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

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.

isLowResources

boolean isLowResources()
Check if low on resources. For most connectors, low resources is measured by calling ThreadPool.isLowOnThreads() on the connector threadpool or the server threadpool if there is no connector threadpool.

For blocking connectors, low resources is used to trigger usage of getLowResourceMaxIdleTime() for the timeout of an idle connection.

for non-blocking connectors, the number of connections is used instead of this method, to select the timeout of an idle connection.

For all connectors, low resources is used to trigger the usage of getLowResourceMaxIdleTime() for read and write operations.

Returns:
true if this connector is low on resources.


Copyright © 1995-2009 Mort Bay Consulting. All Rights Reserved.