Fields Summary |
---|
private static org.apache.juli.logging.Log | log |
public static final boolean | RECYCLE_FACADESAlternate flag to enable recycling of facades. |
protected org.apache.catalina.Service | serviceThe Service we are associated with (if any). |
protected boolean | allowTraceDo we allow TRACE ? |
protected org.apache.catalina.Container | containerThe Container used for processing requests received by this Connector. |
protected boolean | emptySessionPathUse "/" as path for session cookies ? |
protected boolean | enableLookupsThe "enable DNS lookups" flag for this Connector. |
protected boolean | xpoweredBy |
protected static final String | infoDescriptive information about this Connector implementation. |
protected org.apache.catalina.util.LifecycleSupport | lifecycleThe lifecycle event support for this component. |
protected int | portThe port number on which we listen for requests. |
protected String | proxyNameThe 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. |
protected int | proxyPortThe 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. |
protected int | redirectPortThe redirect port for non-SSL to SSL redirects. |
protected String | schemeThe request scheme that will be set on all requests received
through this connector. |
protected boolean | secureThe secure connection flag that will be set on all requests received
through this connector. |
protected org.apache.catalina.util.StringManager | smThe string manager for this package. |
protected int | maxPostSizeMaximum size of a POST which will be automatically parsed by the
container. 2MB by default. |
protected int | maxSavePostSizeMaximum size of a POST which will be saved by the container
during authentication. 4kB by default |
protected boolean | initializedHas this component been initialized yet? |
protected boolean | startedHas this component been started yet? |
protected boolean | stoppedThe shutdown signal to our background thread |
protected boolean | useIPVHostsFlag to use IP-based virtual hosting. |
protected Thread | threadThe background thread. |
protected String | protocolHandlerClassNameCoyote Protocol handler class name.
Defaults to the Coyote HTTP/1.1 protocolHandler. |
protected org.apache.coyote.ProtocolHandler | protocolHandlerCoyote protocol handler. |
protected org.apache.coyote.Adapter | adapterCoyote adapter. |
protected org.apache.tomcat.util.http.mapper.Mapper | mapperMapper. |
protected MapperListener | mapperListenerMapper listener. |
protected String | URIEncodingURI encoding. |
protected boolean | useBodyEncodingForURIURI encoding as body. |
protected static HashMap | replacements |
private static final int | TCN_REQUIRED_MAJOR |
private static final int | TCN_REQUIRED_MINOR |
private static final int | TCN_REQUIRED_PATCH |
private static boolean | aprInitialized |
protected String | domain |
protected ObjectName | oname |
protected MBeanServer | mserver |
ObjectName | controller |
Methods Summary |
---|
public void | addLifecycleListener(org.apache.catalina.LifecycleListener listener)Add a lifecycle event listener to this component.
lifecycle.addLifecycleListener(listener);
|
protected javax.management.ObjectName | createObjectName(java.lang.String domain, java.lang.String type)
String encodedAddr = null;
if (getProperty("address") != null) {
encodedAddr = URLEncoder.encode(getProperty("address").toString());
}
String addSuffix = (getProperty("address") == null) ? "" : ",address="
+ encodedAddr;
ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port="
+ getPort() + addSuffix);
return _oname;
|
public Request | createRequest()Create (or allocate) and return a Request object suitable for
specifying the contents of a Request to the responsible Container.
Request request = new Request();
request.setConnector(this);
return (request);
|
public Response | createResponse()Create (or allocate) and return a Response object suitable for
receiving the contents of a Response from the responsible Container.
Response response = new Response();
response.setConnector(this);
return (response);
|
public void | destroy()
if( oname!=null && controller==oname ) {
if(log.isDebugEnabled())
log.debug("Unregister itself " + oname );
Registry.getRegistry(null, null).unregisterComponent(oname);
}
if( getService() == null)
return;
getService().removeConnector(this);
|
protected void | findContainer()
try {
// Register to the service
ObjectName parentName=new ObjectName( domain + ":" +
"type=Service");
if(log.isDebugEnabled())
log.debug("Adding to " + parentName );
if( mserver.isRegistered(parentName )) {
mserver.invoke(parentName, "addConnector", new Object[] { this },
new String[] {"org.apache.catalina.connector.Connector"});
// As a side effect we'll get the container field set
// Also initialize will be called
//return;
}
// XXX Go directly to the Engine
// initialize(); - is called by addConnector
ObjectName engName=new ObjectName( domain + ":" + "type=Engine");
if( mserver.isRegistered(engName )) {
Object obj=mserver.getAttribute(engName, "managedResource");
if(log.isDebugEnabled())
log.debug("Found engine " + obj + " " + obj.getClass());
container=(Container)obj;
// Internal initialize - we now have the Engine
initialize();
if(log.isDebugEnabled())
log.debug("Initialized");
// As a side effect we'll get the container field set
// Also initialize will be called
return;
}
} catch( Exception ex ) {
log.error( "Error finding container " + ex);
}
|
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.
return lifecycle.findLifecycleListeners();
|
public boolean | getAllowTrace()True if the TRACE method is allowed. Default value is "false".
return (this.allowTrace);
|
public java.lang.Object | getAttribute(java.lang.String name)Return a configured property.
return getProperty(name);
|
public int | getBufferSize()Return the input buffer size for this Connector.
return 2048;
|
public org.apache.catalina.Container | getContainer()Return the Container used for processing requests received by this
Connector.
if( container==null ) {
// Lazy - maybe it was added later
findContainer();
}
return (container);
|
public javax.management.ObjectName | getController()
return controller;
|
public java.lang.String | getDomain()
return domain;
|
public boolean | getEmptySessionPath()Return the "empty session path" flag.
return (this.emptySessionPath);
|
public boolean | getEnableLookups()Return the "enable DNS lookups" flag.
return (this.enableLookups);
|
public java.lang.String | getInfo()Return descriptive information about this Connector implementation.
return (info);
|
public org.apache.tomcat.util.http.mapper.Mapper | getMapper()Return the mapper.
return (mapper);
|
public int | getMaxPostSize()Return the maximum size of a POST which will be automatically
parsed by the container.
return (maxPostSize);
|
public int | getMaxSavePostSize()Return the maximum size of a POST which will be saved by the container
during authentication.
return (maxSavePostSize);
|
public javax.management.ObjectName | getObjectName()
return oname;
|
public int | getPort()Return the port number on which we listen for requests.
return (this.port);
|
public java.lang.Object | getProperty(java.lang.String name)Return a configured property.
replacements.put("acceptCount", "backlog");
replacements.put("connectionLinger", "soLinger");
replacements.put("connectionTimeout", "soTimeout");
replacements.put("connectionUploadTimeout", "timeout");
replacements.put("clientAuth", "clientauth");
replacements.put("keystoreFile", "keystore");
replacements.put("randomFile", "randomfile");
replacements.put("rootFile", "rootfile");
replacements.put("keystorePass", "keypass");
replacements.put("keystoreType", "keytype");
replacements.put("sslProtocol", "protocol");
replacements.put("sslProtocols", "protocols");
String repl = name;
if (replacements.get(name) != null) {
repl = (String) replacements.get(name);
}
return IntrospectionUtils.getProperty(protocolHandler, repl);
|
public java.lang.String | getProtocol()Return the Coyote protocol handler in use.
if ("org.apache.coyote.http11.Http11Protocol".equals
(getProtocolHandlerClassName())
|| "org.apache.coyote.http11.Http11AprProtocol".equals
(getProtocolHandlerClassName())) {
return "HTTP/1.1";
} else if ("org.apache.jk.server.JkCoyoteHandler".equals
(getProtocolHandlerClassName())
|| "org.apache.coyote.ajp.AjpAprProtocol".equals
(getProtocolHandlerClassName())) {
return "AJP/1.3";
}
return getProtocolHandlerClassName();
|
public org.apache.coyote.ProtocolHandler | getProtocolHandler()Return the protocol handler associated with the connector.
return (this.protocolHandler);
|
public java.lang.String | getProtocolHandlerClassName()Return the class name of the Coyote protocol handler in use.
return (this.protocolHandlerClassName);
|
public java.lang.String | getProxyName()Return the proxy server name for this Connector.
return (this.proxyName);
|
public int | getProxyPort()Return the proxy server port for this Connector.
return (this.proxyPort);
|
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.
return (this.redirectPort);
|
public java.lang.String | getScheme()Return the scheme that will be assigned to requests received
through this connector. Default value is "http".
return (this.scheme);
|
public boolean | getSecure()Return the secure connection flag that will be assigned to requests
received through this connector. Default value is "false".
return (this.secure);
|
public org.apache.catalina.Service | getService()Return the Service with which we are associated (if any).
return (this.service);
|
public java.lang.String | getURIEncoding()Return the character encoding to be used for the URI.
return (this.URIEncoding);
|
public boolean | getUseBodyEncodingForURI()Return the true if the entity body encoding should be used for the URI.
return (this.useBodyEncodingForURI);
|
public boolean | getUseIPVHosts()Test if IP-based virtual hosting is enabled.
return useIPVHosts;
|
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.
return xpoweredBy;
|
public void | init()
if( this.getService() != null ) {
if(log.isDebugEnabled())
log.debug( "Already configured" );
return;
}
if( container==null ) {
findContainer();
}
|
public void | initialize()Initialize this connector (create ServerSocket here!)
if (initialized) {
if(log.isInfoEnabled())
log.info(sm.getString("coyoteConnector.alreadyInitialized"));
return;
}
this.initialized = true;
if( oname == null && (container instanceof StandardEngine)) {
try {
// we are loaded directly, via API - and no name was given to us
StandardEngine cb=(StandardEngine)container;
oname = createObjectName(cb.getName(), "Connector");
Registry.getRegistry(null, null)
.registerComponent(this, oname, null);
controller=oname;
} catch (Exception e) {
log.error( "Error registering connector ", e);
}
if(log.isDebugEnabled())
log.debug("Creating name for connector " + oname);
}
// Initializa adapter
adapter = new CoyoteAdapter(this);
protocolHandler.setAdapter(adapter);
IntrospectionUtils.setProperty(protocolHandler, "jkHome",
System.getProperty("catalina.base"));
try {
protocolHandler.init();
} catch (Exception e) {
throw new LifecycleException
(sm.getString
("coyoteConnector.protocolHandlerInitializationFailed", e));
}
|
private static synchronized void | initializeAPR()
// APR init support
if (aprInitialized) {
return;
}
int major = 0;
int minor = 0;
int patch = 0;
try {
String methodName = "initialize";
Class paramTypes[] = new Class[1];
paramTypes[0] = String.class;
Object paramValues[] = new Object[1];
paramValues[0] = null;
Class clazz = Class.forName("org.apache.tomcat.jni.Library");
Method method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
major = clazz.getField("TCN_MAJOR_VERSION").getInt(null);
minor = clazz.getField("TCN_MINOR_VERSION").getInt(null);
patch = clazz.getField("TCN_PATCH_VERSION").getInt(null);
} catch (Throwable t) {
return;
}
if ((major != TCN_REQUIRED_MAJOR) ||
(minor != TCN_REQUIRED_MINOR) ||
(patch < TCN_REQUIRED_PATCH)) {
try {
// Terminate the APR in case the version
// is below required.
String methodName = "terminate";
Method method = Class.forName("org.apache.tomcat.jni.Library")
.getMethod(methodName, (Class [])null);
method.invoke(null, (Object []) null);
} catch (Throwable t) {
// Ignore
}
return;
}
aprInitialized = true;
|
public boolean | isAvailable()Is this connector available for processing requests?
return (started);
|
public void | pause()Pause the connector.
try {
protocolHandler.pause();
} catch (Exception e) {
log.error(sm.getString
("coyoteConnector.protocolHandlerPauseFailed"), e);
}
|
public void | postDeregister()
try {
if( started ) {
stop();
}
} catch( Throwable t ) {
log.error( "Unregistering - can't stop", t);
}
|
public void | postRegister(java.lang.Boolean registrationDone)
|
public void | preDeregister()
|
public javax.management.ObjectName | preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
oname=name;
mserver=server;
domain=name.getDomain();
return name;
|
public void | removeLifecycleListener(org.apache.catalina.LifecycleListener listener)Remove a lifecycle event listener from this component.
lifecycle.removeLifecycleListener(listener);
|
public void | removeProperty(java.lang.String name)remove a configured property.
// FIXME !
//protocolHandler.removeAttribute(name);
|
public void | resume()Pause the connector.
try {
protocolHandler.resume();
} catch (Exception e) {
log.error(sm.getString
("coyoteConnector.protocolHandlerResumeFailed"), e);
}
|
public void | setAllowTrace(boolean allowTrace)Set the allowTrace flag, to disable or enable the TRACE HTTP method.
this.allowTrace = allowTrace;
setProperty("allowTrace", String.valueOf(allowTrace));
|
public void | setAttribute(java.lang.String name, java.lang.Object value)Set a configured property.
setProperty(name, String.valueOf(value));
|
public void | setBufferSize(int bufferSize)Set the input buffer size for this Connector.
|
public void | setContainer(org.apache.catalina.Container container)Set the Container used for processing requests received by this
Connector.
this.container = container;
|
public void | setController(javax.management.ObjectName controller)
this.controller = controller;
|
public void | setEmptySessionPath(boolean emptySessionPath)Set the "empty session path" flag.
this.emptySessionPath = emptySessionPath;
setProperty("emptySessionPath", String.valueOf(emptySessionPath));
|
public void | setEnableLookups(boolean enableLookups)Set the "enable DNS lookups" flag.
this.enableLookups = enableLookups;
setProperty("enableLookups", String.valueOf(enableLookups));
|
public void | setMaxPostSize(int maxPostSize)Set the maximum size of a POST which will be automatically
parsed by the container.
this.maxPostSize = maxPostSize;
|
public void | setMaxSavePostSize(int maxSavePostSize)Set the maximum size of a POST which will be saved by the container
during authentication.
this.maxSavePostSize = maxSavePostSize;
setProperty("maxSavePostSize", String.valueOf(maxSavePostSize));
|
public void | setPort(int port)Set the port number on which we listen for requests.
this.port = port;
setProperty("port", String.valueOf(port));
|
public void | setProperty(java.lang.String name, java.lang.String value)Set a configured property.
String repl = name;
if (replacements.get(name) != null) {
repl = (String) replacements.get(name);
}
IntrospectionUtils.setProperty(protocolHandler, repl, value);
|
public void | setProtocol(java.lang.String protocol)Set the Coyote protocol which will be used by the connector.
// Test APR support
initializeAPR();
if (aprInitialized) {
if ("HTTP/1.1".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11AprProtocol");
} else if ("AJP/1.3".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.ajp.AjpAprProtocol");
} else if (protocol != null) {
setProtocolHandlerClassName(protocol);
} else {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11AprProtocol");
}
} else {
if ("HTTP/1.1".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11Protocol");
} else if ("AJP/1.3".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.jk.server.JkCoyoteHandler");
} else if (protocol != null) {
setProtocolHandlerClassName(protocol);
}
}
|
public void | setProtocolHandlerClassName(java.lang.String protocolHandlerClassName)Set the class name of the Coyote protocol handler which will be used
by the connector.
this.protocolHandlerClassName = protocolHandlerClassName;
|
public void | setProxyName(java.lang.String proxyName)Set the proxy server name for this Connector.
if(proxyName != null && proxyName.length() > 0) {
this.proxyName = proxyName;
setProperty("proxyName", proxyName);
} else {
this.proxyName = null;
removeProperty("proxyName");
}
|
public void | setProxyPort(int proxyPort)Set the proxy server port for this Connector.
this.proxyPort = proxyPort;
setProperty("proxyPort", String.valueOf(proxyPort));
|
public void | setRedirectPort(int redirectPort)Set the redirect port number.
this.redirectPort = redirectPort;
setProperty("redirectPort", String.valueOf(redirectPort));
|
public void | setScheme(java.lang.String scheme)Set the scheme that will be assigned to requests received through
this connector.
this.scheme = scheme;
|
public void | setSecure(boolean secure)Set the secure connection flag that will be assigned to requests
received through this connector.
this.secure = secure;
setProperty("secure", Boolean.toString(secure));
|
public void | setService(org.apache.catalina.Service service)Set the Service with which we are associated (if any).
this.service = service;
// FIXME: setProperty("service", service);
|
public void | setURIEncoding(java.lang.String URIEncoding)Set the URI encoding to be used for the URI.
this.URIEncoding = URIEncoding;
setProperty("uRIEncoding", URIEncoding);
|
public void | setUseBodyEncodingForURI(boolean useBodyEncodingForURI)Set if the entity body encoding should be used for the URI.
this.useBodyEncodingForURI = useBodyEncodingForURI;
setProperty
("useBodyEncodingForURI", String.valueOf(useBodyEncodingForURI));
|
public void | setUseIPVHosts(boolean useIPVHosts)Enable the use of IP-based virtual hosting.
this.useIPVHosts = useIPVHosts;
setProperty("useIPVHosts", String.valueOf(useIPVHosts));
|
public void | setXpoweredBy(boolean xpoweredBy)Enables or disables the generation of an X-Powered-By header (with value
Servlet/2.4) for all servlet-generated responses returned by this
Connector.
this.xpoweredBy = xpoweredBy;
setProperty("xpoweredBy", String.valueOf(xpoweredBy));
|
public void | start()Begin processing requests via this Connector.
if( !initialized )
initialize();
// Validate and update our current state
if (started ) {
if(log.isInfoEnabled())
log.info(sm.getString("coyoteConnector.alreadyStarted"));
return;
}
lifecycle.fireLifecycleEvent(START_EVENT, null);
started = true;
// We can't register earlier - the JMX registration of this happens
// in Server.start callback
if ( this.oname != null ) {
// We are registred - register the adapter as well.
try {
Registry.getRegistry(null, null).registerComponent
(protocolHandler, createObjectName(this.domain,"ProtocolHandler"), null);
} catch (Exception ex) {
log.error(sm.getString
("coyoteConnector.protocolRegistrationFailed"), ex);
}
} else {
if(log.isInfoEnabled())
log.info(sm.getString
("coyoteConnector.cannotRegisterProtocol"));
}
try {
protocolHandler.start();
} catch (Exception e) {
String errPrefix = "";
if(this.service != null) {
errPrefix += "service.getName(): \"" + this.service.getName() + "\"; ";
}
throw new LifecycleException
(errPrefix + " " + sm.getString
("coyoteConnector.protocolHandlerStartFailed", e));
}
if( this.domain != null ) {
mapperListener.setDomain( domain );
//mapperListener.setEngine( service.getContainer().getName() );
mapperListener.init();
try {
ObjectName mapperOname = createObjectName(this.domain,"Mapper");
if (log.isDebugEnabled())
log.debug(sm.getString(
"coyoteConnector.MapperRegistration", mapperOname));
Registry.getRegistry(null, null).registerComponent
(mapper, mapperOname, "Mapper");
} catch (Exception ex) {
log.error(sm.getString
("coyoteConnector.protocolRegistrationFailed"), ex);
}
}
|
public void | stop()Terminate processing requests via this Connector.
// Validate and update our current state
if (!started) {
log.error(sm.getString("coyoteConnector.notStarted"));
return;
}
lifecycle.fireLifecycleEvent(STOP_EVENT, null);
started = false;
try {
mapperListener.destroy();
Registry.getRegistry(null, null).unregisterComponent
(createObjectName(this.domain,"Mapper"));
Registry.getRegistry(null, null).unregisterComponent
(createObjectName(this.domain,"ProtocolHandler"));
} catch (MalformedObjectNameException e) {
log.error( sm.getString
("coyoteConnector.protocolUnregistrationFailed"), e);
}
try {
protocolHandler.destroy();
} catch (Exception e) {
throw new LifecycleException
(sm.getString
("coyoteConnector.protocolHandlerDestroyFailed", e));
}
|