How to make BlazeDS ignore properties?

I have a java class that has one field with getter and setter, and a second pair of getter and setter that access this field differently:

public class NullAbleId { private static final int NULL_ID = -1; private int internalId; getter & setter for internalId public Integer getId() { if(this.internalId == NULL_ID) { return null; } else { return Integer.valueOf(internalId); } } public void setId(Integer id) { if (id == null) { this.internalId = NULL_ID; } else { this.internalId = id.intValue(); } } } 

(the reason for this design is that I want to create a method for passing Nullable Intergers )

On the client side of Flash / Flex, I have a class with two properties: id and internalId (id properties are for testing only, in the end they should return internalId)

BlazeDS are seams for passing both values: id and internalId, because both have a complete getter mesh pair. I want Blaze not to pass an identifier, only internalId should be passed. But I donโ€™t know how to set it up for me.

+4
source share
3 answers

In addition to transient / marshaller, you can implement the Externalizable interface and create your own serialization.

See serialization rules

+1
source

All the rules for serializing BlazeDS are here:

http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=serialize_data_3.html

Here is a quote: "Fields that are static, temporary, or non-public, and bean properties that are non-public or static, are excluded."

So, if you can make your identifier suitable for this criterion, it will be excluded. Another option would be to create a custom serializer that does not explicitly include your id property.

All the best

~ Harris

+3
source

It may be a little old, but it may help some: there is a good ticket for ex properties from Java to Flex through BlazeDS

EDIT: better salted, use @AmfIgnore (or @AmfIgnoreField if your serialization is right in the fields), the annotation contained in spring-flex-core.jar (I used 1.5 0.2 release)

0
source

Source: https://habr.com/ru/post/1339188/


All Articles