如何让BlazeDS忽略属性? [英] How to make BlazeDS ignore properties?

查看:239
本文介绍了如何让BlazeDS忽略属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个java类,它有一个getter和setter字段,第二对getter和setter用另一种方式访问​​这个字段:

  public class NullAbleId {
private static final int NULL_ID = -1;
private int internalId;

getter& setInt内部
$ b $公共整数getId(){
如果(this.internalId == NULL_ID){
返回null;
} else {
return Integer.valueOf(internalId);


$ b public void setId(Integer id){
if(id == null){
this.internalId = NULL_ID;
} else {
this.internalId = id.intValue();



$ b code


这种结构的原因是,我想建立一个

BlazeDS接口传递两个值:id和internalId,因为它们都有一个完整的getter setter对。我希望Blaze不要传输id,只有internalId应该被转移。但是我不知道如何配置它。

解决方案

除了transient / marshaller,你可以实现Externalizable界面,并创建自定义序列化。



请参阅序列化规则


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

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 construction is that I want to build a way to hande Nullable Intergers)

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

BlazeDS seams to transfer both values: id and internalId, because both have a complete getter setter pair. I want Blaze not to transfer id, only internalId should be transferred. But I have no idea how I have to configure that.

解决方案

Besides transient / marshaller you can implement the Externalizable interface and create your custom serialization.

See serialization rules

这篇关于如何让BlazeDS忽略属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆