Hi, Claus.
Thank you so much for looking into the issue. My last request has to do
with how to obtain a reference to the HttpServletResponse in the new (>=
2.0-M3) Camel API. I can get the HttpServletRequest as you suggested (using
HttpMessage), but how do I obtain a reference to the HttpServletResponse
from a method with is the "to" endpoint of a camel-jetty "from" route that
takes an Exchange parameter as so:
public void process(Exchange exchange)
{
HttpMessage in = (HttpMessag) exchange.getIn();
HttpServletRequest = in.getRequest();
// how do I get to the HttpServletResponse which used to be accessed <
2.0-M3
// like this: HttpServletResponse response =
((HttpExchange)exchange).getResponse();
}
Regards
Claus Ibsen-2 wrote:
>
> Hi
>
> Thanks for the sample. I can reproduce the issue.
>
> The issue is that your base class implements the
> javax.jms.MessageListener.
> I will dig into why Camel prefers to invoke this method over the
> method name specified.
>
>
> On Tue, Aug 4, 2009 at 8:02 PM, jjb<[email protected]> wrote:
>>
>> Hi.
>>
>> Attached is an example which recreates the bean issue. My goal is to
>> create
>> a framework which localizes JMS/ActiveMQ and Camel stuff to one package.
>> Then none of our business logic depends on it (it just passes POJOs
>> around
>> that are created from XSD using JAXB). This is why I can't put the
>> @Handler
>> annotation in the DerivedClass.
>> http://www.nabble.com/file/p24813432/camel_bug.tgz camel_bug.tgz
>>
>> About the 2.0-M3 Camel interface for HttpServletResponse - how do I get
>> it
>> from the Exchange?
>>
>> Thanks!
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Tue, Aug 4, 2009 at 9:26 AM, jjb<[email protected]> wrote:
>>>>
>>>> Hi.
>>>>
>>>> Thanks for the quick response. I switched to 2.0-M3 and still had the
>>>> problem - the BaseClass.onMessage still gets called. Is there a newer
>>>> release or something I can check out that might have this fix? Also,
>>>> when I
>>>> use 2.0-M3, how do I get the HttpServletResponse (your suggestion to
>>>> get
>>>> the
>>>> HttpServletRequest worked for me - thanks)?
>>>>
>>>> Regards
>>>
>>> Hi
>>>
>>> About the bean problem. Could you create a ticket for it and attach a
>>> small sample with the issue?
>>>
>>> You can use the @Handler annotation to mark the method that Camel
>>> should use and then avoid using the ?method=xxxx.
>>> But I am interested in fixing why method=xxx does not work for you.
>>>
>>> See more here
>>> http://camel.apache.org/bean-binding.html
>>>
>>>
>>>>
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> On Tue, Aug 4, 2009 at 7:52 AM, jjb<[email protected]> wrote:
>>>>>>
>>>>>> I have a hierarchy of objects which looks like this:
>>>>>>
>>>>>> public BaseClass implements javax.jms.MessageListener
>>>>>> {
>>>>>> public void onMessage(javax.jms.Message message)
>>>>>> {
>>>>>> // do something
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> public DerivedClass extends BaseClass
>>>>>> {
>>>>>> public void process(String body)
>>>>>> {
>>>>>> // do something
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> I then have the following XML in my camel-context.xml:
>>>>>>
>>>>>> <bean id="processor" class="DerivedClass"/>
>>>>>>
>>>>>> <route>
>>>>>> <from uri="activemq:request.queue"/>
>>>>>> <to uri="bean:processor?method=process"/>
>>>>>> </route>
>>>>>>
>>>>>> When I run this code, all messages from request.queue always go to
>>>>>> BaseClass.onMessage, even though I explicitly want them to go to
>>>>>> DerivedClass.process. Have I done something wrong or is this a bug
>>>>>> (I
>>>>>> read
>>>>>> through the bean binding and it said it would first use methods that
>>>>>> were
>>>>>> explicitly specified in the bean's method parameter)?
>>>>>>
>>>>>
>>>>> We have fixed a bug in this relation in 2.0.x (cant remember the
>>>>> version, might be the 2.0m3).
>>>>>
>>>>> In older versions you can work around this by adding an @Body
>>>>> annotation to your base class
>>>>> public void process(@Body String body)
>>>>> And Camel should prefer to use this method.
>>>>>
>>>>>
>>>>>
>>>>>> I also notice that the new 2.0-M3 version of camel-http no longer
>>>>>> contains
>>>>>> the class org.apache.camel.component.http.HttpExchange. Therefore,
>>>>>> this
>>>>>> code no longer compiles:
>>>>>>
>>>>>> public void process(Exchange exchange)
>>>>>> {
>>>>>> try
>>>>>> {
>>>>>> HttpServletResponse response =
>>>>>> ((HttpExchange)exchange).getResponse();
>>>>>> HttpServletRequest request =
>>>>>> ((HttpExchange)exchange).getRequest();
>>>>>> HttpSession session = null;
>>>>>> if (request != null)
>>>>>> session = request.getSession(true);
>>>>>> }
>>>>>> catch (Exception e)
>>>>>> { e.printStackTrace(); }
>>>>>> }
>>>>>>
>>>>>> Is there a new way to get the HttpServletResponse and such from the
>>>>>> Exchange
>>>>>> parameter?
>>>>>
>>>>> Its on the HttpMessage instead.
>>>>>
>>>>> HttpMessage in = (HttpMessag) exchange.getIn();
>>>>> HttpServletRequest = in.getRequest();
>>>>>
>>>>>
>>>>>>
>>>>>> Regards
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24802648.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Claus Ibsen
>>>>> Apache Camel Committer
>>>>>
>>>>> Open Source Integration: http://fusesource.com
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>> Twitter: http://twitter.com/davsclaus
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24803535.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24813432.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
>
--
View this message in context:
http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24822320.html
Sent from the Camel - Users mailing list archive at Nabble.com.