import javax.management.ObjectName;
import org.apache.juli.logging.Log;
+import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.net.AbstractEndpoint.Handler;
import org.apache.tomcat.util.res.StringManager;
public void postDeregister() {
// NOOP
}
+
+
+ // ------------------------------------------------------- Lifecycle methods
+
+ // TODO Keep current state and check for invalid transitions
+
+ @Override
+ public abstract void init() throws Exception;
+
+
+ @Override
+ public final void destroy() {
+ if(getLog().isInfoEnabled()) {
+ getLog().info(sm.getString("abstractProtocolHandler.destroy",
+ getName()));
+ }
+ try {
+ endpoint.destroy();
+ } catch (Exception e) {
+ getLog().error(sm.getString(
+ "abstractProtocolHandler.endPointDestroyError", getName()),
+ e);
+ }
+
+ if( tpOname!=null )
+ Registry.getRegistry(null, null).unregisterComponent(tpOname);
+ if( rgOname != null )
+ Registry.getRegistry(null, null).unregisterComponent(rgOname);
+ }
}
abstractProtocolHandler.getAttribute=Get attribute [{0}] with value [{1}]
abstractProtocolHandler.setAttribute=Set attribute [{0}] with value [{1}]
+abstractProtocolHandler.endPointDestroyError=Failed to destroy end point associated with ProtocolHandler [{0}]
+abstractProtocolHandler.destroy=Destroying ProtocolHandler [{0}]
asyncStateMachine.invalidAsyncState=Calling [{0}] is not valid for a request with Async state [{1}]
package org.apache.coyote.ajp;
import org.apache.coyote.AbstractProtocolHandler;
-import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.res.StringManager;
public abstract class AbstractAjpProtocol extends AbstractProtocolHandler {
if (getLog().isInfoEnabled())
getLog().info(sm.getString("ajpprotocol.stop", getName()));
}
-
-
- @Override
- public void destroy() throws Exception {
- if (getLog().isInfoEnabled())
- getLog().info(sm.getString("ajpprotocol.destroy", getName()));
- endpoint.destroy();
- if (tpOname!=null)
- Registry.getRegistry(null, null).unregisterComponent(tpOname);
- if (rgOname != null)
- Registry.getRegistry(null, null).unregisterComponent(rgOname);
- }
}
protected AjpAprProtocol proto;
protected AtomicLong registerCount = new AtomicLong(0);
protected RequestGroupInfo global = new RequestGroupInfo();
- @Override
- public RequestGroupInfo getGlobal() {
- return global;
- }
protected ConcurrentHashMap<SocketWrapper<Long>, AjpAprProcessor> connections =
new ConcurrentHashMap<SocketWrapper<Long>, AjpAprProcessor>();
this.proto = proto;
}
+ @Override
+ public RequestGroupInfo getGlobal() {
+ return global;
+ }
+
+ @Override
+ public void recycle() {
+ recycledProcessors.clear();
+ }
+
// FIXME: Support for this could be added in AJP as well
@Override
public SocketState event(SocketWrapper<Long> socket, SocketStatus status) {
protected AjpProtocol proto;
protected AtomicLong registerCount = new AtomicLong(0);
protected RequestGroupInfo global = new RequestGroupInfo();
- @Override
- public RequestGroupInfo getGlobal() {
- return global;
- }
protected ConcurrentHashMap<SocketWrapper<Socket>, AjpProcessor> connections =
new ConcurrentHashMap<SocketWrapper<Socket>, AjpProcessor>();
}
@Override
+ public RequestGroupInfo getGlobal() {
+ return global;
+ }
+
+ @Override
+ public void recycle() {
+ recycledProcessors.clear();
+ }
+
+ @Override
public SocketState process(SocketWrapper<Socket> socket) {
return process(socket,SocketStatus.OPEN);
}
# AjpAprProtocol
#
-ajpprotocol.destroy=Destroying Coyote AJP/1.3 on {0}
ajpprotocol.endpoint.initerror=Error initializing endpoint
ajpprotocol.endpoint.starterror=Error starting endpoint
ajpprotocol.endpoint.stoperror=Error stopping endpoint
package org.apache.coyote.http11;
import org.apache.coyote.AbstractProtocolHandler;
-import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.res.StringManager;
public abstract class AbstractHttp11Protocol extends AbstractProtocolHandler {
// ------------------------------------------------------- Lifecycle methods
@Override
- public abstract void init() throws Exception;
-
- @Override
public void pause() throws Exception {
try {
endpoint.pause();
if(getLog().isInfoEnabled())
getLog().info(sm.getString("http11protocol.stop", getName()));
}
-
- @Override
- public void destroy() throws Exception {
- if(getLog().isInfoEnabled())
- getLog().info(sm.getString("http11protocol.destroy", getName()));
- endpoint.destroy();
- if( tpOname!=null )
- Registry.getRegistry(null, null).unregisterComponent(tpOname);
- if( rgOname != null )
- Registry.getRegistry(null, null).unregisterComponent(rgOname);
- }
-
-
}
log.info(sm.getString("http11protocol.start", getName()));
}
- @Override
- public void destroy() throws Exception {
- cHandler.recycledProcessors.clear();
- super.destroy();
- }
-
private Http11ConnectionHandler cHandler;
public boolean getUseSendfile() { return ((AprEndpoint)endpoint).getUseSendfile(); }
protected Http11AprProtocol proto;
protected AtomicLong registerCount = new AtomicLong(0);
protected RequestGroupInfo global = new RequestGroupInfo();
- @Override
- public RequestGroupInfo getGlobal() {
- return global;
- }
protected ConcurrentHashMap<SocketWrapper<Long>, Http11AprProcessor> connections =
new ConcurrentHashMap<SocketWrapper<Long>, Http11AprProcessor>();
+
protected ConcurrentLinkedQueue<Http11AprProcessor> recycledProcessors =
new ConcurrentLinkedQueue<Http11AprProcessor>() {
private static final long serialVersionUID = 1L;
}
@Override
+ public RequestGroupInfo getGlobal() {
+ return global;
+ }
+
+ @Override
+ public void recycle() {
+ recycledProcessors.clear();
+ }
+
+ @Override
public SocketState event(SocketWrapper<Long> socket, SocketStatus status) {
Http11AprProcessor processor = connections.get(socket);
protected Http11NioProtocol proto;
protected static int count = 0;
protected RequestGroupInfo global = new RequestGroupInfo();
- @Override
- public RequestGroupInfo getGlobal() {
- return global;
- }
protected ConcurrentHashMap<NioChannel, Http11NioProcessor> connections =
new ConcurrentHashMap<NioChannel, Http11NioProcessor>();
+
protected ConcurrentLinkedQueue<Http11NioProcessor> recycledProcessors = new ConcurrentLinkedQueue<Http11NioProcessor>() {
private static final long serialVersionUID = 1L;
protected AtomicInteger size = new AtomicInteger(0);
}
@Override
- public void releaseCaches() {
+ public RequestGroupInfo getGlobal() {
+ return global;
+ }
+
+ @Override
+ public void recycle() {
recycledProcessors.clear();
}
}
- @Override
- public void destroy() throws Exception {
- cHandler.recycledProcessors.clear();
- super.destroy();
- }
// ------------------------------------------------------------- Properties
-
/**
* Name of the socket factory.
*/
protected Http11Protocol proto;
protected AtomicLong registerCount = new AtomicLong(0);
protected RequestGroupInfo global = new RequestGroupInfo();
- @Override
- public RequestGroupInfo getGlobal() {
- return global;
- }
protected ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor> connections =
new ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor>();
}
@Override
+ public RequestGroupInfo getGlobal() {
+ return global;
+ }
+
+ @Override
+ public void recycle() {
+ recycledProcessors.clear();
+ }
+
+ @Override
public SocketState process(SocketWrapper<Socket> socket) {
return process(socket,SocketStatus.OPEN);
}
public static interface Handler {
/**
- * Different types of socket states to react upon
+ * Different types of socket states to react upon.
*/
public enum SocketState {
OPEN, CLOSED, LONG, ASYNC_END
/**
- * Obtain the GlobalRequestProcessor associated with the handler
+ * Obtain the GlobalRequestProcessor associated with the handler.
*/
public RequestGroupInfo getGlobal();
+
+
+ /**
+ * Recycle resources associated with the handler.
+ */
+ public void recycle();
}
// Standard SSL Configuration attributes
rootPool = 0;
}
+ handler.recycle();
+
initialized = false;
}
}
serverSocket = null;
}
+ handler.recycle();
initialized = false ;
}
this.keyCache.clear();
this.nioChannels.clear();
this.processorCache.clear();
- if ( handler != null ) handler.releaseCaches();
+ if ( handler != null ) handler.recycle();
}
public interface Handler extends AbstractEndpoint.Handler {
public SocketState process(NioChannel socket);
public SocketState event(NioChannel socket, SocketStatus status);
- public void releaseCaches();
public void release(NioChannel socket);
public void release(SocketChannel socket);
}