For the add case, installing a feature that then installs the interceptor may 
work for you (extends AbstractFeature).  If its something you want to do based 
on a message property, the other way is to have an interceptor that adds an 
interceptor.  A number of the CXF interceptors do this for "ending" phases 
where they need to do some cleanup.

The remove is a bit trickier, since you'd need to keep track of the Client 
instance it was installed on to remove it.  Its certainly possible but you also 
may have to worry about synchronization since the list from the Client is 
copied each time a new message is started, so if you have an active client you 
may get ConcurrentModificationException from other threads trying to use the 
client while you are removing the interceptor.
________________________________________
From: webber [[email protected]]
Sent: Friday, July 06, 2012 8:44 AM
To: [email protected]
Subject: Adding a conditional interceptor (or removing one based on a condition)

Hi,

I have a couple of interceptors on my client(jaxws:client) which are added
using spring config (jaxws:inInterceptors). I would like one of these
interceptors to be added based on a propery setting.

The only option I could get to work was using the property setting in the
interceptor's handleMessage and decide whether or not to perform the
required interceptor logic. So basically, when the condition is false, it
always go to the handleMessage and does nothing.

I assume the above solution is not ideal. Is there anyway I can control this
properly, by
a) Not adding the interceptor in the first place based on that propery (not
sure if there is if/else condition in spring config)
b) If we do have to add the interceptor in spring config, is there a way to
obtain it and remove it later on from else where based on a property

Thanks

--
View this message in context: 
http://cxf.547215.n5.nabble.com/Adding-a-conditional-interceptor-or-removing-one-based-on-a-condition-tp5710686.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to