camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: bean binding with inheritance & 2.0-M3 camel-http
Date Sat, 15 Aug 2009 15:15:46 GMT
Hi

Had a 2nd look and realized you need to use multipart/form instead to
upload files.

See example on ticket using curl with the -F option
https://issues.apache.org/activemq/browse/CAMEL-1913



On Sat, Aug 15, 2009 at 12:23 PM, Claus Ibsen<claus.ibsen@gmail.com> wrote:
> Hi
>
> I had a look and found a glitch. I have created a ticket to track it
> https://issues.apache.org/activemq/browse/CAMEL-1913
>
>
> On Fri, Aug 14, 2009 at 10:56 PM, jjb<jj_burford@yahoo.com> wrote:
>>
>> Hi
>>
>> My example does use the POST method to send the data by virtue of using the
>> --post-file option to wget.  From the wget man page:
>>
>>       --post-data=string
>>       --post-file=file
>>           Use POST as the method for all HTTP requests and send the
>> specified data in the request body.  "--post-data" sends string as data,
>> whereas
>>           "--post-file" sends the contents of file.  Other than that, they
>> work in exactly the same way.
>>
>> So my wget example does indeed use POST.  As I said, this used to work in
>> Camel 2.0-M2.  Am I missing something?  Would you like me to provide an
>> example or are you able to test this using what I have mentioned so far?  If
>> this works for you (using wget --post-file) with the latest SNAPSHOT then
>> maybe you can show me what you are doing in your camel-context and bean
>> method.
>>
>> Regards
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> You should use POST to send data. GET is only for like query
>>> parameters and the body is expected to be empty using GET.
>>> As opposed to POST where the posted data is in the body.
>>>
>>>
>>>
>>>
>>> On Thu, Aug 13, 2009 at 9:36 PM, jjb<jj_burford@yahoo.com> wrote:
>>>>
>>>> FYI, I use the following wget command to test this:
>>>>
>>>> wget --post-file=ftm_request.xml --output-document=-
>>>> http://localhost:8080/ftm/
>>>>
>>>> Where the ftm_request.xml file has the following contents (which I want
>>>> to
>>>> get as a String in my HttpProcessor.process method):
>>>>
>>>> <ftm_request>
>>>>        <ftm_ping_request type="0" repid="12345678"/>
>>>> </ftm_request>
>>>>
>>>>
>>>> Regards
>>>>
>>>>
>>>> jjb wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I got a new SNAPSHOT release today but still am unable to get the body
>>>>> of
>>>>> an HTTP request as a string.  Here's an example of my setup:
>>>>>
>>>>>
>>>>> From camel-context.xml:
>>>>>
>>>>> <!-- from Spring bean declaration portion -->
>>>>>     <bean id="http_processor" class="HttpProcessor"/>
>>>>>
>>>>> <!-- from Camel context portion -->
>>>>>     <route>
>>>>>       <from uri="jetty:http://0.0.0.0:8080/ftm/?sessionSupport=true"/>
>>>>>       <to uri="bean:http_processor"/>
>>>>>     </route>
>>>>>
>>>>>
>>>>> From HttpProcessor.java:
>>>>>
>>>>>         public void process(Exchange exchange)
>>>>>       {
>>>>>              String body =
>>>>> (String)exchange.getIn().getBody(String.class);
>>>>>              System.out.println("HTTP PROCESSOR GOT BODY " + body);
>>>>>         }
>>>>>
>>>>>
>>>>> I get an empty String for the body portion.  Is there another way to get
>>>>> the HTTP body as a String or is this just broken in the latest SNAPSHOT
>>>>> (this used to work in 2.0-M2)?
>>>>>
>>>>> Regards
>>>>>
>>>>>
>>>>> jjb wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> So I got the latest SNAPSHOT and the bean binding issue as well as the
>>>>>> camel-http getResponse issue have been fixed.  Thank you so much for
>>>>>> that.  The last issue I am currently stuck on is the following code:
>>>>>>
>>>>>> String body = exchange.getIn().getBody(Sting.class);
>>>>>>
>>>>>> I still get an empty String back from this.
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>>
>>>>>>> On Fri, Aug 7, 2009 at 2:40 AM, jjb<jj_burford@yahoo.com> wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> I have another question regarding how to obtain the body of the HTTP
>>>>>>>> message.  Before the latest SNAPSHOT (in 2.0-M2), I used to be able
>>>>>>>> to
>>>>>>>> do
>>>>>>>> this:
>>>>>>>>
>>>>>>>> String body = (String)exchange.getIn().getBody((new
>>>>>>>> String()).getClass());
>>>>>>>>
>>>>>>>> This now gives me an empty String.  Do you know how I can get the
>>>>>>>> body
>>>>>>>> of an
>>>>>>>> HTTP post now?
>>>>>>>
>>>>>>> String body = exchange.getIn().getBody(Sting.class);
>>>>>>> should work.
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Regards
>>>>>>>>
>>>>>>>>
>>>>>>>> jjb wrote:
>>>>>>>>>
>>>>>>>>> Hi, Claus.
>>>>>>>>>
>>>>>>>>> I was hoping to get the latest SNAPSHOT with the
>>>>>>>>> HttpMessage.getResponse
>>>>>>>>> method implemented.  I just updated from the SNAPSHOT repo and
>>>>>>>>> verified
>>>>>>>>> it's not there yet:
>>>>>>>>>
>>>>>>>>> stealth: wget --no-check-certificate
>>>>>>>>> https://repository.apache.org/content/repositories/snapshots//org/apache/camel/camel-http/2.0-SNAPSHOT/camel-http-2.0-SNAPSHOT.jar
>>>>>>>>> --2009-08-06 15:28:08--
>>>>>>>>> https://repository.apache.org/content/repositories/snapshots//org/apache/camel/camel-http/2.0-SNAPSHOT/camel-http-2.0-SNAPSHOT.jar
>>>>>>>>> Resolving repository.apache.org... 140.211.11.100
>>>>>>>>> Connecting to repository.apache.org|140.211.11.100|:443...
>>>>>>>>> connected.
>>>>>>>>> WARNING: cannot verify repository.apache.org's certificate, issued
>>>>>>>>> by
>>>>>>>>> `/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com,
>>>>>>>>> Inc./OU=http://certificates.godaddy.com/repository/CN=Go Daddy
>>>>>>>>> Secure
>>>>>>>>> Certification Authority/serialNumber=07969287':
>>>>>>>>>   Self-signed certificate encountered.
>>>>>>>>> HTTP request sent, awaiting response... 200 OK
>>>>>>>>> Length: 42721 (42K) [text/plain]
>>>>>>>>> Saving to: `camel-http-2.0-SNAPSHOT.jar'
>>>>>>>>>
>>>>>>>>> 100%[=================================================================================================================================================>]
>>>>>>>>> 42,721      73.7K/s   in 0.6s
>>>>>>>>>
>>>>>>>>> 2009-08-06 15:28:09 (73.7 KB/s) - `camel-http-2.0-SNAPSHOT.jar'
>>>>>>>>> saved
>>>>>>>>> [42721/42721]
>>>>>>>>>
>>>>>>>>> stealth: javap -classpath camel-http-2.0-SNAPSHOT.jar
>>>>>>>>> org.apache.camel.component.http.HttpMessage
>>>>>>>>> Compiled from "HttpMessage.java"
>>>>>>>>> public class org.apache.camel.component.http.HttpMessage extends
>>>>>>>>> org.apache.camel.impl.DefaultMessage{
>>>>>>>>>     public
>>>>>>>>> org.apache.camel.component.http.HttpMessage(org.apache.camel.Exchange,
>>>>>>>>> javax.servlet.http.HttpServletRequest);
>>>>>>>>>     public javax.servlet.http.HttpServletRequest getRequest();
>>>>>>>>>     protected java.lang.Object createBody();
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> stealth:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Do you know when it might make it into the repo?
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> Also the bean method name issue has been fixed in trunk.
>>>>>>>>>> So if possible please test it at your side by building from source
>>>>>>>>>> or
>>>>>>>>>> try SNAPSHOT when a new build is published to apache maven repos.
>>>>>>>>>>
>>>>>>>>>> On Wed, Aug 5, 2009 at 1:55 PM, Claus Ibsen<claus.ibsen@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>> Hi
>>>>>>>>>>>
>>>>>>>>>>> Okay I am committing a fix in short time.
>>>>>>>>>>>
>>>>>>>>>>> You can grab it using 2 ways
>>>>>>>>>>> - from the body using the camel type converter, to avoid ugly java
>>>>>>>>>>> type
>>>>>>>>>>> casts
>>>>>>>>>>> - using java type cast to cast the message to HttpMessage
>>>>>>>>>>>
>>>>>>>>>>>            // we have access to the HttpServletRequest here and we
>>>>>>>>>>> can grab it if we need it
>>>>>>>>>>>            HttpServletRequest req =
>>>>>>>>>>> exchange.getIn().getBody(HttpServletRequest.class);
>>>>>>>>>>>            assertNotNull(req);
>>>>>>>>>>>
>>>>>>>>>>>            // we have access to the HttpServletResponse here and
>>>>>>>>>>> we
>>>>>>>>>>> can grab it if we need it
>>>>>>>>>>>            HttpServletResponse res =
>>>>>>>>>>> exchange.getIn().getBody(HttpServletResponse.class);
>>>>>>>>>>>            assertNotNull(res);
>>>>>>>>>>>
>>>>>>>>>>>            // and they should also be on HttpMessage
>>>>>>>>>>>            HttpMessage msg = (HttpMessage) exchange.getIn();
>>>>>>>>>>>            assertNotNull(msg.getRequest());
>>>>>>>>>>>            assertNotNull(msg.getResponse());
>>>>>>>>>>>
>>>>>>>>>>> And use the output stream to write to the servlet response
>>>>>>>>>>>
>>>>>>>>>>>            // and we can use servlet response to write to output
>>>>>>>>>>> stream
>>>>>>>>>>> also
>>>>>>>>>>>            res.getOutputStream().print("Written by servlet
>>>>>>>>>>> response");
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Wed, Aug 5, 2009 at 10:55 AM, Claus
>>>>>>>>>>> Ibsen<claus.ibsen@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>> Hi
>>>>>>>>>>>>
>>>>>>>>>>>> Cool I have added a ticket to get it back
>>>>>>>>>>>> https://issues.apache.org/activemq/browse/CAMEL-1879
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Wed, Aug 5, 2009 at 10:52 AM, jjb<jj_burford@yahoo.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi, Claus.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I built a framework to receive status related messages from a
>>>>>>>>>>>>> topic as
>>>>>>>>>>>>> the
>>>>>>>>>>>>> route is traversed.  Consider the routes the define DerivedClass
>>>>>>>>>>>>> -> A
>>>>>>>>>>>>> -> B
>>>>>>>>>>>>> -> C.  As each segment in the route executes, it sends JAXB/XML
>>>>>>>>>>>>> messages to
>>>>>>>>>>>>> a topic that are then forwarded back to the client via a
>>>>>>>>>>>>> callback.
>>>>>>>>>>>>>  As
>>>>>>>>>>>>> the
>>>>>>>>>>>>> DerivedClass receives these messages, it sends them back over
>>>>>>>>>>>>> the
>>>>>>>>>>>>> HTTP
>>>>>>>>>>>>> socket (via the HttpServletResponse) to the invoking web client.
>>>>>>>>>>>>>  This
>>>>>>>>>>>>> gives
>>>>>>>>>>>>> the web client a realtime flow of XML status updates while the
>>>>>>>>>>>>> different
>>>>>>>>>>>>> endpoints are traversed.  Since I do not want DerivedClass to
>>>>>>>>>>>>> know
>>>>>>>>>>>>> about
>>>>>>>>>>>>> Camel or JMS, there is a class which DerivedClass submits a
>>>>>>>>>>>>> request to
>>>>>>>>>>>>> (manager instance below) that also listens on this topic for
>>>>>>>>>>>>> related
>>>>>>>>>>>>> status
>>>>>>>>>>>>> messages.  These I get via callback and write them to the web
>>>>>>>>>>>>> client
>>>>>>>>>>>>> accordingly:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> public interface Client
>>>>>>>>>>>>> {
>>>>>>>>>>>>>    public void notify(String status);
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> public DerivedClass implements Client
>>>>>>>>>>>>> {
>>>>>>>>>>>>>    HttpServletResponse response;
>>>>>>>>>>>>>
>>>>>>>>>>>>>    public void process(Exchange exchange)
>>>>>>>>>>>>>    {
>>>>>>>>>>>>>        HttpServletResponse response = ....;   // need to know
>>>>>>>>>>>>> how
>>>>>>>>>>>>> to
>>>>>>>>>>>>> get
>>>>>>>>>>>>> this
>>>>>>>>>>>>>        String request = "MY XML REQUEST";   // this is actually
>>>>>>>>>>>>> a
>>>>>>>>>>>>> JAXB
>>>>>>>>>>>>> serialized object
>>>>>>>>>>>>>
>>>>>>>>>>>>>        // submit XML request to class which listens on topic and
>>>>>>>>>>>>> calls
>>>>>>>>>>>>> notify with stuff for us
>>>>>>>>>>>>>        manager.submit(request, this);
>>>>>>>>>>>>>    }
>>>>>>>>>>>>>
>>>>>>>>>>>>>    // we get our stuff from the manager object which listens on
>>>>>>>>>>>>> a
>>>>>>>>>>>>> topic and
>>>>>>>>>>>>> correlates status
>>>>>>>>>>>>>    // messages and calls this notify method
>>>>>>>>>>>>>    public notify(String status)
>>>>>>>>>>>>>    {
>>>>>>>>>>>>>         response.getWriter().println(status);
>>>>>>>>>>>>>    }
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> I was hoping 2.0-M3 Camel would allow access to
>>>>>>>>>>>>> HttpServletRequest
>>>>>>>>>>>>> as
>>>>>>>>>>>>> before
>>>>>>>>>>>>> 2.0-M3 so I can make my own synchronous writes to the HTTP
>>>>>>>>>>>>> client
>>>>>>>>>>>>> from
>>>>>>>>>>>>> DerivedClass with no dependence on Camel.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>
>>>>>>>>>>>>> response.getWriter().println(statusStr)
>>>>>>>>>>>>>
>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Ah the response may be missing on the HttpMessage.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> What do you need it for?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Wed, Aug 5, 2009 at 9:51 AM, jjb<jj_burford@yahoo.com>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 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<jj_burford@yahoo.com>
>>>>>>>>>>>>>>>> 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<jj_burford@yahoo.com>
>>>>>>>>>>>>>>>>>> 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<jj_burford@yahoo.com>
>>>>>>>>>>>>>>>>>>>> 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.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> 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-tp24802648p24823165.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
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Claus Ibsen
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>
>>>>>>>>>>> Open Source Integration: http://fusesource.com
>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>> Twitter: http://twitter.com/davsclaus
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> 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-tp24802648p24856990.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-tp24802648p24957352.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-tp24802648p24978424.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
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message