Tie

Java Method Interception

Cook Book

Applying mutiple rules

Problem

You want to test for a number of different conditions before applying an interceptor.

Solution 1

Write your own class that implements InterceptionRule. Perform as many tests as necessary to verify the necessary conditions.

Solution 2

Use InterceptionBuilder.whenBoth(...), or InterceptionBuilder.whenEither(...), to setup the rules you need for your interceptor.

Solution 3

Use the necessary combinations of AndRule, OrRule and NotRule to build a logic expression that meets your needs.