BlazeDS - 从 ArrayList的转换在 Java 端到 Actionscript
所以我们有一个带有两个泛型 ArrayList 的 java 类。看起来
public class Blah
{
public ArrayList<ConcreteClass> a;
public ArrayList<BaseClass> b;
}
通过在actionscript类中使用[ArrayElementType('ConcreteClass')],我们能够很好地转换所有的“a”。然而,对于“b”,由于实际的类是 BaseClassImplementation1、BaseClassImplementation2 等类的异构组合,因此它被键入为对象。假设客户端存在强类型 AS 版本的 java 类,有没有办法将其转换为特定的具体类,
谢谢您的帮助! 瑞吉斯
So we have a java class with two ArrayLists of generics. It looks like
public class Blah
{
public ArrayList<ConcreteClass> a;
public ArrayList<BaseClass> b;
}
by using [ArrayElementType('ConcreteClass')] in the actionscript class, we are able to get all the "a"s converted fine. However with "b", since the actual class coming across the line is a heterogeneous mix of classes like BaseClassImplementation1, BaseClassImplementation2 etc, it gets typed as an object. Is there a way to convert it to the specific concrete class assuming that a strongly typed AS version of the java class exists on the client side
thanks for your help!
Regis
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了确保所有 DTO 类都跨 AS 和 Java 进行编组,您需要使用指向 java 类定义的“RemoteClass”属性,将每个远程类定义为 AS 中的“远程类”,如下所示 [RemoteClass(alias= “com.myco.class”)]。
BlazeDS 将在类被序列化/反序列化时对其执行内省,并对其进行适当的转换(请参阅下面的文档)。类如何打包或嵌套在数组中并不重要,只要可以内省它就应该可以工作。
如果您需要对某个类进行特殊序列化,您可以通过扩展“AbastractProxy”并在启动时使用 PropertyProxyRegistry 注册方法将它们加载到 blazeds 中来创建自己的序列化代理(称为 beanproxy)。
您可以在 Blaze 开发人员指南 http://livedocs.adobe.com/ 中找到大部分内容blazeds/1/blazeds_devguide/。
创建您自己的 beanproxy 类请查看此处://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/io/BeanProxy.html
To ensure that all of your DTO classes are marshalled across AS and Java, you need to define each remote class as a "remote class" in AS by using the "RemoteClass" attribute pointing to the java class definition like this [RemoteClass(alias="com.myco.class")].
BlazeDS will perform introspection on the class as it is being serialized/de-serialized and convert it appropriately (see doc below). It doesn't matter how the classes are packed or nested in an array, as long as it can be introspected it should work.
If you need special serialization for a class you can create your own serialization proxys (called beanproxy) by extending "AbastractProxy" and loading them into blazeds using the PropertyProxyRegistry register method on startup.
You will find most of this in the Blaze developers guide http://livedocs.adobe.com/blazeds/1/blazeds_devguide/.
Creating your own beanproxy class look here: //livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/io/BeanProxy.html