remm 2005/06/17 04:50:01 Modified: http11/src/java/org/apache/coyote/http11 Http11AprProtocol.java jk/java/org/apache/coyote/ajp AjpAprProtocol.java Log: - Code cleanups (there will be quite a few of them in this class). Revision Changes Path 1.10 +29 -48 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProtocol.java Index: Http11AprProtocol.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProtocol.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Http11AprProtocol.java 17 Jun 2005 09:43:35 -0000 1.9 +++ Http11AprProtocol.java 17 Jun 2005 11:50:01 -0000 1.10 @@ -613,9 +613,6 @@ } // -------------------- Connection handler -------------------- - public static final int THREAD_DATA_PROCESSOR=1; - public static final int THREAD_DATA_OBJECT_NAME=2; - static class Http11ConnectionHandler implements Handler { Http11AprProtocol proto; @@ -627,61 +624,45 @@ this.proto=proto; } - public Object[] init() { - Object thData[]=new Object[3]; - - Http11AprProcessor processor = - new Http11AprProcessor(proto.maxHttpHeaderSize, proto.ep); - processor.setAdapter( proto.adapter ); - processor.setMaxKeepAliveRequests( proto.maxKeepAliveRequests ); - processor.setTimeout( proto.timeout ); - processor.setDisableUploadTimeout( proto.disableUploadTimeout ); - processor.setCompression( proto.compression ); - processor.setCompressionMinSize( proto.compressionMinSize); - processor.setNoCompressionUserAgents( proto.noCompressionUserAgents); - processor.setCompressableMimeTypes( proto.compressableMimeTypes); - processor.setRestrictedUserAgents( proto.restrictedUserAgents); - processor.setSocketBuffer( proto.socketBuffer ); - processor.setMaxSavePostSize( proto.maxSavePostSize ); - processor.setServer( proto.server ); - - thData[Http11AprProtocol.THREAD_DATA_PROCESSOR]=processor; - - if( proto.getDomain() != null ) { - try { - RequestInfo rp=processor.getRequest().getRequestProcessor(); - rp.setGlobalProcessor(global); - ObjectName rpName=new ObjectName - (proto.getDomain() + ":type=RequestProcessor,worker=" - + proto.getName() +",name=HttpRequest" + count++ ); - Registry.getRegistry(null, null).registerComponent( rp, rpName, null); - thData[Http11AprProtocol.THREAD_DATA_OBJECT_NAME]=rpName; - } catch( Exception ex ) { - log.warn("Error registering request"); - } - } - - return thData; - } - public boolean process(long socket) { - Http11AprProcessor processor=null; + Http11AprProcessor processor = null; try { - // FIXME: It is also possible to use the TWA data, so keep init() [] for - // now to test which is more efficient processor = (Http11AprProcessor) localProcessor.get(); if (processor == null) { - processor = (Http11AprProcessor) (init()[Http11AprProtocol.THREAD_DATA_PROCESSOR]); + processor = + new Http11AprProcessor(proto.maxHttpHeaderSize, proto.ep); + processor.setAdapter(proto.adapter); + processor.setMaxKeepAliveRequests(proto.maxKeepAliveRequests); + processor.setTimeout(proto.timeout); + processor.setDisableUploadTimeout(proto.disableUploadTimeout); + processor.setCompression(proto.compression); + processor.setCompressionMinSize(proto.compressionMinSize); + processor.setNoCompressionUserAgents(proto.noCompressionUserAgents); + processor.setCompressableMimeTypes(proto.compressableMimeTypes); + processor.setRestrictedUserAgents(proto.restrictedUserAgents); + processor.setSocketBuffer(proto.socketBuffer); + processor.setMaxSavePostSize(proto.maxSavePostSize); + processor.setServer(proto.server); localProcessor.set(processor); + if (proto.getDomain() != null) { + synchronized (this) { + try { + RequestInfo rp = processor.getRequest().getRequestProcessor(); + rp.setGlobalProcessor(global); + ObjectName rpName = new ObjectName + (proto.getDomain() + ":type=RequestProcessor,worker=" + + proto.getName() + ",name=HttpRequest" + count++); + Registry.getRegistry(null, null).registerComponent(rp, rpName, null); + } catch (Exception e) { + log.warn("Error registering request"); + } + } + } } if (processor instanceof ActionHook) { ((ActionHook) processor).action(ActionCode.ACTION_START, null); } - //socket = connection.getSocket(); - - //InputStream in = socket.getInputStream(); - //OutputStream out = socket.getOutputStream(); // FIXME: SSL implementation /* 1.3 +21 -57 jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java Index: AjpAprProtocol.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AjpAprProtocol.java 17 Jun 2005 09:43:35 -0000 1.2 +++ AjpAprProtocol.java 17 Jun 2005 11:50:01 -0000 1.3 @@ -526,9 +526,6 @@ } // -------------------- Connection handler -------------------- - public static final int THREAD_DATA_PROCESSOR=1; - public static final int THREAD_DATA_OBJECT_NAME=2; - static class AjpConnectionHandler implements Handler { AjpAprProtocol proto; @@ -536,69 +533,39 @@ RequestGroupInfo global=new RequestGroupInfo(); ThreadLocal localProcessor = new ThreadLocal(); - AjpConnectionHandler( AjpAprProtocol proto ) { - this.proto=proto; - } - - public Object[] init() { - Object thData[]=new Object[3]; - - AjpAprProcessor processor = - new AjpAprProcessor(proto.maxHttpHeaderSize, proto.ep); - processor.setAdapter( proto.adapter ); - processor.setMaxPostSize( proto.maxPostSize ); - processor.setServer( proto.server ); - - thData[AjpAprProtocol.THREAD_DATA_PROCESSOR]=processor; - - if( proto.getDomain() != null ) { - try { - RequestInfo rp=processor.getRequest().getRequestProcessor(); - rp.setGlobalProcessor(global); - ObjectName rpName=new ObjectName - (proto.getDomain() + ":type=RequestProcessor,worker=" - + proto.getName() +",name=AjpRequest" + count++ ); - Registry.getRegistry(null, null).registerComponent( rp, rpName, null); - thData[AjpAprProtocol.THREAD_DATA_OBJECT_NAME]=rpName; - } catch( Exception ex ) { - log.warn("Error registering request"); - } - } - - return thData; + AjpConnectionHandler(AjpAprProtocol proto) { + this.proto = proto; } public boolean process(long socket) { - AjpAprProcessor processor=null; + AjpAprProcessor processor = null; try { - // FIXME: It is also possible to use the TWA data, so keep init() [] for - // now to test which is more efficient processor = (AjpAprProcessor) localProcessor.get(); if (processor == null) { - processor = (AjpAprProcessor) (init()[AjpAprProtocol.THREAD_DATA_PROCESSOR]); + processor = new AjpAprProcessor(proto.maxHttpHeaderSize, proto.ep); + processor.setAdapter(proto.adapter); + processor.setMaxPostSize(proto.maxPostSize); + processor.setServer(proto.server); localProcessor.set(processor); + if (proto.getDomain() != null) { + synchronized (this) { + try { + RequestInfo rp=processor.getRequest().getRequestProcessor(); + rp.setGlobalProcessor(global); + ObjectName rpName=new ObjectName + (proto.getDomain() + ":type=RequestProcessor,worker=" + + proto.getName() +",name=AjpRequest" + count++ ); + Registry.getRegistry(null, null).registerComponent( rp, rpName, null); + } catch( Exception ex ) { + log.warn("Error registering request"); + } + } + } } if (processor instanceof ActionHook) { ((ActionHook) processor).action(ActionCode.ACTION_START, null); } - //socket = connection.getSocket(); - - //InputStream in = socket.getInputStream(); - //OutputStream out = socket.getOutputStream(); - - // FIXME: SSL implementation - /* - if( proto.secure ) { - SSLSupport sslSupport=null; - if(proto.sslImplementation != null) - sslSupport = proto.sslImplementation.getSSLSupport(socket); - processor.setSSLSupport(sslSupport); - } else { - processor.setSSLSupport( null ); - } - processor.setSocket( socket ); - */ return processor.process(socket); @@ -623,9 +590,6 @@ AjpAprProtocol.log.error (sm.getString("ajpprotocol.proto.error"), e); } finally { - // if(proto.adapter != null) proto.adapter.recycle(); - // processor.recycle(); - if (processor instanceof ActionHook) { ((ActionHook) processor).action(ActionCode.ACTION_STOP, null); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]