You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by rkiesler <rk...@slimail.com> on 2009/04/10 21:52:10 UTC

Can cxf-bc and cxf-se interceptors share context?

I am trying to pass some information captured in a cxf-bc consumer
interceptor onto a cxf-se endpoint interceptor, but am not able to find any
common context -- the interceptor execute on separate threads (so no
ThreadLocal stuff), the Message object is different, as is the Exchange and
DeliveryChannel objects.

Is there some kind of a context object where we can set properties on the bc
side and retrieve them on the se side?

Thanks,
--
Roy
-- 
View this message in context: http://www.nabble.com/Can-cxf-bc-and-cxf-se-interceptors-share-context--tp22993688p22993688.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Can cxf-bc and cxf-se interceptors share context?

Posted by Freeman Fang <fr...@gmail.com>.
rkiesler wrote:
> Freeman,
>
> Thanks for this -- I am now able to add a property to the NormalizedMessage
> in my cxf-bc interceptor.
>
> On the cxf-se side, which phase should I use to get the NormalizedMessage? I
> tried RECEIVE and PRE_INVOKE, but message.getContent(MessageExchange.class)
> returns null in both phases.
>   
RECEIVE is ok
use message.get(MessageExchange.class);  but not 
message.getContent(MessageExchange.class)
Example as below
public class ExtractPropertyInterceptor extends
AbstractPhaseInterceptor<Message> {
   
   
    public ExtractPropertyInterceptor() {
        super(Phase.RECEIVE);
    }
   
    public void handleMessage(Message message) {
       
        MessageExchange exchange = message.get(MessageExchange.class);
        NormalizedMessage norMessage =
            (NormalizedMessage) exchange.getMessage("in");
        //then you can get the properties you saved before from the
NorMessage
       
    }

   
}
> Thanks again,
>
> --
>
> Roy
>
>
> Freeman Fang wrote:
>   
>> Roy,
>> Change your phase to PRE_INVOKE, and use code like
>> MessageExchange exchange = message
>>                     .getContent(MessageExchange.class);
>> //use exchange here to get NormalizedMessage
>> Freeman
>>
>>     


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com


Re: Can cxf-bc and cxf-se interceptors share context?

Posted by rkiesler <rk...@slimail.com>.
Freeman,

Thanks for this -- I am now able to add a property to the NormalizedMessage
in my cxf-bc interceptor.

On the cxf-se side, which phase should I use to get the NormalizedMessage? I
tried RECEIVE and PRE_INVOKE, but message.getContent(MessageExchange.class)
returns null in both phases.

Thanks again,

--

Roy


Freeman Fang wrote:
> 
> Roy,
> Change your phase to PRE_INVOKE, and use code like
> MessageExchange exchange = message
>                     .getContent(MessageExchange.class);
> //use exchange here to get NormalizedMessage
> Freeman
> 
-- 
View this message in context: http://www.nabble.com/Can-cxf-bc-and-cxf-se-interceptors-share-context--tp22993688p23045854.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Can cxf-bc and cxf-se interceptors share context?

Posted by Freeman Fang <fr...@gmail.com>.
Roy,
Change your phase to PRE_INVOKE, and use code like
MessageExchange exchange = message
                    .getContent(MessageExchange.class);
//use exchange here to get NormalizedMessage
Freeman

rkiesler wrote:
> Freeman,
>
> My cxf-bc interceptor is set on the RECEIVE phase, and the following
> statements throws a ClassCastException:
>
>
> NormalizedMessage norMsg = (NormalizedMessage)exchange.getInMessage();
>
> Looking at the debugger, exchange.getInMessage() returns a
> org.apache.cxf.message.MessageImpl, which does not implement the
> NormalizedMessage JBI interface.
>
> Is there a different phase I should use this interceptor in to get a
> NormalizedMessage from the exchange?
>
> Thanks,
>
> --
>
> Roy
>
>
> Freeman Fang wrote:
>   
>> Hi,
>> You can set properties to the NormalizedMessage on cxf bc and retrieve 
>> it from cxf se.
>> Take a look at [1] where we already have discussed this issue, you may 
>> need write  interceptor to set/retrieve property yourself
>> [1]http://cwiki.apache.org/SM/discussion-forums.html#nabble-td22581230%7Ca22581230
>>
>> Freeman
>>
>> rkiesler wrote:
>>     
>>> I am trying to pass some information captured in a cxf-bc consumer
>>> interceptor onto a cxf-se endpoint interceptor, but am not able to find
>>> any
>>> common context -- the interceptor execute on separate threads (so no
>>> ThreadLocal stuff), the Message object is different, as is the Exchange
>>> and
>>> DeliveryChannel objects.
>>>
>>> Is there some kind of a context object where we can set properties on the
>>> bc
>>> side and retrieve them on the se side?
>>>
>>> Thanks,
>>> --
>>> Roy
>>>   
>>>       
>> -- 
>> Freeman Fang
>> ------------------------
>> Open Source SOA: http://fusesource.com
>>
>>
>>
>>     
>
>   


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com


Re: Can cxf-bc and cxf-se interceptors share context?

Posted by rkiesler <rk...@slimail.com>.
Freeman,

My cxf-bc interceptor is set on the RECEIVE phase, and the following
statements throws a ClassCastException:


NormalizedMessage norMsg = (NormalizedMessage)exchange.getInMessage();

Looking at the debugger, exchange.getInMessage() returns a
org.apache.cxf.message.MessageImpl, which does not implement the
NormalizedMessage JBI interface.

Is there a different phase I should use this interceptor in to get a
NormalizedMessage from the exchange?

Thanks,

--

Roy


Freeman Fang wrote:
> 
> Hi,
> You can set properties to the NormalizedMessage on cxf bc and retrieve 
> it from cxf se.
> Take a look at [1] where we already have discussed this issue, you may 
> need write  interceptor to set/retrieve property yourself
> [1]http://cwiki.apache.org/SM/discussion-forums.html#nabble-td22581230%7Ca22581230
> 
> Freeman
> 
> rkiesler wrote:
>> I am trying to pass some information captured in a cxf-bc consumer
>> interceptor onto a cxf-se endpoint interceptor, but am not able to find
>> any
>> common context -- the interceptor execute on separate threads (so no
>> ThreadLocal stuff), the Message object is different, as is the Exchange
>> and
>> DeliveryChannel objects.
>>
>> Is there some kind of a context object where we can set properties on the
>> bc
>> side and retrieve them on the se side?
>>
>> Thanks,
>> --
>> Roy
>>   
> 
> 
> -- 
> Freeman Fang
> ------------------------
> Open Source SOA: http://fusesource.com
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Can-cxf-bc-and-cxf-se-interceptors-share-context--tp22993688p23024517.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Can cxf-bc and cxf-se interceptors share context?

Posted by Freeman Fang <fr...@gmail.com>.
Hi,
You can set properties to the NormalizedMessage on cxf bc and retrieve 
it from cxf se.
Take a look at [1] where we already have discussed this issue, you may 
need write  interceptor to set/retrieve property yourself
[1]http://cwiki.apache.org/SM/discussion-forums.html#nabble-td22581230%7Ca22581230

Freeman

rkiesler wrote:
> I am trying to pass some information captured in a cxf-bc consumer
> interceptor onto a cxf-se endpoint interceptor, but am not able to find any
> common context -- the interceptor execute on separate threads (so no
> ThreadLocal stuff), the Message object is different, as is the Exchange and
> DeliveryChannel objects.
>
> Is there some kind of a context object where we can set properties on the bc
> side and retrieve them on the se side?
>
> Thanks,
> --
> Roy
>   


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com