I have a restlet in which i want to chain a validator and filter one after the other in the code. The code goes something like this
@Override
public synchronized Restlet createInboundRoot()
{
Router router = new Router();
Validator val = new ParameterValidator(getContext());
Filter fil = new MYFilter(getContext());
router.attach("/HelloWorld", HW.class);
fil.setNext(val);
val.setNext(router);
val.validate("Name",true,"^[a-z0-9A-Z]+$");
return val;
}
but this doesn't checks in the filter, just works on the validator and then comes out.
But if i write this same code as given below, it works fine,
@Override
public synchronized Restlet createInboundRoot()
{
Router router = new Router();
Validator val = new ParameterValidator(getContext());
Filter fil = new MYFilter(getContext());
router.attach("/HelloWorld", fil);
fil.setNext(val);
val.setNext(HW.class);
val.validate("Name",true,"^[a-z0-9A-Z]+$");
return router;
}
The above code works fine but now in case i have to create a chain i'll have to create new objects of Validator and Filter with every new mapping. Any solution will be appreciated