Package org.forgerock.openig.filter
Class SwitchFilter
- java.lang.Object
-
- org.forgerock.openig.filter.SwitchFilter
-
- All Implemented Interfaces:
Filter
public class SwitchFilter extends Object implements Filter
Conditionally diverts the request to another handler. Before and after the request is handled, associated conditions are evaluated. If a condition evaluates totrue
, then the processing flow is diverted to the associated handler. If no condition evaluates totrue
, then the request flows normally through the filter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SwitchFilter.Heaplet
Creates and initializes an expect filter in a heap environment.
-
Constructor Summary
Constructors Constructor Description SwitchFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SwitchFilter
addRequestCase(Expression<Boolean> condition, Handler handler)
Add a request switch case with a condition and the handler to execute if condition yields.SwitchFilter
addResponseCase(Expression<Boolean> condition, Handler handler)
Add a response switch case with a condition and the handler to execute if condition yields.Promise<Response,NeverThrowsException>
filter(Context context, Request request, Handler next)
Filters the request and/or response of an exchange.
-
-
-
Method Detail
-
addRequestCase
public SwitchFilter addRequestCase(Expression<Boolean> condition, Handler handler)
Add a request switch case with a condition and the handler to execute if condition yields.- Parameters:
condition
- expression to evaluatehandler
- handler to be executed if the condition yields- Returns:
- this filter for fluent invocation.
-
addResponseCase
public SwitchFilter addResponseCase(Expression<Boolean> condition, Handler handler)
Add a response switch case with a condition and the handler to execute if condition yields.- Parameters:
condition
- expression to evaluatehandler
- handler to be executed if the condition yields- Returns:
- this filter for fluent invocation.
-
filter
public Promise<Response,NeverThrowsException> filter(Context context, Request request, Handler next)
Description copied from interface:Filter
Filters the request and/or response of an exchange. To pass the request to the next filter or handler in the chain, the filter callsnext.handle(context, request)
.This method may elect not to pass the request to the next filter or handler, and instead handle the request itself. It can achieve this by merely avoiding a call to
next.handle(context, request)
and creating its own response object. The filter is also at liberty to replace a response with another of its own by intercepting the response returned by the next handler.
-
-