org.apache.catalina.connector
Class Connector

java.lang.Object
  extended by org.apache.catalina.connector.Connector
All Implemented Interfaces:
MBeanRegistration, org.apache.catalina.Lifecycle

public class Connector
extends Object
implements org.apache.catalina.Lifecycle, MBeanRegistration

Implementation of a Coyote connector for Tomcat 5.x.

Version:
$Revision: 783305 $ $Date: 2009-06-10 13:48:10 +0200 (mer., 10 juin 2009) $ TODO: This class fixes an issue when restarting the web container, remove it when integrating Tomcat > 6.0.20
Author:
Craig R. McClanahan, Remy Maucherat

Field Summary
protected  org.apache.coyote.Adapter adapter
          Coyote adapter.
protected  boolean allowTrace
          Do we allow TRACE ?
protected  org.apache.catalina.Container container
          The Container used for processing requests received by this Connector.
protected  String domain
           
protected  boolean emptySessionPath
          Use "/" as path for session cookies ?
protected  boolean enableLookups
          The "enable DNS lookups" flag for this Connector.
protected static String info
          Descriptive information about this Connector implementation.
protected  boolean initialized
          Has this component been initialized yet?
protected  org.apache.catalina.util.LifecycleSupport lifecycle
          The lifecycle event support for this component.
protected  org.apache.tomcat.util.http.mapper.Mapper mapper
          Mapper.
protected  MapperListener mapperListener
          Mapper listener.
protected  int maxPostSize
          Maximum size of a POST which will be automatically parsed by the container.
protected  int maxSavePostSize
          Maximum size of a POST which will be saved by the container during authentication.
protected  MBeanServer mserver
           
protected  ObjectName oname
           
protected  int port
          The port number on which we listen for requests.
protected  org.apache.coyote.ProtocolHandler protocolHandler
          Coyote protocol handler.
protected  String protocolHandlerClassName
          Coyote Protocol handler class name.
protected  String proxyName
          The server name to which we should pretend requests to this Connector were directed.
protected  int proxyPort
          The server port to which we should pretent requests to this Connector were directed.
static boolean RECYCLE_FACADES
          Alternate flag to enable recycling of facades.
protected  int redirectPort
          The redirect port for non-SSL to SSL redirects.
protected static HashMap replacements
           
protected  String scheme
          The request scheme that will be set on all requests received through this connector.
protected  boolean secure
          The secure connection flag that will be set on all requests received through this connector.
protected  org.apache.catalina.Service service
          The Service we are associated with (if any).
protected  org.apache.catalina.util.StringManager sm
          The string manager for this package.
protected  boolean started
          Has this component been started yet?
protected  boolean stopped
          The shutdown signal to our background thread
protected  Thread thread
          The background thread.
protected  String URIEncoding
          URI encoding.
protected  boolean useBodyEncodingForURI
          URI encoding as body.
protected  boolean useIPVHosts
          Flag to use IP-based virtual hosting.
protected  boolean xpoweredBy
           
 
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
Constructor Summary
Connector()
           
Connector(String protocol)
           
 
Method Summary
 void addLifecycleListener(org.apache.catalina.LifecycleListener listener)
          Add a lifecycle event listener to this component.
protected  ObjectName createObjectName(String domain, String type)
           
 org.apache.catalina.connector.Request createRequest()
          Create (or allocate) and return a Request object suitable for specifying the contents of a Request to the responsible Container.
 org.apache.catalina.connector.Response createResponse()
          Create (or allocate) and return a Response object suitable for receiving the contents of a Response from the responsible Container.
 void destroy()
           
protected  void findContainer()
           
 org.apache.catalina.LifecycleListener[] findLifecycleListeners()
          Get the lifecycle listeners associated with this lifecycle.
 boolean getAllowTrace()
          True if the TRACE method is allowed.
 Object getAttribute(String name)
          Return a configured property.
 int getBufferSize()
          Deprecated.  
 org.apache.catalina.Container getContainer()
          Return the Container used for processing requests received by this Connector.
 ObjectName getController()
           
 String getDomain()
           
 boolean getEmptySessionPath()
          Return the "empty session path" flag.
 boolean getEnableLookups()
          Return the "enable DNS lookups" flag.
 String getInfo()
          Return descriptive information about this Connector implementation.
 org.apache.tomcat.util.http.mapper.Mapper getMapper()
          Return the mapper.
 int getMaxPostSize()
          Return the maximum size of a POST which will be automatically parsed by the container.
 int getMaxSavePostSize()
          Return the maximum size of a POST which will be saved by the container during authentication.
 ObjectName getObjectName()
           
 int getPort()
          Return the port number on which we listen for requests.
 Object getProperty(String name)
          Return a configured property.
 String getProtocol()
          Return the Coyote protocol handler in use.
 org.apache.coyote.ProtocolHandler getProtocolHandler()
          Return the protocol handler associated with the connector.
 String getProtocolHandlerClassName()
          Return the class name of the Coyote protocol handler in use.
 String getProxyName()
          Return the proxy server name for this Connector.
 int getProxyPort()
          Return the proxy server port for this Connector.
 int getRedirectPort()
          Return the port number to which a request should be redirected if it comes in on a non-SSL port and is subject to a security constraint with a transport guarantee that requires SSL.
 String getScheme()
          Return the scheme that will be assigned to requests received through this connector.
 boolean getSecure()
          Return the secure connection flag that will be assigned to requests received through this connector.
 org.apache.catalina.Service getService()
          Return the Service with which we are associated (if any).
 String getURIEncoding()
          Return the character encoding to be used for the URI.
 boolean getUseBodyEncodingForURI()
          Return the true if the entity body encoding should be used for the URI.
 boolean getUseIPVHosts()
          Test if IP-based virtual hosting is enabled.
 boolean getXpoweredBy()
          Indicates whether the generation of an X-Powered-By response header for servlet-generated responses is enabled or disabled for this Connector.
 void init()
           
 void initialize()
          Initialize this connector (create ServerSocket here!)
 boolean isAvailable()
          Is this connector available for processing requests?
 void pause()
          Pause the connector.
 void postDeregister()
           
 void postRegister(Boolean registrationDone)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
 void removeLifecycleListener(org.apache.catalina.LifecycleListener listener)
          Remove a lifecycle event listener from this component.
 void removeProperty(String name)
          remove a configured property.
 void resume()
          Pause the connector.
 void setAllowTrace(boolean allowTrace)
          Set the allowTrace flag, to disable or enable the TRACE HTTP method.
 void setAttribute(String name, Object value)
          Set a configured property.
 void setBufferSize(int bufferSize)
          Deprecated.  
 void setContainer(org.apache.catalina.Container container)
          Set the Container used for processing requests received by this Connector.
 void setController(ObjectName controller)
           
 void setEmptySessionPath(boolean emptySessionPath)
          Set the "empty session path" flag.
 void setEnableLookups(boolean enableLookups)
          Set the "enable DNS lookups" flag.
 void setMaxPostSize(int maxPostSize)
          Set the maximum size of a POST which will be automatically parsed by the container.
 void setMaxSavePostSize(int maxSavePostSize)
          Set the maximum size of a POST which will be saved by the container during authentication.
 void setPort(int port)
          Set the port number on which we listen for requests.
 boolean setProperty(String name, String value)
          Set a configured property.
 void setProtocol(String protocol)
          Set the Coyote protocol which will be used by the connector.
 void setProtocolHandlerClassName(String protocolHandlerClassName)
          Set the class name of the Coyote protocol handler which will be used by the connector.
 void setProxyName(String proxyName)
          Set the proxy server name for this Connector.
 void setProxyPort(int proxyPort)
          Set the proxy server port for this Connector.
 void setRedirectPort(int redirectPort)
          Set the redirect port number.
 void setScheme(String scheme)
          Set the scheme that will be assigned to requests received through this connector.
 void setSecure(boolean secure)
          Set the secure connection flag that will be assigned to requests received through this connector.
 void setService(org.apache.catalina.Service service)
          Set the Service with which we are associated (if any).
 void setURIEncoding(String URIEncoding)
          Set the URI encoding to be used for the URI.
 void setUseBodyEncodingForURI(boolean useBodyEncodingForURI)
          Set if the entity body encoding should be used for the URI.
 void setUseIPVHosts(boolean useIPVHosts)
          Enable the use of IP-based virtual hosting.
 void setXpoweredBy(boolean xpoweredBy)
          Enables or disables the generation of an X-Powered-By header (with value Servlet/2.5) for all servlet-generated responses returned by this Connector.
 void start()
          Begin processing requests via this Connector.
 void stop()
          Terminate processing requests via this Connector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECYCLE_FACADES

public static final boolean RECYCLE_FACADES
Alternate flag to enable recycling of facades.


service

protected org.apache.catalina.Service service
The Service we are associated with (if any).


allowTrace

protected boolean allowTrace
Do we allow TRACE ?


container

protected org.apache.catalina.Container container
The Container used for processing requests received by this Connector.


emptySessionPath

protected boolean emptySessionPath
Use "/" as path for session cookies ?


enableLookups

protected boolean enableLookups
The "enable DNS lookups" flag for this Connector.


xpoweredBy

protected boolean xpoweredBy

info

protected static final String info
Descriptive information about this Connector implementation.

See Also:
Constant Field Values

lifecycle

protected org.apache.catalina.util.LifecycleSupport lifecycle
The lifecycle event support for this component.


port

protected int port
The port number on which we listen for requests.


proxyName

protected String proxyName
The server name to which we should pretend requests to this Connector were directed. This is useful when operating Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the server name included in the Host header is used.


proxyPort

protected int proxyPort
The server port to which we should pretent requests to this Connector were directed. This is useful when operating Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the port number specified by the port property is used.


redirectPort

protected int redirectPort
The redirect port for non-SSL to SSL redirects.


scheme

protected String scheme
The request scheme that will be set on all requests received through this connector.


secure

protected boolean secure
The secure connection flag that will be set on all requests received through this connector.


sm

protected org.apache.catalina.util.StringManager sm
The string manager for this package.


maxPostSize

protected int maxPostSize
Maximum size of a POST which will be automatically parsed by the container. 2MB by default.


maxSavePostSize

protected int maxSavePostSize
Maximum size of a POST which will be saved by the container during authentication. 4kB by default


initialized

protected boolean initialized
Has this component been initialized yet?


started

protected boolean started
Has this component been started yet?


stopped

protected boolean stopped
The shutdown signal to our background thread


useIPVHosts

protected boolean useIPVHosts
Flag to use IP-based virtual hosting.


thread

protected Thread thread
The background thread.


protocolHandlerClassName

protected String protocolHandlerClassName
Coyote Protocol handler class name. Defaults to the Coyote HTTP/1.1 protocolHandler.


protocolHandler

protected org.apache.coyote.ProtocolHandler protocolHandler
Coyote protocol handler.


adapter

protected org.apache.coyote.Adapter adapter
Coyote adapter.


mapper

protected org.apache.tomcat.util.http.mapper.Mapper mapper
Mapper.


mapperListener

protected MapperListener mapperListener
Mapper listener.


URIEncoding

protected String URIEncoding
URI encoding.


useBodyEncodingForURI

protected boolean useBodyEncodingForURI
URI encoding as body.


replacements

protected static HashMap replacements

domain

protected String domain

oname

protected ObjectName oname

mserver

protected MBeanServer mserver
Constructor Detail

Connector

public Connector()
          throws Exception
Throws:
Exception

Connector

public Connector(String protocol)
          throws Exception
Throws:
Exception
Method Detail

getProperty

public Object getProperty(String name)
Return a configured property.


setProperty

public boolean setProperty(String name,
                           String value)
Set a configured property.


getAttribute

public Object getAttribute(String name)
Return a configured property.


setAttribute

public void setAttribute(String name,
                         Object value)
Set a configured property.


removeProperty

public void removeProperty(String name)
remove a configured property.


getService

public org.apache.catalina.Service getService()
Return the Service with which we are associated (if any).


setService

public void setService(org.apache.catalina.Service service)
Set the Service with which we are associated (if any).

Parameters:
service - The service that owns this Engine

getAllowTrace

public boolean getAllowTrace()
True if the TRACE method is allowed. Default value is "false".


setAllowTrace

public void setAllowTrace(boolean allowTrace)
Set the allowTrace flag, to disable or enable the TRACE HTTP method.

Parameters:
allowTrace - The new allowTrace flag

isAvailable

public boolean isAvailable()
Is this connector available for processing requests?


getBufferSize

public int getBufferSize()
Deprecated. 

Return the input buffer size for this Connector.


setBufferSize

public void setBufferSize(int bufferSize)
Deprecated. 

Set the input buffer size for this Connector.

Parameters:
bufferSize - The new input buffer size.

getContainer

public org.apache.catalina.Container getContainer()
Return the Container used for processing requests received by this Connector.


setContainer

public void setContainer(org.apache.catalina.Container container)
Set the Container used for processing requests received by this Connector.

Parameters:
container - The new Container to use

getEmptySessionPath

public boolean getEmptySessionPath()
Return the "empty session path" flag.


setEmptySessionPath

public void setEmptySessionPath(boolean emptySessionPath)
Set the "empty session path" flag.

Parameters:
emptySessionPath - The new "empty session path" flag value

getEnableLookups

public boolean getEnableLookups()
Return the "enable DNS lookups" flag.


setEnableLookups

public void setEnableLookups(boolean enableLookups)
Set the "enable DNS lookups" flag.

Parameters:
enableLookups - The new "enable DNS lookups" flag value

getInfo

public String getInfo()
Return descriptive information about this Connector implementation.


getMapper

public org.apache.tomcat.util.http.mapper.Mapper getMapper()
Return the mapper.


getMaxPostSize

public int getMaxPostSize()
Return the maximum size of a POST which will be automatically parsed by the container.


setMaxPostSize

public void setMaxPostSize(int maxPostSize)
Set the maximum size of a POST which will be automatically parsed by the container.

Parameters:
maxPostSize - The new maximum size in bytes of a POST which will be automatically parsed by the container

getMaxSavePostSize

public int getMaxSavePostSize()
Return the maximum size of a POST which will be saved by the container during authentication.


setMaxSavePostSize

public void setMaxSavePostSize(int maxSavePostSize)
Set the maximum size of a POST which will be saved by the container during authentication.

Parameters:
maxSavePostSize - The new maximum size in bytes of a POST which will be saved by the container during authentication.

getPort

public int getPort()
Return the port number on which we listen for requests.


setPort

public void setPort(int port)
Set the port number on which we listen for requests.

Parameters:
port - The new port number

getProtocol

public String getProtocol()
Return the Coyote protocol handler in use.


setProtocol

public void setProtocol(String protocol)
Set the Coyote protocol which will be used by the connector.

Parameters:
protocol - The Coyote protocol name

getProtocolHandlerClassName

public String getProtocolHandlerClassName()
Return the class name of the Coyote protocol handler in use.


setProtocolHandlerClassName

public void setProtocolHandlerClassName(String protocolHandlerClassName)
Set the class name of the Coyote protocol handler which will be used by the connector.

Parameters:
protocolHandlerClassName - The new class name

getProtocolHandler

public org.apache.coyote.ProtocolHandler getProtocolHandler()
Return the protocol handler associated with the connector.


getProxyName

public String getProxyName()
Return the proxy server name for this Connector.


setProxyName

public void setProxyName(String proxyName)
Set the proxy server name for this Connector.

Parameters:
proxyName - The new proxy server name

getProxyPort

public int getProxyPort()
Return the proxy server port for this Connector.


setProxyPort

public void setProxyPort(int proxyPort)
Set the proxy server port for this Connector.

Parameters:
proxyPort - The new proxy server port

getRedirectPort

public int getRedirectPort()
Return the port number to which a request should be redirected if it comes in on a non-SSL port and is subject to a security constraint with a transport guarantee that requires SSL.


setRedirectPort

public void setRedirectPort(int redirectPort)
Set the redirect port number.

Parameters:
redirectPort - The redirect port number (non-SSL to SSL)

getScheme

public String getScheme()
Return the scheme that will be assigned to requests received through this connector. Default value is "http".


setScheme

public void setScheme(String scheme)
Set the scheme that will be assigned to requests received through this connector.

Parameters:
scheme - The new scheme

getSecure

public boolean getSecure()
Return the secure connection flag that will be assigned to requests received through this connector. Default value is "false".


setSecure

public void setSecure(boolean secure)
Set the secure connection flag that will be assigned to requests received through this connector.

Parameters:
secure - The new secure connection flag

getURIEncoding

public String getURIEncoding()
Return the character encoding to be used for the URI.


setURIEncoding

public void setURIEncoding(String URIEncoding)
Set the URI encoding to be used for the URI.

Parameters:
URIEncoding - The new URI character encoding.

getUseBodyEncodingForURI

public boolean getUseBodyEncodingForURI()
Return the true if the entity body encoding should be used for the URI.


setUseBodyEncodingForURI

public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI)
Set if the entity body encoding should be used for the URI.

Parameters:
useBodyEncodingForURI - The new value for the flag.

getXpoweredBy

public boolean getXpoweredBy()
Indicates whether the generation of an X-Powered-By response header for servlet-generated responses is enabled or disabled for this Connector.

Returns:
true if generation of X-Powered-By response header is enabled, false otherwise

setXpoweredBy

public void setXpoweredBy(boolean xpoweredBy)
Enables or disables the generation of an X-Powered-By header (with value Servlet/2.5) for all servlet-generated responses returned by this Connector.

Parameters:
xpoweredBy - true if generation of X-Powered-By response header is to be enabled, false otherwise

setUseIPVHosts

public void setUseIPVHosts(boolean useIPVHosts)
Enable the use of IP-based virtual hosting.

Parameters:
useIPVHosts - true if Hosts are identified by IP, false/code> if Hosts are identified by name.

getUseIPVHosts

public boolean getUseIPVHosts()
Test if IP-based virtual hosting is enabled.


createRequest

public org.apache.catalina.connector.Request createRequest()
Create (or allocate) and return a Request object suitable for specifying the contents of a Request to the responsible Container.


createResponse

public org.apache.catalina.connector.Response createResponse()
Create (or allocate) and return a Response object suitable for receiving the contents of a Response from the responsible Container.


addLifecycleListener

public void addLifecycleListener(org.apache.catalina.LifecycleListener listener)
Add a lifecycle event listener to this component.

Specified by:
addLifecycleListener in interface org.apache.catalina.Lifecycle
Parameters:
listener - The listener to add

findLifecycleListeners

public org.apache.catalina.LifecycleListener[] findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.

Specified by:
findLifecycleListeners in interface org.apache.catalina.Lifecycle

removeLifecycleListener

public void removeLifecycleListener(org.apache.catalina.LifecycleListener listener)
Remove a lifecycle event listener from this component.

Specified by:
removeLifecycleListener in interface org.apache.catalina.Lifecycle
Parameters:
listener - The listener to add

createObjectName

protected ObjectName createObjectName(String domain,
                                      String type)
                               throws MalformedObjectNameException
Throws:
MalformedObjectNameException

initialize

public void initialize()
                throws org.apache.catalina.LifecycleException
Initialize this connector (create ServerSocket here!)

Throws:
org.apache.catalina.LifecycleException

pause

public void pause()
           throws org.apache.catalina.LifecycleException
Pause the connector.

Throws:
org.apache.catalina.LifecycleException

resume

public void resume()
            throws org.apache.catalina.LifecycleException
Pause the connector.

Throws:
org.apache.catalina.LifecycleException

start

public void start()
           throws org.apache.catalina.LifecycleException
Begin processing requests via this Connector.

Specified by:
start in interface org.apache.catalina.Lifecycle
Throws:
org.apache.catalina.LifecycleException - if a fatal startup error occurs

stop

public void stop()
          throws org.apache.catalina.LifecycleException
Terminate processing requests via this Connector.

Specified by:
stop in interface org.apache.catalina.Lifecycle
Throws:
org.apache.catalina.LifecycleException - if a fatal shutdown error occurs

getController

public ObjectName getController()

setController

public void setController(ObjectName controller)

getObjectName

public ObjectName getObjectName()

getDomain

public String getDomain()

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception

postRegister

public void postRegister(Boolean registrationDone)
Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

findContainer

protected void findContainer()

init

public void init()
          throws Exception
Throws:
Exception

destroy

public void destroy()
             throws Exception
Throws:
Exception


Copyright © 2010 OW2 Consortium. All Rights Reserved.