数的ActionScript / Flex的ArrayCollection的对象以Java集合<龙>使用BlazeDS的 [英] ActionScript/Flex ArrayCollection of Number objects to Java Collection<Long> using BlazeDS

查看:361
本文介绍了数的ActionScript / Flex的ArrayCollection的对象以Java集合<龙>使用BlazeDS的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Flex 3,使通过的RemoteObject调用一个Java 1.6的方法和BlazeDS的和Spring过的SecureAMFChannel 2.5.5集成暴露。该动作如下(此code是真实的东西它是一个独立开发的网络上的一个例子);

I am using Flex 3 and make a call through a RemoteObject to a Java 1.6 method and exposed with BlazeDS and Spring 2.5.5 Integration over a SecureAMFChannel. The ActionScript is as follows (this code is an example of the real thing which is on a separate dev network);

import com.adobe.cairngorm.business.ServiceLocator;
import mx.collections.ArrayCollection;
import mx.rpc.remoting.RemoteObject;
import mx.rpc.IResponder;

public class MyClass implements IResponder
{

    private var service:RemoteObject = ServiceLocator.getInstance().getRemoteOjbect("mySerivce");

    public MyClass()
    {
        [ArrayElementType("Number")]
        private var myArray:ArrayCollection;

        var id1:Number = 1;
        var id2:Number = 2;
        var id3:Number = 3;

        myArray = new ArrayCollection([id1, id2, id3]);

        getData(myArray);

    }

    public function getData(myArrayParam:ArrayCollection):void
    {
        var token:AsyncToken = service.getData(myArrayParam);
        token.addResponder(this.responder); //Assume responder implementation method exists and works
    }

}

这将拨打电话,一旦产生,对它是通过BlazeDS的暴露(假设机制工作,因为他们不涉及收集参数所有其他呼叫一样)服务的Java类。我的Java服务类看起来是这样的;

This will make a call, once created to the service Java class which is exposed through BlazeDS (assume the mechanics work because they do for all other calls not involving Collection parameters). My Java service class looks like this;

public class MySerivce {
    public Collection<DataObjectPOJO> getData(Collection<Long> myArrayParam) {
        //The following line is never executed and throws an exception
        for (Long l : myArrayParam) {
            System.out.println(l);
        }
    }

}

这是引发的异常是一个ClassCastException说,一个java.lang.Integer中不能被强制转换为java.lang.Long的。我通过收集循环使用对象而不是,检查,看它是否是一个整数,将其转换为一个,那么做一个.longValue()就可以了,然后将其添加到一个临时ArraList努力解决此问题。育。

The exception that is thrown is a ClassCastException saying that a java.lang.Integer cannot be cast to a java.lang.Long. I worked around this issue by looping through the collection using Object instead, checking to see if it is an Integer, cast it to one, then do a .longValue() on it then add it to a temp ArraList. Yuk.

最大的问题是我的应用程序应该处理数十亿从数据库记录的ID将溢出2.147十亿限制的整数。我很想有BlazeDS的或JavaAdapter的它,在方法中指定翻译的ActionScript数为Long。我恨,即使我用的是收藏的通用基础元素类型是一个整数。如果这是笔直的Java,它不会编译。

The big problem is my application is supposed to handle records in the billions from a DB and the id will overflow the 2.147 billion limit of an integer. I would love to have BlazeDS or the JavaAdapter in it, translate the ActionScript Number to a Long as specified in the method. I hate that even though I use the generic the underlying element type of the collection is an Integer. If this was straight Java, it wouldn't compile.

任何想法是AP preciated。解决方案是更好! :)

Any ideas are appreciated. Solutions are even better! :)

推荐答案

请阅读有关您的问题下面的线程。你可以找到有一些解决方法。

Please read the following threads related to your issue. You can find there some workarounds.

https://bugs.adobe.com/jira/browse/BLZ-115

https://bugs.adobe.com/jira/browse/BLZ-305

这篇关于数的ActionScript / Flex的ArrayCollection的对象以Java集合&LT;龙&GT;使用BlazeDS的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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