cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aki Yoshida <elak...@googlemail.com>
Subject best practice for setting order constraints among interceptors
Date Tue, 16 Aug 2011 16:51:19 GMT
Hi,
If you have two interceptors A and B that go into the same phase and
additionally you want to make sure A must precede B, you can either
write
addBefore(B) in A's constructor
or
addAfter(A) in B's constructor.

But is there a good rule for deciding which one to choose?

The concrete case that I have is for LoggingOutInterceptor and
TransformOutInterceptor.
They both go into PRE_STREAM..

LoggingOI should wrap the output stream before anyone start using it,
so it must precede any Stax based interceptors. That means we have the
order:
LoggingOI < TransformOI < StaxOI

Initially, I added this constraint in the constructor of TransformOI
as I was fixing another issue of this class.
addBefore(StaxOI)
addAfter(LoggingOI).

But later I thought, it might have been more readable to put this
constraint in the LoggingOI as
addBefore(StaxOI)
addBefore(TransformOI).
to indicate LoggingOI must precede any known Stax based interceptors.

Maybe, this is a stupid question. But if someone has a strong opinion
in one way or the other. I am interested in hearing it.

Thanks.

regards, aki

Mime
View raw message