org.mortbay.jetty
Interface Connector
- All Superinterfaces:
- Buffers, LifeCycle
- All Known Implementing Classes:
- AbstractConnector
- 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
getName
public String getName()
- Returns:
- the name of the connector. Defaults to the HostName:port
open
public void open()
throws IOException
- Opens the connector
- Throws:
IOException
close
public void close()
throws IOException
- Throws:
IOException
setServer
public void setServer(Server server)
getServer
public Server getServer()
getHeaderBufferSize
public int getHeaderBufferSize()
- Returns:
- Returns the headerBufferSize.
setHeaderBufferSize
public 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
public int getRequestBufferSize()
- Returns:
- Returns the requestBufferSize.
setRequestBufferSize
public 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
public int getResponseBufferSize()
- Returns:
- Returns the responseBufferSize.
setResponseBufferSize
public 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
public int getIntegralPort()
getIntegralScheme
public String getIntegralScheme()
isIntegral
public boolean isIntegral(Request request)
getConfidentialPort
public int getConfidentialPort()
getConfidentialScheme
public String getConfidentialScheme()
isConfidential
public boolean isConfidential(Request request)
customize
public 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
newContinuation
public Continuation newContinuation()
getHost
public String getHost()
setHost
public void setHost(String hostname)
setPort
public void setPort(int port)
- Parameters:
port
- The port fto listen of for connections or 0 if any available
port may be used.
getPort
public int getPort()
- Returns:
- The configured port for the connector or 0 if any available
port may be used.
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.
getMaxIdleTime
public int getMaxIdleTime()
setMaxIdleTime
public void setMaxIdleTime(int ms)
getLowResourceMaxIdleTime
public int getLowResourceMaxIdleTime()
setLowResourceMaxIdleTime
public void setLowResourceMaxIdleTime(int ms)
getConnection
public Object getConnection()
- Returns:
- the underlying socket, channel, buffer etc. for the connector.
getResolveNames
public boolean getResolveNames()
- Returns:
- true if names resolution should be done.
getRequests
public 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
public long getConnectionsDurationMin()
- Returns:
- Returns the connectionsDurationMin.
getConnectionsDurationTotal
public long getConnectionsDurationTotal()
- Returns:
- Returns the connectionsDurationTotal.
getConnectionsOpenMin
public int getConnectionsOpenMin()
- Returns:
- Returns the connectionsOpenMin.
getConnectionsRequestsMin
public int getConnectionsRequestsMin()
- Returns:
- Returns the connectionsRequestsMin.
getConnections
public int getConnections()
- Returns:
- Number of connections accepted by the server since
statsReset() called. Undefined if setStatsOn(false).
getConnectionsOpen
public int getConnectionsOpen()
- Returns:
- Number of connections currently open that were opened
since statsReset() called. Undefined if setStatsOn(false).
getConnectionsOpenMax
public int getConnectionsOpenMax()
- Returns:
- Maximum number of connections opened simultaneously
since statsReset() called. Undefined if setStatsOn(false).
getConnectionsDurationAve
public long getConnectionsDurationAve()
- Returns:
- Average duration in milliseconds of open connections
since statsReset() called. Undefined if setStatsOn(false).
getConnectionsDurationMax
public long getConnectionsDurationMax()
- Returns:
- Maximum duration in milliseconds of an open connection
since statsReset() called. Undefined if setStatsOn(false).
getConnectionsRequestsAve
public int getConnectionsRequestsAve()
- Returns:
- Average number of requests per connection
since statsReset() called. Undefined if setStatsOn(false).
getConnectionsRequestsMax
public int getConnectionsRequestsMax()
- Returns:
- Maximum number of requests per connection
since statsReset() called. Undefined if setStatsOn(false).
statsReset
public void statsReset()
- Reset statistics.
setStatsOn
public void setStatsOn(boolean on)
getStatsOn
public boolean getStatsOn()
- Returns:
- True if statistics collection is turned on.
getStatsOnMs
public long getStatsOnMs()
- Returns:
- Timestamp stats were started at.