FileDocCategorySizeDatePackage
JkCoyoteHandler.javaAPI DocApache Tomcat 6.0.146831Fri Jul 20 04:20:36 BST 2007org.apache.jk.server

JkCoyoteHandler

public class JkCoyoteHandler extends org.apache.jk.core.JkHandler implements org.apache.coyote.ProtocolHandler
Plugs Jk into Coyote. Must be named "type=JkHandler,name=container" jmx:notification-handler name="org.apache.jk.SEND_PACKET jmx:notification-handler name="org.apache.coyote.ACTION_COMMIT

Fields Summary
protected static org.apache.juli.logging.Log
log
private boolean
paused
int
epNote
org.apache.coyote.Adapter
adapter
protected JkMain
jkMain
boolean
started
Constructors Summary
Methods Summary
public voiddestroy()

        if( !started ) return;

        started = false;
        getJkMain().stop();
    
public org.apache.coyote.AdaptergetAdapter()

        return adapter;
    
public java.lang.ObjectgetAttribute(java.lang.String name)
Retrieve config info. Primarily for use with the admin webapp.

        return getJkMain().getProperty(name);
    
public java.util.IteratorgetAttributeNames()

       return properties.keySet().iterator();
    
public JkMaingetJkMain()

        if( jkMain == null ) {
            jkMain=new JkMain();
            jkMain.setWorkerEnv(wEnv);
            
        }
        return jkMain;
    
public java.lang.StringgetProperty(java.lang.String name)

        return properties.getProperty(name) ;
    
public voidinit()
Start the protocol

    
            
       
        if( started ) return;

        started=true;
        
        if( wEnv==null ) {
            // we are probably not registered - not very good.
            wEnv=getJkMain().getWorkerEnv();
            wEnv.addHandler("container", this );
        }

        try {
            // jkMain.setJkHome() XXX;
            
            getJkMain().init();

        } catch( Exception ex ) {
            log.error("Error during init",ex);
        }
    
public intinvoke(org.apache.jk.core.Msg msg, org.apache.jk.core.MsgContext ep)

        if( ep.isLogTimeEnabled() ) 
            ep.setLong( MsgContext.TIMER_PRE_REQUEST, System.currentTimeMillis());
        
        Request req=ep.getRequest();
        Response res=req.getResponse();

        if( log.isDebugEnabled() )
            log.debug( "Invoke " + req + " " + res + " " + req.requestURI().toString());
        
        res.setNote( epNote, ep );
        ep.setStatus( MsgContext.JK_STATUS_HEAD );
        RequestInfo rp = req.getRequestProcessor();
        rp.setStage(Constants.STAGE_SERVICE);
        try {
            adapter.service( req, res );
        } catch( Exception ex ) {
            log.info("Error servicing request " + req,ex);
        }
        if(ep.getStatus() != MsgContext.JK_STATUS_CLOSED) {
            res.finish();
        }

        req.recycle();
        req.updateCounters();
        res.recycle();
        ep.recycle();
        if( ep.getStatus() == MsgContext.JK_STATUS_ERROR ) {
            return ERROR;
        }
        ep.setStatus( MsgContext.JK_STATUS_NEW );
        rp.setStage(Constants.STAGE_KEEPALIVE);
        return OK;
    
public voidpause()

        if(!paused) {
            paused = true;
            getJkMain().pause();
        }
    
public javax.management.ObjectNamepreRegister(javax.management.MBeanServer server, javax.management.ObjectName oname)

        // override - we must be registered as "container"
        this.name="container";        
        return super.preRegister(server, oname);
    
public voidresume()

        if(paused) {
            paused = false;
            getJkMain().resume();
        }
    
public voidsetAdapter(org.apache.coyote.Adapter adapter)
The adapter, used to call the connector

        this.adapter=adapter;
    
public voidsetAttribute(java.lang.String name, java.lang.Object value)
Pass config info

        if( log.isDebugEnabled())
            log.debug("setAttribute " + name + " " + value );
        if( value instanceof String )
            this.setProperty( name, (String)value );
    
public voidsetProperty(java.lang.String name, java.lang.String value)
Set a property. Name is a "component.property". JMX should be used instead.


                     
            
        if( log.isTraceEnabled())
            log.trace("setProperty " + name + " " + value );
        getJkMain().setProperty( name, value );
        properties.put( name, value );
    
public voidstart()

        try {
            if( oname != null && getJkMain().getDomain() == null) {
                try {
                    ObjectName jkmainOname = 
                        new ObjectName(oname.getDomain() + ":type=JkMain");
                    Registry.getRegistry(null, null)
                        .registerComponent(getJkMain(), jkmainOname, "JkMain");
                } catch (Exception e) {
                    log.error( "Error registering jkmain " + e );
                }
            }
            getJkMain().start();
        } catch( Exception ex ) {
            log.error("Error during startup",ex);
        }