Monday 15 August 2011

@Function Annotation in Mule -


I want to use comment in the code @ function {/ code>]. I only know about it

But I can not get good results.

I created a new project, added a Java component, created a new class and copied this code

But I have many errors, I think I have to configure other things but I do not know Neither how do I use the @function And I can.

You need to manually declare an annotation parser in your configuration, so that the annotation is processed Can go

Consider this POJO:

  package com.acme; Import org.mule.api.annotations.expression.XPath; Import org.mule.api.annotations.expressions.Function; Import org.w3c.dom.Document; Public class annotated PO {public expedition (@expath ("/ envelope") final document document, @ function ("uide") last string id) {return "envelope text:" + Doctor.gate document element (). GetTextContent () + "- ID:" + ID; }}   

You can use it with this mule configuration:

  & lt; Spring: Bean class = "org.mule.config.endpoint.RegistryBackedAnnotationsParserFactory" / & gt; & Lt; Flow name = "test annotated pozzo" & gt; & Lt; Http: inbound-endpoint address = "http: // localhost: 8080 / pozzo" exchange-pattern = "request-response" /> & Lt; Component class = "com.acme.AnnotatedPojo" /> & Lt; / Flow & gt; Example call:  
  $ curl -H "content-type: app / xml" http: // localhost: 8080 / pojo -d '&' Lt; Envelope & gt; Foo & lt; / Envelope & gt; 'Envelope text: foo - id: 9133fc7d-a07f-11e2-b560-4d5f883736c4    

No comments:

Post a Comment