{
Pipeline pipeline = manager.getContainer().getPipeline();
// Clean out any existing request handler
Valve[] valves = pipeline.getValves();
RequestHandlerValve mockValve = null;
for (Valve valve: valves)
{
if (valve instanceof RequestHandlerValve)
{
mockValve = (RequestHandlerValve) valve;
break;
}
}
if (mockValve == null)
{
mockValve = new RequestHandlerValve(requestHandler);
pipeline.addValve(mockValve);
}
else
{
mockValve.setRequestHandler(requestHandler);
}
return pipeline.getFirst();
}