remm        2005/08/01 03:00:59

  Modified:    jk/java/org/apache/coyote/ajp LocalStrings.properties
                        AjpAprProtocol.java
  Log:
  - Internationalization and code cleanups.
  - No functional change.
  
  Revision  Changes    Path
  1.5       +2 -1      
jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/LocalStrings.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LocalStrings.properties   1 Aug 2005 09:40:14 -0000       1.4
  +++ LocalStrings.properties   1 Aug 2005 10:00:59 -0000       1.5
  @@ -22,6 +22,7 @@
   ajpprotocol.endpoint.resumeerror=Error resuming endpoint
   ajpprotocol.failedread=Socket read failed
   ajpprotocol.failedwrite=Socket write failed
  +ajpprotocol.request.register=Error registering request processor in JMX
   
   ajpprocessor.header.error=Header message parsing failed
   ajpprocessor.request.prepare=Error preparing request
  
  
  
  1.7       +145 -86   
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AjpAprProtocol.java       26 Jul 2005 16:13:33 -0000      1.6
  +++ AjpAprProtocol.java       1 Aug 2005 10:00:59 -0000       1.7
  @@ -45,41 +45,98 @@
    * @author Remy Maucherat
    * @author Costin Manolache
    */
  -public class AjpAprProtocol implements ProtocolHandler, MBeanRegistration
  -{
  +public class AjpAprProtocol 
  +    implements ProtocolHandler, MBeanRegistration {
  +    
  +    
  +    protected static org.apache.commons.logging.Log log =
  +        org.apache.commons.logging.LogFactory.getLog(AjpAprProtocol.class);
  +
  +    /**
  +     * The string manager for this package.
  +     */
  +    protected static StringManager sm =
  +        StringManager.getManager(Constants.Package);
  +
  +
  +    // ------------------------------------------------------------ 
Constructor
  +
  +
       public AjpAprProtocol() {
  -        cHandler = new AjpConnectionHandler( this );
  +        cHandler = new AjpConnectionHandler(this);
           setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
           setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
           //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
           setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
       }
   
  +    
  +    // ----------------------------------------------------- Instance 
Variables
  +
  +
  +    protected ObjectName tpOname;
  +    
  +    
  +    protected ObjectName rgOname;
  +
  +
       /**
  -     * The string manager for this package.
  +     * Associated APR endpoint.
        */
  -    protected static StringManager sm =
  -        StringManager.getManager(Constants.Package);
  +    protected AprEndpoint ep = new AprEndpoint();
   
  -    /** Pass config info
  +
  +    /**
  +     * Configuration attributes.
        */
  -    public void setAttribute( String name, Object value ) {
  -        if( log.isTraceEnabled())
  -            log.trace(sm.getString("ajpprotocol.setattribute", name, value));
  +    protected Hashtable attributes = new Hashtable();
  +
  +
  +    /**
  +     * Should authentication be done in the native webserver layer, 
  +     * or in the Servlet container ?
  +     */
  +    protected boolean tomcatAuthentication = true;
  +
   
  +    /**
  +     * Adapter which will process the requests recieved by this endpoint.
  +     */
  +    private Adapter adapter;
  +    
  +    
  +    /**
  +     * Connection handler for AJP.
  +     */
  +    private AjpConnectionHandler cHandler;
  +
  +
  +    // --------------------------------------------------------- Public 
Methods
  +
  +
  +    /** 
  +     * Pass config info
  +     */
  +    public void setAttribute(String name, Object value) {
  +        if (log.isTraceEnabled()) {
  +            log.trace(sm.getString("ajpprotocol.setattribute", name, value));
  +        }
           attributes.put(name, value);
       }
   
  -    public Object getAttribute( String key ) {
  -        if( log.isTraceEnabled())
  +    public Object getAttribute(String key) {
  +        if (log.isTraceEnabled()) {
               log.trace(sm.getString("ajpprotocol.getattribute", key));
  +        }
           return attributes.get(key);
       }
   
  +
       public Iterator getAttributeNames() {
           return attributes.keySet().iterator();
       }
   
  +
       /**
        * Set a property.
        */
  @@ -87,19 +144,23 @@
           setAttribute(name, value);
       }
   
  +
       /**
        * Get a property
        */
       public String getProperty(String name) {
  -        return (String)getAttribute(name);
  +        return (String) getAttribute(name);
       }
   
  -    /** The adapter, used to call the connector
  +
  +    /**
  +     * The adapter, used to call the connector
        */
       public void setAdapter(Adapter adapter) {
  -        this.adapter=adapter;
  +        this.adapter = adapter;
       }
   
  +
       public Adapter getAdapter() {
           return adapter;
       }
  @@ -112,37 +173,32 @@
           ep.setHandler(cHandler);
           ep.setUseSendfile(false);
   
  -        // XXX get domain from registration
           try {
               ep.init();
           } catch (Exception ex) {
               log.error(sm.getString("ajpprotocol.endpoint.initerror"), ex);
               throw ex;
           }
  -        if(log.isInfoEnabled())
  +        if (log.isInfoEnabled()) {
               log.info(sm.getString("ajpprotocol.init", getName()));
  -
  +        }
       }
   
  -    ObjectName tpOname;
  -    ObjectName rgOname;
   
       public void start() throws Exception {
  -        if( this.domain != null ) {
  +        if (this.domain != null ) {
               try {
  -                // XXX We should be able to configure it separately
  -                // XXX It should be possible to use a single TP
  -                tpOname=new ObjectName
  +                tpOname = new ObjectName
                       (domain + ":" + "type=ThreadPool,name=" + getName());
                   Registry.getRegistry(null, null)
  -                .registerComponent(ep, tpOname, null );
  +                    .registerComponent(ep, tpOname, null );
               } catch (Exception e) {
                   log.error("Can't register threadpool" );
               }
  -            rgOname=new ObjectName
  +            rgOname = new ObjectName
                   (domain + ":type=GlobalRequestProcessor,name=" + getName());
               Registry.getRegistry(null, null).registerComponent
  -                ( cHandler.global, rgOname, null );
  +                (cHandler.global, rgOname, null);
           }
   
           try {
  @@ -151,7 +207,7 @@
               log.error(sm.getString("ajpprotocol.endpoint.starterror"), ex);
               throw ex;
           }
  -        if(log.isInfoEnabled())
  +        if (log.isInfoEnabled())
               log.info(sm.getString("ajpprotocol.start", getName()));
       }
   
  @@ -162,7 +218,7 @@
               log.error(sm.getString("ajpprotocol.endpoint.pauseerror"), ex);
               throw ex;
           }
  -        if(log.isInfoEnabled())
  +        if (log.isInfoEnabled())
               log.info(sm.getString("ajpprotocol.pause", getName()));
       }
   
  @@ -173,89 +229,83 @@
               log.error(sm.getString("ajpprotocol.endpoint.resumeerror"), ex);
               throw ex;
           }
  -        if(log.isInfoEnabled())
  +        if (log.isInfoEnabled())
               log.info(sm.getString("ajpprotocol.resume", getName()));
       }
   
       public void destroy() throws Exception {
  -        if(log.isInfoEnabled())
  +        if (log.isInfoEnabled())
               log.info(sm.getString("ajpprotocol.stop", getName()));
           ep.destroy();
  -        if( tpOname!=null )
  +        if (tpOname!=null)
               Registry.getRegistry(null, null).unregisterComponent(tpOname);
  -        if( rgOname != null )
  +        if (rgOname != null)
               Registry.getRegistry(null, null).unregisterComponent(rgOname);
       }
   
  -    // -------------------- Properties--------------------
  -    protected AprEndpoint ep=new AprEndpoint();
  -    protected boolean secure;
  -
  -    protected Hashtable attributes = new Hashtable();
  -
  -    private int timeout = 300000;   // 5 minutes as in Apache HTTPD server
  -    protected boolean tomcatAuthentication = true;
  -
  -    private Adapter adapter;
  -    private AjpConnectionHandler cHandler;
  -
  -    // -------------------- Pool setup --------------------
   
       public int getMaxThreads() {
           return ep.getMaxThreads();
       }
   
  -    public void setMaxThreads( int maxThreads ) {
  +    public void setMaxThreads(int maxThreads) {
           ep.setMaxThreads(maxThreads);
           setAttribute("maxThreads", "" + maxThreads);
       }
   
       public void setThreadPriority(int threadPriority) {
  -      ep.setThreadPriority(threadPriority);
  -      setAttribute("threadPriority", "" + threadPriority);
  +        ep.setThreadPriority(threadPriority);
  +        setAttribute("threadPriority", "" + threadPriority);
       }
  -
  +    
       public int getThreadPriority() {
  -      return ep.getThreadPriority();
  +        return ep.getThreadPriority();
       }
  -
  -    // -------------------- Tcp setup --------------------
  +    
   
       public int getBacklog() {
           return ep.getBacklog();
       }
   
  +
       public void setBacklog( int i ) {
           ep.setBacklog(i);
           setAttribute("backlog", "" + i);
       }
   
  +
       public int getPort() {
           return ep.getPort();
       }
   
  +
       public void setPort( int port ) {
           ep.setPort(port);
           setAttribute("port", "" + port);
       }
   
  +
       public boolean getUseSendfile() {
           return ep.getUseSendfile();
       }
   
  +
       public void setUseSendfile(boolean useSendfile) {
           // No sendfile for AJP
       }
   
  +
       public InetAddress getAddress() {
           return ep.getAddress();
       }
   
  +
       public void setAddress(InetAddress ia) {
  -        ep.setAddress( ia );
  +        ep.setAddress(ia);
           setAttribute("address", "" + ia);
       }
   
  +
       public String getName() {
           String encodedAddr = "";
           if (getAddress() != null) {
  @@ -267,86 +317,93 @@
           return ("ajp-" + encodedAddr + ep.getPort());
       }
   
  +
       public boolean getTcpNoDelay() {
           return ep.getTcpNoDelay();
       }
   
  -    public void setTcpNoDelay( boolean b ) {
  -        ep.setTcpNoDelay( b );
  +
  +    public void setTcpNoDelay(boolean b) {
  +        ep.setTcpNoDelay(b);
           setAttribute("tcpNoDelay", "" + b);
       }
   
  +
       public boolean getTomcatAuthentication() {
           return tomcatAuthentication;
       }
   
  +
       public void setTomcatAuthentication(boolean tomcatAuthentication) {
           this.tomcatAuthentication = tomcatAuthentication;
       }
   
  +
       public int getFirstReadTimeout() {
           return ep.getFirstReadTimeout();
       }
   
  -    public void setFirstReadTimeout( int i ) {
  +
  +    public void setFirstReadTimeout(int i) {
           ep.setFirstReadTimeout(i);
           setAttribute("firstReadTimeout", "" + i);
       }
   
  +
       public int getPollTime() {
           return ep.getPollTime();
       }
   
  -    public void setPollTime( int i ) {
  +
  +    public void setPollTime(int i) {
           ep.setPollTime(i);
           setAttribute("pollTime", "" + i);
       }
   
  +
       public void setPollerSize(int i) {
           ep.setPollerSize(i); 
           setAttribute("pollerSize", "" + i);
       }
  -    
  +
  +
       public int getPollerSize() {
           return ep.getPollerSize();
       }
  -    
  +
  +
       public int getSoLinger() {
           return ep.getSoLinger();
       }
   
  -    public void setSoLinger( int i ) {
  -        ep.setSoLinger( i );
  +
  +    public void setSoLinger(int i) {
  +        ep.setSoLinger(i);
           setAttribute("soLinger", "" + i);
       }
   
  +
       public int getSoTimeout() {
           return ep.getSoTimeout();
       }
   
  +
       public void setSoTimeout( int i ) {
           ep.setSoTimeout(i);
           setAttribute("soTimeout", "" + i);
       }
   
  -    public int getTimeout() {
  -        return timeout;
  -    }
  -
  -    public void setTimeout( int timeouts ) {
  -        timeout = timeouts;
  -        setAttribute("timeout", "" + timeouts);
  -    }
  +    
  +    // --------------------------------------  AjpConnectionHandler Inner 
Class
   
  -    // --------------------  Connection handler --------------------
   
  -    static class AjpConnectionHandler implements Handler {
  -        AjpAprProtocol proto;
  -        static int count=0;
  -        RequestGroupInfo global=new RequestGroupInfo();
  -        ThreadLocal localProcessor = new ThreadLocal();
  +    protected static class AjpConnectionHandler implements Handler {
  +        protected AjpAprProtocol proto;
  +        protected static int count = 0;
  +        protected RequestGroupInfo global=new RequestGroupInfo();
  +        protected ThreadLocal localProcessor = new ThreadLocal();
   
  -        AjpConnectionHandler(AjpAprProtocol proto) {
  +        public AjpConnectionHandler(AjpAprProtocol proto) {
               this.proto = proto;
           }
   
  @@ -362,14 +419,15 @@
                       if (proto.getDomain() != null) {
                           synchronized (this) {
                               try {
  -                                RequestInfo 
rp=processor.getRequest().getRequestProcessor();
  +                                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");
  +                                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(sm.getString("ajpprotocol.request.register"));
                               }
                           }
                       }
  @@ -410,11 +468,10 @@
           }
       }
   
  -    protected static org.apache.commons.logging.Log log
  -        = org.apache.commons.logging.LogFactory.getLog(AjpAprProtocol.class);
   
       // -------------------- Various implementation classes 
--------------------
   
  +
       protected String domain;
       protected ObjectName oname;
       protected MBeanServer mserver;
  @@ -443,4 +500,6 @@
   
       public void postDeregister() {
       }
  +    
  + 
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to