Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.jetty
Class AbstractConnector

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.mortbay.jetty.AbstractBuffers
              org.mortbay.jetty.AbstractConnector

All Implemented Interfaces:
  LifeCycle, Buffers, Connector

Direct Known Subclasses:
  AbstractNIOConnector, LocalConnector, SocketConnector

    public abstract class AbstractConnector

extends AbstractBuffers
implements Connector

Abstract Connector implementation. This abstract implementation of the Connector interface provides:

- AbstractLifeCycle implementation
- Implementations for connector getters and setters
- Buffer management
- Socket configuration
- Base acceptor thread
- Optional reverse proxy headers checking

Author:
  gregw TODO - allow multiple Acceptor threads

Nested Class Summary

Nested classes/interfaces inherited from class org.mortbay.jetty.AbstractBuffers
`AbstractBuffers.ThreadBuffers`

Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle
`LifeCycle.Listener`

Field Summary
`protected int` | `_lowResourceMaxIdleTime`
`protected int` | `_maxIdleTime`
`protected int` | `_soLingerTime`

Fields inherited from class org.mortbay.component.AbstractLifeCycle
`_listeners`

Constructor Summary
`AbstractConnector()`

Method Summary
`protected abstract void` | `accept(int acceptorID)`
`protected void` | `checkForwardedHeaders(EndPoint endpoint, Request request)`
`protected void` | `configure(java.net.Socket socket)`
`protected void` | `connectionClosed(HttpConnection connection)`
`protected void` | `connectionOpened(HttpConnection connection)`
`void` | `customize(EndPoint endpoint, Request request)` Customize a request for an endpoint.
`protected void` | `doStart()`
`protected void` | `doStop()`
`int` | `getAcceptorPriorityOffset()`
`int` | `getAcceptors()`
`int` | `getAcceptQueueSize()`
`int` | `getConfidentialPort()`
`java.lang.String` | `getConfidentialScheme()`
`int` | `getConnections()`
`long` | `getConnectionsDurationAve()`
`long` | `getConnectionsDurationMax()`
`long` | `getConnectionsDurationMin()`
`long` | `getConnectionsDurationTotal()`
`int` | `getConnectionsOpen()`
`int` | `getConnectionsOpenMax()`
`int` | `getConnectionsOpenMin()`
`int` | `getConnectionsRequestsAve()`
`int` | `getConnectionsRequestsMax()`
`int` | `getConnectionsRequestsMin()`
`java.lang.String` | `getForwardedForHeader()`
`java.lang.String` | `getForwardedHostHeader()`
`java.lang.String` | `getForwardedServerHeader()`
`java.lang.String` | `getHost()`
`java.lang.String` | `getHostHeader()`
`int` | `getIntegralPort()`
`java.lang.String` | `getIntegralScheme()`
`protected java.lang.String` | `getLeftMostValue(java.lang.String headerValue)`
`int` | `getLowResourceMaxIdleTime()`
`int` | `getMaxIdleTime()`
`java.lang.String` | `getName()`
`int` | `getPort()`
`int` | `getRequests()`
`boolean` | `getResolveNames()`
`boolean` | `getReuseAddress()`
`Server` | `getServer()`
`int` | `getSoLingerTime()`
`boolean` | `getStatsOn()`
`long` | `getStatsOnMs()`
`ThreadPool` | `getThreadPool()`
`boolean` | `isConfidential(Request request)`
`boolean` | `isForwarded()` Is reverse proxy handling on?
`boolean` | `isIntegral(Request request)`
`void` | `join()`
`Continuation` | `newContinuation()`
`void` | `persist(EndPoint endpoint)` Persist an endpoint.
`void` | `setAcceptorPriorityOffset(int offset)` Set the priority offset of the acceptor threads.
`void` | `setAcceptors(int acceptors)`
`void` | `setAcceptQueueSize(int acceptQueueSize)`
`void` | `setConfidentialPort(int confidentialPort)`
`void` | `setConfidentialScheme(java.lang.String confidentialScheme)`
`void` | `setForwarded(boolean check)` Set reverse proxy handling
`void` | `setForwardedForHeader(java.lang.String forwardedRemoteAddressHeader)`
`void` | `setForwardedHostHeader(java.lang.String forwardedHostHeader)`
`void` | `setForwardedServerHeader(java.lang.String forwardedServerHeader)`
`void` | `setHost(java.lang.String host)`
`void` | `setHostHeader(java.lang.String hostHeader)` Set a forced valued for the host header to control what is returned by `ServletRequest.getServerName()` and `ServletRequest.getServerPort()`.
`void` | `setIntegralPort(int integralPort)`
`void` | `setIntegralScheme(java.lang.String integralScheme)`
`void` | `setLowResourceMaxIdleTime(int maxIdleTime)`
`void` | `setMaxIdleTime(int maxIdleTime)` Set the maximum Idle time for a connection, which roughly translates to the `Socket.setSoTimeout(int)` call, although with NIO implementations other mechanisms may be used to implement the timeout.
`void` | `setName(java.lang.String name)`
`void` | `setPort(int port)`
`void` | `setResolveNames(boolean resolve)`
`void` | `setReuseAddress(boolean reuseAddress)`
`void` | `setServer(Server server)`
`void` | `setSoLingerTime(int soLingerTime)`
`void` | `setStatsOn(boolean on)`
`void` | `setThreadPool(ThreadPool pool)`
`void` | `statsReset()` Reset statistics.
`void` | `stopAccept(int acceptorID)`
`java.lang.String` | `toString()`

Methods inherited from class org.mortbay.jetty.AbstractBuffers
`getBuffer, getHeaderBufferSize, getRequestBufferSize, getResponseBufferSize, newBuffer, returnBuffer, setHeaderBufferSize, setRequestBufferSize, setResponseBufferSize`

Methods inherited from class org.mortbay.component.AbstractLifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, 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.jetty.Connector
`close, getConnection, getHeaderBufferSize, getLocalPort, getRequestBufferSize, getResponseBufferSize, open, setHeaderBufferSize, setRequestBufferSize, setResponseBufferSize`

Methods inherited from interface org.mortbay.component.LifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Methods inherited from interface org.mortbay.io.Buffers
`getBuffer, returnBuffer`

Field Detail

### _maxIdleTime

    protected int _maxIdleTime

### _lowResourceMaxIdleTime

    protected int _lowResourceMaxIdleTime

### _soLingerTime

    protected int _soLingerTime

Constructor Detail

### AbstractConnector

    public AbstractConnector()

Method Detail

### getServer

    public Server getServer()

  Specified by:
    `getServer` in interface `Connector`

### setServer

    public void setServer(Server server)

  Specified by:
    `setServer` in interface `Connector`

### getThreadPool

    public ThreadPool getThreadPool()

### setThreadPool

    public void setThreadPool(ThreadPool pool)

### setHost

    public void setHost(java.lang.String host)

  Specified by:
    `setHost` in interface `Connector`

### getHost

    public java.lang.String getHost()

  Specified by:
    `getHost` in interface `Connector`

### setPort

    public void setPort(int port)

  Specified by:
    `setPort` in interface `Connector`
  Parameters:
    `port` - The port fto listen of for connections or 0 if any available port may be used.

### getPort

    public int getPort()

  Specified by:
    `getPort` in interface `Connector`
  Returns:
    The configured port for the connector or 0 if any available port may be used.

### getMaxIdleTime

    public int getMaxIdleTime()

  Specified by:
    `getMaxIdleTime` in interface `Connector`
  Returns:
    Returns the maxIdleTime.

### setMaxIdleTime

    public void setMaxIdleTime(int maxIdleTime)

  Set the maximum Idle time for a connection, which roughly translates to the `Socket.setSoTimeout(int)` call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied:
  - When waiting for a new request to be received on a connection
  - When reading the headers and content of a request
  - When writing the headers and content of a response
  Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note, that as Jetty supports writes of memory mapped file buffers, then a write may take many 10s of seconds for large content written to a slow device.

  Previously, Jetty supported separate idle timeouts and IO operation timeouts, however the expense of changing the value of soTimeout was significant, so these timeouts were merged. With the advent of NIO, it may be possible to again differentiate these values (if there is demand).

  Specified by:
    `setMaxIdleTime` in interface `Connector`
  Parameters:
    `maxIdleTime` - The maxIdleTime to set.

### getLowResourceMaxIdleTime

    public int getLowResourceMaxIdleTime()

  Specified by:
    `getLowResourceMaxIdleTime` in interface `Connector`
  Returns:
    Returns the maxIdleTime.

### setLowResourceMaxIdleTime

    public void setLowResourceMaxIdleTime(int maxIdleTime)

  Specified by:
    `setLowResourceMaxIdleTime` in interface `Connector`
  Parameters:
    `maxIdleTime` - The maxIdleTime to set.

### getSoLingerTime

    public int getSoLingerTime()

  Returns:
    Returns the soLingerTime.

### getAcceptQueueSize

    public int getAcceptQueueSize()

  Returns:
    Returns the acceptQueueSize.

### setAcceptQueueSize

    public void setAcceptQueueSize(int acceptQueueSize)

  Parameters:
    `acceptQueueSize` - The acceptQueueSize to set.

### getAcceptors

    public int getAcceptors()

  Returns:
    Returns the number of acceptor threads.

### setAcceptors

    public void setAcceptors(int acceptors)

  Parameters:
    `acceptors` - The number of acceptor threads to set.

### setSoLingerTime

    public void setSoLingerTime(int soLingerTime)

  Parameters:
    `soLingerTime` - The soLingerTime to set or -1 to disable.

### doStart

    protected void doStart()
                    throws java.lang.Exception

  Overrides:
    `doStart` in class `AbstractBuffers`
  Throws:
    `java.lang.Exception`

### doStop

    protected void doStop()
                   throws java.lang.Exception

  Overrides:
    `doStop` in class `AbstractLifeCycle`
  Throws:
    `java.lang.Exception`

### join

    public void join()
              throws java.lang.InterruptedException

  Throws:
    `java.lang.InterruptedException`

### configure

    protected void configure(java.net.Socket socket)
                      throws java.io.IOException

  Throws:
    `java.io.IOException`

### customize

    public void customize(EndPoint endpoint,
                          Request request)
                   throws java.io.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`
  Throws:
    `java.io.IOException`

### checkForwardedHeaders

    protected void checkForwardedHeaders(EndPoint endpoint,
                                         Request request)
                                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### getLeftMostValue

    protected java.lang.String getLeftMostValue(java.lang.String headerValue)

### persist

    public void persist(EndPoint endpoint)
                 throws java.io.IOException

  Description copied from interface: `Connector`
  Persist an endpoint. Called after every request if the connection is to remain open.

  Specified by:
    `persist` in interface `Connector`
  Throws:
    `java.io.IOException`

### getConfidentialPort

    public int getConfidentialPort()

  Specified by:
    `getConfidentialPort` in interface `Connector`
  Returns:
    The port to use when redirecting a request if a data constraint of confidential is required. See `Constraint.getDataConstraint()`

### getConfidentialScheme

    public java.lang.String getConfidentialScheme()

  Specified by:
    `getConfidentialScheme` in interface `Connector`
  Returns:
    The schema to use when redirecting a request if a data constraint of confidential is required. See `Constraint.getDataConstraint()`

### isIntegral

    public boolean isIntegral(Request request)

  Specified by:
    `isIntegral` in interface `Connector`
  Parameters:
    `request` - A request
  Returns:
    true if the request is integral. This normally means the https schema has been used.

### getIntegralPort

    public int getIntegralPort()

  Specified by:
    `getIntegralPort` in interface `Connector`
  Returns:
    The port to use when redirecting a request if a data constraint of integral is required. See `Constraint.getDataConstraint()`

### getIntegralScheme

    public java.lang.String getIntegralScheme()

  Specified by:
    `getIntegralScheme` in interface `Connector`
  Returns:
    The schema to use when redirecting a request if a data constraint of integral is required. See `Constraint.getDataConstraint()`

### isConfidential

    public boolean isConfidential(Request request)

  Specified by:
    `isConfidential` in interface `Connector`
  Parameters:
    `request` - A request
  Returns:
    true if the request is confidential. This normally means the https schema has been used.

### setConfidentialPort

    public void setConfidentialPort(int confidentialPort)

  Parameters:
    `confidentialPort` - The confidentialPort to set.

### setConfidentialScheme

    public void setConfidentialScheme(java.lang.String confidentialScheme)

  Parameters:
    `confidentialScheme` - The confidentialScheme to set.

### setIntegralPort

    public void setIntegralPort(int integralPort)

  Parameters:
    `integralPort` - The integralPort to set.

### setIntegralScheme

    public void setIntegralScheme(java.lang.String integralScheme)

  Parameters:
    `integralScheme` - The integralScheme to set.

### newContinuation

    public Continuation newContinuation()

  Specified by:
    `newContinuation` in interface `Connector`

### accept

    protected abstract void accept(int acceptorID)
                            throws java.io.IOException,
                                   java.lang.InterruptedException

  Throws:
    `java.io.IOException`
    `java.lang.InterruptedException`

### stopAccept

    public void stopAccept(int acceptorID)
                    throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### getResolveNames

    public boolean getResolveNames()

  Specified by:
    `getResolveNames` in interface `Connector`
  Returns:
    true if names resolution should be done.

### setResolveNames

    public void setResolveNames(boolean resolve)

### isForwarded

    public boolean isForwarded()

  Is reverse proxy handling on?

  Returns:
    true if this connector is checking the x-forwarded-for/host/server headers

### setForwarded

    public void setForwarded(boolean check)

  Set reverse proxy handling

  Parameters:
    `check` - true if this connector is checking the x-forwarded-for/host/server headers

### getHostHeader

    public java.lang.String getHostHeader()

### setHostHeader

    public void setHostHeader(java.lang.String hostHeader)

  Set a forced valued for the host header to control what is returned by `ServletRequest.getServerName()` and `ServletRequest.getServerPort()`. This value is only used if `isForwarded()` is true.

  Parameters:
    `hostHeader` - The value of the host header to force.

### getForwardedHostHeader

    public java.lang.String getForwardedHostHeader()

### setForwardedHostHeader

    public void setForwardedHostHeader(java.lang.String forwardedHostHeader)

  Parameters:
    `forwardedHostHeader` - The header name for forwarded hosts (default x-forwarded-host)

### getForwardedServerHeader

    public java.lang.String getForwardedServerHeader()

### setForwardedServerHeader

    public void setForwardedServerHeader(java.lang.String forwardedServerHeader)

  Parameters:
    `forwardedServerHeader` - The header name for forwarded server (default x-forwarded-server)

### getForwardedForHeader

    public java.lang.String getForwardedForHeader()

### setForwardedForHeader

    public void setForwardedForHeader(java.lang.String forwardedRemoteAddressHeader)

  Parameters:
    `forwardedRemoteAddressHeader` - The header name for forwarded for (default x-forwarded-for)

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `AbstractBuffers`

### getName

    public java.lang.String getName()

  Specified by:
    `getName` in interface `Connector`
  Returns:
    the name of the connector. Defaults to the HostName:port

### setName

    public void setName(java.lang.String name)

### getRequests

    public int getRequests()

  Specified by:
    `getRequests` in interface `Connector`
  Returns:
    Get the number of requests handled by this context since last call of statsReset(). If setStatsOn(false) then this is undefined.

### getConnectionsDurationMin

    public long getConnectionsDurationMin()

  Specified by:
    `getConnectionsDurationMin` in interface `Connector`
  Returns:
    Returns the connectionsDurationMin.

### getConnectionsDurationTotal

    public long getConnectionsDurationTotal()

  Specified by:
    `getConnectionsDurationTotal` in interface `Connector`
  Returns:
    Returns the connectionsDurationTotal.

### getConnectionsOpenMin

    public int getConnectionsOpenMin()

  Specified by:
    `getConnectionsOpenMin` in interface `Connector`
  Returns:
    Returns the connectionsOpenMin.

### getConnectionsRequestsMin

    public int getConnectionsRequestsMin()

  Specified by:
    `getConnectionsRequestsMin` in interface `Connector`
  Returns:
    Returns the connectionsRequestsMin.

### getConnections

    public int getConnections()

  Specified by:
    `getConnections` in interface `Connector`
  Returns:
    Number of connections accepted by the server since statsReset() called. Undefined if setStatsOn(false).

### getConnectionsOpen

    public int getConnectionsOpen()

  Specified by:
    `getConnectionsOpen` in interface `Connector`
  Returns:
    Number of connections currently open that were opened since statsReset() called. Undefined if setStatsOn(false).

### getConnectionsOpenMax

    public int getConnectionsOpenMax()

  Specified by:
    `getConnectionsOpenMax` in interface `Connector`
  Returns:
    Maximum number of connections opened simultaneously since statsReset() called. Undefined if setStatsOn(false).

### getConnectionsDurationAve

    public long getConnectionsDurationAve()

  Specified by:
    `getConnectionsDurationAve` in interface `Connector`
  Returns:
    Average duration in milliseconds of open connections since statsReset() called. Undefined if setStatsOn(false).

### getConnectionsDurationMax

    public long getConnectionsDurationMax()

  Specified by:
    `getConnectionsDurationMax` in interface `Connector`
  Returns:
    Maximum duration in milliseconds of an open connection since statsReset() called. Undefined if setStatsOn(false).

### getConnectionsRequestsAve

    public int getConnectionsRequestsAve()

  Specified by:
    `getConnectionsRequestsAve` in interface `Connector`
  Returns:
    Average number of requests per connection since statsReset() called. Undefined if setStatsOn(false).

### getConnectionsRequestsMax

    public int getConnectionsRequestsMax()

  Specified by:
    `getConnectionsRequestsMax` in interface `Connector`
  Returns:
    Maximum number of requests per connection since statsReset() called. Undefined if setStatsOn(false).

### statsReset

    public void statsReset()

  Reset statistics.

  Specified by:
    `statsReset` in interface `Connector`

### setStatsOn

    public void setStatsOn(boolean on)

  Specified by:
    `setStatsOn` in interface `Connector`

### getStatsOn

    public boolean getStatsOn()

  Specified by:
    `getStatsOn` in interface `Connector`
  Returns:
    True if statistics collection is turned on.

### getStatsOnMs

    public long getStatsOnMs()

  Specified by:
    `getStatsOnMs` in interface `Connector`
  Returns:
    Timestamp stats were started at.

### connectionOpened

    protected void connectionOpened(HttpConnection connection)

### connectionClosed

    protected void connectionClosed(HttpConnection connection)

### getAcceptorPriorityOffset

    public int getAcceptorPriorityOffset()

  Returns:
    the acceptorPriority

### setAcceptorPriorityOffset

    public void setAcceptorPriorityOffset(int offset)

  Set the priority offset of the acceptor threads. The priority is adjusted by this amount (default 0) to either favour the acceptance of new threads and newly active connections or to favour the handling of already dispatched connections.

  Parameters:
    `offset` - the amount to alter the priority of the acceptor threads.

### getReuseAddress

    public boolean getReuseAddress()

  Returns:
    True if the the server socket will be opened in SO_REUSEADDR mode.

### setReuseAddress

    public void setReuseAddress(boolean reuseAddress)

  Parameters:
    `reuseAddress` - True if the the server socket will be opened in SO_REUSEADDR mode.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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