You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "m.jimen.blazquez" <m....@gmail.com> on 2012/01/12 15:49:08 UTC
@Bean annotation in REST service definition
Hi,
I am managing a rest service with cxfrs camel component.
In the definition of my rest service, I would like to invoke a bean:
@POST
@Path("service/{service}/{version}/{operation}")
@Consumes("application/json")
@Produces("application/json")
public void people(@PathParam("service")String service,
@PathParam("version") String version,
@PathParam("operation") String operation,
*@Bean(ref = "routeHelper", method="getObject")* Object json) {
return null;
}
so that when I invoke the service, the content in the body (json) is
transformed into an object.
I have registered the bean in the context:
<bean id="routeHelper" class="myPackage.RouteHelper" />
The problem is that the routeHelper.getObject is never called. I have no
error in the execution, I obtain the body of the Exchange with the four
parameters as if the bold text has not been read.
¿Am I trying to do something is not permitted?
I have read in other post that cxfrs component unmarshalls the json but I
cannot find the way to manage this.
Kindest regards
--
View this message in context: http://camel.465427.n5.nabble.com/Bean-annotation-in-REST-service-definition-tp5140117p5140117.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: @Bean annotation in REST service definition
Posted by "m.jimen.blazquez" <m....@gmail.com>.
Sorry. I forgot my camel version.
The camel version is 2.9.0
--
View this message in context: http://camel.465427.n5.nabble.com/Bean-annotation-in-REST-service-definition-tp5140117p5140261.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: @Bean annotation in REST service definition
Posted by "m.jimen.blazquez" <m....@gmail.com>.
Hi,
simplifying my camel context is:
<camelContext id="camel-route"
xmlns="http://camel.apache.org/schema/spring">
<route>
<camel:from
uri="cxfrs:/exchange2?resourceClasses=thePackage.ExchangeServiceResource" />
<camel:log message="REQUEST RECEIVED" />
</route>
</camelContext>
I think that before the execution of the log message, the @Bean method in
the service rest definition must be executed, is this right?
kindest regards
--
View this message in context: http://camel.465427.n5.nabble.com/Bean-annotation-in-REST-service-definition-tp5140117p5140259.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: @Bean annotation in REST service definition
Posted by Hadrian Zbarcea <hz...@gmail.com>.
How does your camel context look like (or at least the relevant route).
What version of camel?
Hadrian
On 01/12/2012 09:49 AM, m.jimen.blazquez wrote:
> Hi,
>
> I am managing a rest service with cxfrs camel component.
>
> In the definition of my rest service, I would like to invoke a bean:
>
> @POST
> @Path("service/{service}/{version}/{operation}")
> @Consumes("application/json")
> @Produces("application/json")
> public void people(@PathParam("service")String service,
> @PathParam("version") String version,
> @PathParam("operation") String operation,
> *@Bean(ref = "routeHelper", method="getObject")* Object json) {
> return null;
> }
>
> so that when I invoke the service, the content in the body (json) is
> transformed into an object.
>
> I have registered the bean in the context:
>
> <bean id="routeHelper" class="myPackage.RouteHelper" />
>
> The problem is that the routeHelper.getObject is never called. I have no
> error in the execution, I obtain the body of the Exchange with the four
> parameters as if the bold text has not been read.
>
> ¿Am I trying to do something is not permitted?
>
> I have read in other post that cxfrs component unmarshalls the json but I
> cannot find the way to manage this.
>
> Kindest regards
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bean-annotation-in-REST-service-definition-tp5140117p5140117.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Hadrian Zbarcea
Principal Software Architect
Talend, Inc
http://coders.talend.com/
http://camelbot.blogspot.com/