Jax-rs convert to object Mule - mule

I am using RAML for design api.
Then I convert raml to jaxrs and get java classes (https://github.com/mulesoft-labs/raml-for-jax-rs ).
It gives two classes: interface and *impl classes.
Then I Import them into my project In Anypoint Studio. I want to use them.
But JsonToObject Transfer cannot use convert classes.
org.mule.api.transformer.TransformerMessagingException: Failed to transform from "json" to "classImpl".
I try use without interface classes. It work correct.
How to use interface and *impl Classes for convert json to Object?

I solved the problem. 1. RAML need to convert using jackson 2. In Anypoint need to deserialize from the json to the object by ObjectMapper

You should make sure your classImp support JSON binding using Jackson annotations. See the related Mule documentation on JSON Support for details.

Related

Registering KryoSerializer to Hazelcast

I created a serializer for a specific object using the com.esotericsoftware.kryo.Serializer (extending from it and passing my generic parameter).
Now i want to put my object into a com.hazelcast.map.IMap by setting the value type to my custom object.
My question is, how do i tell my com.hazelcast.core.HazelcastInstance that it should use my custom kryo serializer for serialization of the object?
I am also using https://github.com/jerrinot/subzero in my project.
Follow the documentation here for Kryo, JSON or other customer serializers to use with Hazelcast: https://docs.hazelcast.org/docs/4.1.1/manual/html-single/index.html#custom-serialization

Kotlin Data Classes support in Protobuf

I am implementing protobuf recently in our kotlin project.
I am receiving the binary data and deserialising it to Proto object using the proto file.
But I would like have that converted to data class.
I could not find any supporting information about how to do this.
Is it possible to get data class from binary data or from deserialized proto object??
One solution might be to use pb-and-k which has the kotlin code generator and will generate data classes for you based off of the .proto files
If you have know the structure of the data and can write your data classes upfront, you might want to have a look at kotlinx.serialization. It is an official Kotlin project and supports protobuf out-of-the-box.

wsimport generate files including Jackson annotations

How can I use wsimport (or any other tool that provides similar funcionality for that matter) to generate the required files to talk to a JAX-WS webservice, but not only have it add JAXB annotation to the request/response classes, but also add Jackson annotations?
In the big picture, I do not want to duplicate, I want to reuse the generated classes for a REST service. If the above is not possible, is there any other way that saves me from duplicating everything?
As mentioned in a comment, Jackson has a JAXB Annotations module, that can use JAXB annotated classes beside / instead of standard Jackson annotated ones...
See: https://github.com/FasterXML/jackson-module-jaxb-annotations

Mule DataMapper MEL custom functions or calling custom transformer

I have a question relating to the DataMapper component and extending the behaviour. I have a scenario where I'm converting one payload to another using the DataMapper. Some of the elements in my source request as strings (i.e. Male, Female) and these values need to be mapped to ID elements, known as enums in the target system. A DBLookup will suffice but because of the structure of enums (a.k.a lookup tables) in the target system I'd need to define multiple DBLookups for the values which need to be changed. So I'm looking to develop a more generic way of performing the mapping. I've two proposals, which I'm currently exploring
1) Use the invokeTransformer default function in to call a custom transformer. i.e.
output.gender = invokeTransformer("EnumTransformer",input.gender);
However, even though my transformer is defined in my flow
<custom-transformer name="EnumTransformer" class="com.abc.mule.EnumTransformer" />
Running a Preview in the DataMapper fails with the following error (in Studio Error Log)
Caused by: java.lang.IllegalArgumentException: Invalid transformer name 'EnumTransformer'
at com.mulesoft.datamapper.transform.function.InvokeTransformerFunction.call(InvokeTransformerFunction.java:35)
at org.mule.el.mvel.MVELFunctionAdaptor.call(MVELFunctionAdaptor.java:38)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1011)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:987)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:377)
... 18 more
As the transformer is scoped to my flow and the datamapper is outside this scope do I assume it is now possible to invoke a custom transformer in a datamapper? Or do I require additional setup.
2) The alternative approach would be to use "global function". I've found he documentation in this area to be quiet weak. The functionality is referenced in the the cheat sheet and there is a [jira](
https://www.mulesoft.org/jira/browse/MULE-6438) to improve the documentation.
Again perhaps this functionality suffers from a scope issue. Questions on this approach is if anyone can provide a HOWTO on calling some JAVA code via MEL from a data mapper script? This blog suggests data mapper MEL can call JAVA but limits it's example to string functions. Is there any example of calling a custom JAVA class / static method?
In general I'm questioning if I am approaching this wrong? Should I use a Flow Ref and call a JAVA component?
Update
It is perfectly acceptable to use a custom transformer from the data mapper component. The issue I was encountering was a Mule Studio issue. Preview of a data mapping which contains a transformer does not work because the mule registry is not populated on the mule context as mule is not running.
In terms of the general approach now that I have realized the DB Lookup can accept multiple input parameters I can use this to address my mapping scenario.
Thanks
Rich
Try by providing complete class name

vb.net parsing json

How can I parse json from such as twitter etc in vb.net applications.
Use the DataContractJsonSerializer class of the System.Runtime.Serialization.Json namespace. You can use it's ReadObject method to deserialize the JSON stream.
You can use the JSon.Net library. I've never used it from VB.net but I assume it's CLS-compliant and it should work OK.