| Method from org.apache.catalina.connector.Connector Detail: |
public void addLifecycleListener(LifecycleListener listener) {
lifecycle.addLifecycleListener(listener);
}
Add a lifecycle event listener to this component. |
protected ObjectName createObjectName(String domain,
String type) throws MalformedObjectNameException {
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() {
Request request = new Request();
request.setConnector(this);
return (request);
}
Create (or allocate) and return a Request object suitable for
specifying the contents of a Request to the responsible Container. |
public Response createResponse() {
Response response = new Response();
response.setConnector(this);
return (response);
}
Create (or allocate) and return a Response object suitable for
receiving the contents of a Response from the responsible Container. |
public void destroy() throws Exception {
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 LifecycleListener[] findLifecycleListeners() {
return lifecycle.findLifecycleListeners();
}
Get the lifecycle listeners associated with this lifecycle. If this
Lifecycle has no listeners registered, a zero-length array is returned. |
public boolean getAllowTrace() {
return (this.allowTrace);
}
True if the TRACE method is allowed. Default value is "false". |
public Object getAttribute(String name) {
return getProperty(name);
}
Return a configured property. |
public int getBufferSize() {
return 2048;
} Deprecated!
Return the input buffer size for this Connector. |
public Container getContainer() {
if( container==null ) {
// Lazy - maybe it was added later
findContainer();
}
return (container);
}
Return the Container used for processing requests received by this
Connector. |
public ObjectName getController() {
return controller;
}
|
public String getDomain() {
return domain;
}
|
public boolean getEmptySessionPath() {
return (this.emptySessionPath);
}
Return the "empty session path" flag. |
public boolean getEnableLookups() {
return (this.enableLookups);
}
Return the "enable DNS lookups" flag. |
public String getInfo() {
return (info);
}
Return descriptive information about this Connector implementation. |
public Mapper getMapper() {
return (mapper);
}
|
public int getMaxPostSize() {
return (maxPostSize);
}
Return the maximum size of a POST which will be automatically
parsed by the container. |
public int getMaxSavePostSize() {
return (maxSavePostSize);
}
Return the maximum size of a POST which will be saved by the container
during authentication. |
public ObjectName getObjectName() {
return oname;
}
|
public int getPort() {
return (this.port);
}
Return the port number on which we listen for requests. |
public Object getProperty(String name) {
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);
}
Return a configured property. |
public String getProtocol() {
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();
}
Return the Coyote protocol handler in use. |
public ProtocolHandler getProtocolHandler() {
return (this.protocolHandler);
}
Return the protocol handler associated with the connector. |
public String getProtocolHandlerClassName() {
return (this.protocolHandlerClassName);
}
Return the class name of the Coyote protocol handler in use. |
public String getProxyName() {
return (this.proxyName);
}
Return the proxy server name for this Connector. |
public int getProxyPort() {
return (this.proxyPort);
}
Return the proxy server port for this Connector. |
public int getRedirectPort() {
return (this.redirectPort);
}
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. |
public String getScheme() {
return (this.scheme);
}
Return the scheme that will be assigned to requests received
through this connector. Default value is "http". |
public boolean getSecure() {
return (this.secure);
}
Return the secure connection flag that will be assigned to requests
received through this connector. Default value is "false". |
public Service getService() {
return (this.service);
}
Return the Service with which we are associated (if any). |
public String getURIEncoding() {
return (this.URIEncoding);
}
Return the character encoding to be used for the URI. |
public boolean getUseBodyEncodingForURI() {
return (this.useBodyEncodingForURI);
}
Return the true if the entity body encoding should be used for the URI. |
public boolean getUseIPVHosts() {
return useIPVHosts;
}
Test if IP-based virtual hosting is enabled. |
public boolean getXpoweredBy() {
return xpoweredBy;
}
Indicates whether the generation of an X-Powered-By response header for
servlet-generated responses is enabled or disabled for this Connector. |
public void init() throws Exception {
if( this.getService() != null ) {
if(log.isDebugEnabled())
log.debug( "Already configured" );
return;
}
if( container==null ) {
findContainer();
}
}
|
public void initialize() throws LifecycleException {
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));
}
}
Initialize this connector (create ServerSocket here!) |
public boolean isAvailable() {
return (started);
}
Is this connector available for processing requests? |
public void pause() throws LifecycleException {
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(Boolean registrationDone) {
}
|
public void preDeregister() throws Exception {
}
|
public ObjectName preRegister(MBeanServer server,
ObjectName name) throws Exception {
oname=name;
mserver=server;
domain=name.getDomain();
return name;
}
|
public void removeLifecycleListener(LifecycleListener listener) {
lifecycle.removeLifecycleListener(listener);
}
Remove a lifecycle event listener from this component. |
public void removeProperty(String name) {
// FIXME !
//protocolHandler.removeAttribute(name);
}
remove a configured property. |
public void resume() throws LifecycleException {
try {
protocolHandler.resume();
} catch (Exception e) {
log.error(sm.getString
("coyoteConnector.protocolHandlerResumeFailed"), e);
}
}
|
public void setAllowTrace(boolean allowTrace) {
this.allowTrace = allowTrace;
setProperty("allowTrace", String.valueOf(allowTrace));
}
Set the allowTrace flag, to disable or enable the TRACE HTTP method. |
public void setAttribute(String name,
Object value) {
setProperty(name, String.valueOf(value));
}
Set a configured property. |
public void setBufferSize(int bufferSize) {
} Deprecated!
Set the input buffer size for this Connector. |
public void setContainer(Container container) {
this.container = container;
}
Set the Container used for processing requests received by this
Connector. |
public void setController(ObjectName controller) {
this.controller = controller;
}
|
public void setEmptySessionPath(boolean emptySessionPath) {
this.emptySessionPath = emptySessionPath;
setProperty("emptySessionPath", String.valueOf(emptySessionPath));
}
Set the "empty session path" flag. |
public void setEnableLookups(boolean enableLookups) {
this.enableLookups = enableLookups;
setProperty("enableLookups", String.valueOf(enableLookups));
}
Set the "enable DNS lookups" flag. |
public void setMaxPostSize(int maxPostSize) {
this.maxPostSize = maxPostSize;
}
Set the maximum size of a POST which will be automatically
parsed by the container. |
public void setMaxSavePostSize(int maxSavePostSize) {
this.maxSavePostSize = maxSavePostSize;
setProperty("maxSavePostSize", String.valueOf(maxSavePostSize));
}
Set the maximum size of a POST which will be saved by the container
during authentication. |
public void setPort(int port) {
this.port = port;
setProperty("port", String.valueOf(port));
}
Set the port number on which we listen for requests. |
public boolean setProperty(String name,
String value) {
String repl = name;
if (replacements.get(name) != null) {
repl = (String) replacements.get(name);
}
return IntrospectionUtils.setProperty(protocolHandler, repl, value);
}
Set a configured property. |
public void setProtocol(String protocol) {
// 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);
}
}
}
Set the Coyote protocol which will be used by the connector. |
public void setProtocolHandlerClassName(String protocolHandlerClassName) {
this.protocolHandlerClassName = protocolHandlerClassName;
}
Set the class name of the Coyote protocol handler which will be used
by the connector. |
public void setProxyName(String proxyName) {
if(proxyName != null && proxyName.length() > 0) {
this.proxyName = proxyName;
setProperty("proxyName", proxyName);
} else {
this.proxyName = null;
removeProperty("proxyName");
}
}
Set the proxy server name for this Connector. |
public void setProxyPort(int proxyPort) {
this.proxyPort = proxyPort;
setProperty("proxyPort", String.valueOf(proxyPort));
}
Set the proxy server port for this Connector. |
public void setRedirectPort(int redirectPort) {
this.redirectPort = redirectPort;
setProperty("redirectPort", String.valueOf(redirectPort));
}
Set the redirect port number. |
public void setScheme(String scheme) {
this.scheme = scheme;
}
Set the scheme that will be assigned to requests received through
this connector. |
public void setSecure(boolean secure) {
this.secure = secure;
setProperty("secure", Boolean.toString(secure));
}
Set the secure connection flag that will be assigned to requests
received through this connector. |
public void setService(Service service) {
this.service = service;
// FIXME: setProperty("service", service);
}
Set the Service with which we are associated (if any). |
public void setURIEncoding(String URIEncoding) {
this.URIEncoding = URIEncoding;
setProperty("uRIEncoding", URIEncoding);
}
Set the URI encoding to be used for the URI. |
public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI) {
this.useBodyEncodingForURI = useBodyEncodingForURI;
setProperty
("useBodyEncodingForURI", String.valueOf(useBodyEncodingForURI));
}
Set if the entity body encoding should be used for the URI. |
public void setUseIPVHosts(boolean useIPVHosts) {
this.useIPVHosts = useIPVHosts;
setProperty("useIPVHosts", String.valueOf(useIPVHosts));
}
Enable the use of IP-based virtual hosting. |
public void setXpoweredBy(boolean xpoweredBy) {
this.xpoweredBy = xpoweredBy;
setProperty("xpoweredBy", String.valueOf(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. |
public void start() throws LifecycleException {
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);
}
}
}
Begin processing requests via this Connector. |
public void stop() throws LifecycleException {
// 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));
}
}
Terminate processing requests via this Connector. |