You can use below code to tell if the messsage is from client.
Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))
On Fri Sep 30 17:40:10 2011, Gerald Preissler wrote:
I'm implementing an interceptor for CXF and am looking for a way to
programmatically determine where the interceptor is actually being
called during processing, i.e. I want to know whether the interceptor is
being run on the client or the service side and in the outgoing or
incoming interceptor chain. Outgoing or incoming chain is easy:
message.get(MESSAGE_INFO_KEY).getType() returns Type.INPUT or Type.OUTPUT
To determine if I am on the client or service side I came up with
something like this (pseudocode):
((type == Type.INPUT)&& (message ==
message.getExchange().getOutMessage())) => Client / Request
((type == Type.INPUT)&& (message ==
message.getExchange().getInMessage())) => Provider / Request
((type == Type.OUTPUT)&& (message ==
message.getExchange().getOutMessage())) => Provider / Response
((type == Type.OUTPUT)&& (message ==
message.getExchange().getInMessage())) => Client / Response
Did I get this right? Is there maybe a more elegant way to handle this?
Thanks in advance for any hints.
Best regards
Jerry
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang