It is imperative that we understand the key concepts of interceptors before we proceed with writing one. Interceptors in Fuji are, in theory, based on the Aspect Oriented Programming(AOP) technique. They allow you to apply advice at a set of point cuts. The following key elements define interceptors in Fuji :
Interceptors are injected onto the message path and can intercept the Messages being exchanged on that path or the entire Message Exchange. So, interceptors can intercept the :
Each of the above is the advised object in terms of AOP. Let's go over each of these in detail.
Intercepting the Message Exchange
This gives the interceptor the most flexibility in altering the course of the message flow and it's content. An interceptor which intercepts a message exchange can
The updates need to be made within the limits of the Message Exchange Pattern.
The message exchange interceptor can short the message exchange, for example a interceptor intercepting the message exchange on the "in" message path, can set the "out" message on the exchange and short it ( we will see in the examples section how a exchange is "shorted"). When the message exchange is shorted this way, the message exchange is marked as "DONE" and sent back to the sender.
Intercepting the Message
Either the "in" or "out" message in the exchange can be intercepted. An interceptor that intercepts a message can
Intercepting the Message Payload
Either the "in" or "out" message in the exchange can be intercepted. An interceptor that intercepts a message can
"current message" refers to the message being exchanged on the message path when the interceptor is invoked.
The Message (Exchange) is intercepted when it is being sent on the delivery channel i.e. when the consumer/provider creates/updates the exchange and puts it onto the delivery channel. The senders thread of execution is used to invoke the interceptors. If an interceptor fails ( throws an exception ), the message exchange is terminated and sent back to the sender.
Interception point is equivalent to a join point in AOP.
Comparing this to AOP, interception scope is equivalent to point cuts.
. More then one interceptor can be in scope at the interception point, each of these is fired based on their priority. Priority is a user defined property of interceptors and can be specified in the Intercept Annotation