// ----------------------------------------------------------- Constructors
- public AjpAprProcessor(AprEndpoint endpoint) {
+ public AjpAprProcessor(int packetSize, AprEndpoint endpoint) {
this.endpoint = endpoint;
response.setOutputBuffer(new SocketOutputBuffer());
request.setResponse(response);
+ requestHeaderMessage = new AjpMessage(packetSize);
+ responseHeaderMessage = new AjpMessage(packetSize);
+ bodyMessage = new AjpMessage(packetSize);
+
if (endpoint.getFirstReadTimeout() > 0) {
readTimeout = endpoint.getFirstReadTimeout() * 1000;
} else {
}
// Allocate input and output buffers
- inputBuffer = ByteBuffer.allocateDirect(Constants.MAX_PACKET_SIZE * 2);
+ inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
inputBuffer.limit(0);
- outputBuffer = ByteBuffer.allocateDirect(Constants.MAX_PACKET_SIZE * 2);
+ outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
// Cause loading of HexUtils
int foo = HexUtils.DEC[0];
* processing of the first message of a "request", so it might not be a request
* header. It will stay unchanged during the processing of the whole request.
*/
- protected AjpMessage requestHeaderMessage = new AjpMessage();
+ protected AjpMessage requestHeaderMessage = null;
/**
* Message used for response header composition.
*/
- protected AjpMessage responseHeaderMessage = new AjpMessage();
+ protected AjpMessage responseHeaderMessage = null;
/**
* Body message.
*/
- protected AjpMessage bodyMessage = new AjpMessage();
+ protected AjpMessage bodyMessage = null;
/**
static {
// Set the get body message buffer
- AjpMessage getBodyMessage = new AjpMessage();
+ AjpMessage getBodyMessage = new AjpMessage(128);
getBodyMessage.reset();
getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
getBodyMessage.getLen());
// Set the read body message buffer
- AjpMessage pongMessage = new AjpMessage();
+ AjpMessage pongMessage = new AjpMessage(128);
pongMessage.reset();
pongMessage.appendByte(Constants.JK_AJP13_CPONG_REPLY);
pongMessage.end();
pongMessage.getLen());
// Allocate the end message array
- AjpMessage endMessage = new AjpMessage();
+ AjpMessage endMessage = new AjpMessage(128);
endMessage.reset();
endMessage.appendByte(Constants.JK_AJP13_END_RESPONSE);
endMessage.appendByte(1);
// Error flag
error = false;
- long soTimeout = endpoint.getSoTimeout();
-
int limit = 0;
if (endpoint.getFirstReadTimeout() > 0) {
limit = endpoint.getMaxThreads() / 2;
/**
+ * AJP packet size.
+ */
+ protected int packetSize = Constants.MAX_PACKET_SIZE;
+
+
+ /**
* Adapter which will process the requests recieved by this endpoint.
*/
private Adapter adapter;
}
+ public int getPacketSize() {
+ return packetSize;
+ }
+
+
+ public void setPacketSize(int i) {
+ packetSize = i;
+ }
+
+
// -------------------------------------- AjpConnectionHandler Inner Class
protected AjpAprProtocol proto;
protected static int count = 0;
protected RequestGroupInfo global=new RequestGroupInfo();
- protected ThreadLocal localProcessor = new ThreadLocal();
+ protected ThreadLocal<AjpAprProcessor> localProcessor = new ThreadLocal<AjpAprProcessor>();
public AjpConnectionHandler(AjpAprProtocol proto) {
this.proto = proto;
public SocketState process(long socket) {
AjpAprProcessor processor = null;
try {
- processor = (AjpAprProcessor) localProcessor.get();
+ processor = localProcessor.get();
if (processor == null) {
- processor = new AjpAprProcessor(proto.ep);
+ processor = new AjpAprProcessor(proto.packetSize, proto.ep);
processor.setAdapter(proto.adapter);
processor.setTomcatAuthentication(proto.tomcatAuthentication);
processor.setRequiredSecret(proto.requiredSecret);
StringManager.getManager(Constants.Package);
+ // ------------------------------------------------------------ Constructor
+
+
+ public AjpMessage(int packetSize) {
+ buf = new byte[packetSize];
+ }
+
+
// ----------------------------------------------------- Instance Variables
/**
* Fixed size buffer.
*/
- protected byte buf[] = new byte[8 * 1024];
+ protected byte buf[] = null;
/**
// ----------------------------------------------------------- Constructors
- public AjpProcessor(JIoEndpoint endpoint) {
+ public AjpProcessor(int packetSize, JIoEndpoint endpoint) {
this.endpoint = endpoint;
response.setOutputBuffer(new SocketOutputBuffer());
request.setResponse(response);
+ requestHeaderMessage = new AjpMessage(packetSize);
+ responseHeaderMessage = new AjpMessage(packetSize);
+ bodyMessage = new AjpMessage(packetSize);
+
// Cause loading of HexUtils
int foo = HexUtils.DEC[0];
* processing of the first message of a "request", so it might not be a request
* header. It will stay unchanged during the processing of the whole request.
*/
- protected AjpMessage requestHeaderMessage = new AjpMessage();
+ protected AjpMessage requestHeaderMessage = null;
/**
* Message used for response header composition.
*/
- protected AjpMessage responseHeaderMessage = new AjpMessage();
+ protected AjpMessage responseHeaderMessage = null;
/**
* Body message.
*/
- protected AjpMessage bodyMessage = new AjpMessage();
+ protected AjpMessage bodyMessage = null;
/**
static {
// Set the get body message buffer
- AjpMessage getBodyMessage = new AjpMessage();
+ AjpMessage getBodyMessage = new AjpMessage(128);
getBodyMessage.reset();
getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
0, getBodyMessage.getLen());
// Set the read body message buffer
- AjpMessage pongMessage = new AjpMessage();
+ AjpMessage pongMessage = new AjpMessage(128);
pongMessage.reset();
pongMessage.appendByte(Constants.JK_AJP13_CPONG_REPLY);
pongMessage.end();
0, pongMessage.getLen());
// Allocate the end message array
- AjpMessage endMessage = new AjpMessage();
+ AjpMessage endMessage = new AjpMessage(128);
endMessage.reset();
endMessage.appendByte(Constants.JK_AJP13_END_RESPONSE);
endMessage.appendByte(1);
// Error flag
error = false;
- long soTimeout = endpoint.getSoTimeout();
-
while (started && !error) {
// Parsing the request header
/**
+ * AJP packet size.
+ */
+ protected int packetSize = Constants.MAX_PACKET_SIZE;
+
+
+ /**
* Adapter which will process the requests recieved by this endpoint.
*/
private Adapter adapter;
}
+ public int getPacketSize() {
+ return packetSize;
+ }
+
+
+ public void setPacketSize(int i) {
+ packetSize = i;
+ }
+
+
// -------------------------------------- AjpConnectionHandler Inner Class
protected AjpProtocol proto;
protected static int count = 0;
protected RequestGroupInfo global=new RequestGroupInfo();
- protected ThreadLocal localProcessor = new ThreadLocal();
+ protected ThreadLocal<AjpProcessor> localProcessor = new ThreadLocal<AjpProcessor>();
public AjpConnectionHandler(AjpProtocol proto) {
this.proto = proto;
public boolean process(Socket socket) {
AjpProcessor processor = null;
try {
- processor = (AjpProcessor) localProcessor.get();
+ processor = localProcessor.get();
if (processor == null) {
- processor = new AjpProcessor(proto.ep);
+ processor = new AjpProcessor(proto.packetSize, proto.ep);
processor.setAdapter(proto.adapter);
processor.setTomcatAuthentication(proto.tomcatAuthentication);
processor.setRequiredSecret(proto.requiredSecret);