Package org.forgerock.openig.filter
Class SwitchFilter
java.lang.Object
org.forgerock.openig.filter.SwitchFilter
- All Implemented Interfaces:
Filter
Conditionally diverts the request to another handler. Before and after the request is
handled, associated conditions are evaluated. If a condition evaluates to
true
, then
the processing flow is diverted to the associated handler. If no condition evaluates to
true
, then the request flows normally through the filter.
Typical behaviours:
- If a request case yields, only that handler's case is invoked (no next nor response case)
- If no request case yields, then next handler will be invoked, and maybe a response case will handle it too
- If neither request nor response case yield, only the next handler is invoked
This filter preserves the filtered request for the response binding.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Creates and initializes a switch filter in a heap environment. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddRequestCase
(Expression<Boolean> condition, Handler handler) Add a request switch case with a condition and the handler to execute if condition yields.addResponseCase
(Expression<Boolean> condition, Handler handler) Add a response switch case with a condition and the handler to execute if condition yields.Filters the request and/or response of an exchange.
-
Constructor Details
-
SwitchFilter
public SwitchFilter()
-
-
Method Details
-
addRequestCase
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
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.
-