Quantcast

@Bean annotation in REST service definition

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

@Bean annotation in REST service definition

m.jimen.blazquez
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: @Bean annotation in REST service definition

hadrian
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: @Bean annotation in REST service definition

m.jimen.blazquez
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: @Bean annotation in REST service definition

m.jimen.blazquez
Sorry. I forgot my camel version.

The camel version is 2.9.0

Loading...