ctx1.setTrusted( ctx.isTrusted());
e=ctx.getHostAliases();
while( e.hasMoreElements())
ctx1.addHostAlias( (String)e.nextElement());
BaseInterceptor ri[] =
cm.getContainer().getInterceptors(Container.H_copyContext);
int i;
for( i=0; i < ri.length; i++) {
ri[i].copyContext(request, ctx, ctx1);
}
cm.removeContext( ctx );
cm.addContext( ctx1 );
// put back saved local interceptors
e=sI.elements();
while(e.hasMoreElements()){
BaseInterceptor savedI=(BaseInterceptor)e.nextElement();
ctx1.addInterceptor(savedI);
savedI.setContext(ctx1);
savedI.reload(request,ctx1);
}
ctx1.init();
// remap the request
request.setAttribute("tomcat.ReloadInterceptor", this);
ri = cm.getContainer().getInterceptors(Container.H_contextMap);
for( i=0; i< ri.length; i++ ) {
if( ri[i]==this ) break;
int status=ri[i].contextMap( request );
if( status!=0 ) return status;
}
}
} else {
// This is the old ( buggy) behavior
// ctx.reload() has some fixes - it removes most of the
// user servlets, but still need work XXX.
// we also need to save context attributes.
Enumeration sE=ctx.getServletNames();
while( sE.hasMoreElements() ) {
try {
String sN=(String)sE.nextElement();
Handler sw=ctx.getServletByName( sN );
sw.reload();
} catch( Exception ex ) {
log( "Reload exception: " + ex);
}
}
// send notification to all interceptors
// They may try to save up the state or take
// the right actions
if( debug>0 ) log( "Reloading hooks for context " +
ctx.toString());
// Call reload hook in context manager
BaseInterceptor cI[]=ctx.getContainer().getInterceptors();
for( int i=0; i< cI.length; i++ ) {
cI[i].reload( request, ctx );
ctx.getContainer().setNote( "oldLoader", null);
}
}