| Method from org.apache.jk.common.HandlerRequest Detail: |
public boolean getDelayInitialRead() {
return delayInitialRead;
}
Get the flag to tell if we delay the initial body read |
public boolean getRegisterRequests() {
return registerRequests;
}
Get the flag to tell if we JMX register requests. |
public boolean getShutdownEnabled() {
return shutdownEnabled;
}
|
public void init() {
dispatch=(HandlerDispatch)wEnv.getHandler( "dispatch" );
if( dispatch != null ) {
// register incoming message handlers
dispatch.registerMessageType( AjpConstants.JK_AJP13_FORWARD_REQUEST,
"JK_AJP13_FORWARD_REQUEST",
this, null); // 2
dispatch.registerMessageType( AjpConstants.JK_AJP13_SHUTDOWN,
"JK_AJP13_SHUTDOWN",
this, null); // 7
dispatch.registerMessageType( AjpConstants.JK_AJP13_CPING_REQUEST,
"JK_AJP13_CPING_REQUEST",
this, null); // 10
dispatch.registerMessageType( HANDLE_THREAD_END,
"HANDLE_THREAD_END",
this, null);
// register outgoing messages handler
dispatch.registerMessageType( AjpConstants.JK_AJP13_SEND_BODY_CHUNK, // 3
"JK_AJP13_SEND_BODY_CHUNK",
this,null );
}
tmpBufNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "tmpBuf" );
secretNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "secret" );
if( next==null )
next=wEnv.getHandler( "container" );
if( log.isDebugEnabled() )
log.debug( "Container handler " + next + " " + next.getName() +
" " + next.getClass().getName());
// should happen on start()
generateAjp13Id();
}
|
public int invoke(Msg msg,
MsgContext ep) throws IOException {
int type=msg.getByte();
ThreadWithAttributes twa = null;
if (Thread.currentThread() instanceof ThreadWithAttributes) {
twa = (ThreadWithAttributes) Thread.currentThread();
}
Object control=ep.getControl();
MessageBytes tmpMB=(MessageBytes)ep.getNote( tmpBufNote );
if( tmpMB==null ) {
tmpMB= MessageBytes.newInstance();
ep.setNote( tmpBufNote, tmpMB);
}
if( log.isDebugEnabled() )
log.debug( "Handling " + type );
switch( type ) {
case AjpConstants.JK_AJP13_FORWARD_REQUEST:
try {
if (twa != null) {
twa.setCurrentStage(control, "JkDecode");
}
decodeRequest( msg, ep, tmpMB );
if (twa != null) {
twa.setCurrentStage(control, "JkService");
twa.setParam(control,
((Request)ep.getRequest()).unparsedURI());
}
} catch( Exception ex ) {
/* If we are here it is because we have a bad header or something like that */
log.error( "Error decoding request ", ex );
msg.dump( "Incomming message");
Response res=ep.getRequest().getResponse();
if ( res==null ) {
res=new Response();
ep.getRequest().setResponse(res);
}
res.setMessage("Bad Request");
res.setStatus(400);
return ERROR;
}
if( requiredSecret != null ) {
String epSecret=(String)ep.getNote( secretNote );
if( epSecret==null || ! requiredSecret.equals( epSecret ) )
return ERROR;
}
/* XXX it should be computed from request, by workerEnv */
if(log.isDebugEnabled() )
log.debug("Calling next " + next.getName() + " " +
next.getClass().getName());
int err= next.invoke( msg, ep );
if (twa != null) {
twa.setCurrentStage(control, "JkDone");
}
if( log.isDebugEnabled() )
log.debug( "Invoke returned " + err );
return err;
case AjpConstants.JK_AJP13_SHUTDOWN:
String epSecret=null;
if( msg.getLen() > 3 ) {
// we have a secret
msg.getBytes( tmpMB );
epSecret=tmpMB.toString();
}
if( requiredSecret != null &&
requiredSecret.equals( epSecret ) ) {
if( log.isDebugEnabled() )
log.debug("Received wrong secret, no shutdown ");
return ERROR;
}
// XXX add isSameAddress check
JkChannel ch=ep.getSource();
if( !ch.isSameAddress(ep) ) {
log.error("Shutdown request not from 'same address' ");
return ERROR;
}
if( !shutdownEnabled ) {
log.warn("Ignoring shutdown request: shutdown not enabled");
return ERROR;
}
// forward to the default handler - it'll do the shutdown
checkRequest(ep);
next.invoke( msg, ep );
if(log.isInfoEnabled())
log.info("Exiting");
System.exit(0);
return OK;
// We got a PING REQUEST, quickly respond with a PONG
case AjpConstants.JK_AJP13_CPING_REQUEST:
msg.reset();
msg.appendByte(AjpConstants.JK_AJP13_CPONG_REPLY);
ep.getSource().send( msg, ep );
ep.getSource().flush( msg, ep ); // Server needs to get it
return OK;
case HANDLE_THREAD_END:
return OK;
default:
if(log.isInfoEnabled())
log.info("Unknown message " + type);
}
return OK;
}
|
public boolean isTomcatAuthentication() {
return tomcatAuthentication;
}
|
public void setAjpidDir(String path) {
if( "".equals( path ) ) path=null;
ajpidDir=path;
}
|
public void setDecodedUri(boolean b) {
decoded=b;
}
|
public void setDelayInitialRead(boolean dir) {
delayInitialRead = dir;
}
Set the flag to delay the initial body read |
public void setRegisterRequests(boolean srr) {
registerRequests = srr;
}
Set the flag to tell if we JMX register requests. |
public void setSecret(String s) {
requiredSecret=s;
}
|
public void setShutdownEnabled(boolean se) {
shutdownEnabled = se;
}
|
public void setTomcatAuthentication(boolean newTomcatAuthentication) {
tomcatAuthentication = newTomcatAuthentication;
}
|
public void setUseSecret(boolean b) {
if(b) {
requiredSecret=Double.toString(Math.random());
}
}
|