弹性+ BlazeDS +多模块maven项目
我有一个多模块 Maven 项目(大约 10 个模块),其中 2 个模块是 Flex 项目及其相应的服务器项目,通过 BlazeDS 进行通信。
服务器模块依赖于另一个包含公共内容的模块,并在整个项目中共享。当使用公共模块中的对象时,对象不会被序列化并通过 AMF 发送到 SWF。服务器模块中的所有内容都已序列化并且工作正常,但公共模块中的对象(在服务器端具有有效值)不会发送到客户端。
我正在使用 Flexmojos 来构建这个。我需要做什么才能使公共项目中的类可用于序列化,并能够将它们用作我的 swf 项目中的 RemoteClass 对象?
基本结构与此类似(我尝试过简化一下):
swf-module (Flex):
Class MyObject.as:
package swf.model {
[RemoteClass(alias="server.model.MyObject")]
public class MyObject {
public var name:String;
public var common:MyCommonObject;
}
}
Class MyCommonObject.as:
package swf.model {
[RemoteClass(alias="common.model.MyCommonObject")]
public class MyCommonObject {
public var commonNumber:Number; }
}
server-module (Java):
Class MyObject.java:
package server.model;
import common.model.MyCommonObject;
public class MyObject {
private String name;
private MyCommonObject common;
public MyObject() {}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public MyCommonObject getCommon() {
return common;
}
public void setCommon(MyCommonObject common) {
this.common= common;
}
}
common -模块(Java)
类MyCommonObject.java:
package common.model;
public class MyCommonObject{
private Double commonNumber;
public MyCommonObject() {}
public Double getCommonNumber() {
return commonNumber;
}
public void setCommonNumber(Double commonNumber) {
this.commonNumber= commonNumber;
}
}
I've got a multi module Maven project (about 10 modules) where 2 of the modules are a flex project and its corresponding server project, communicating via BlazeDS.
The server module is dependent on another module containing common things, shared over the whole project. When using objects from the common module, the objects aren't serialized and sent via AMF to the SWF. Everything in the server-module is serialized and is working fine, but the objects from the common module (which has valid values on the server side) is not sent to the client.
I'm using Flexmojos to build this. What do I have to do to make the classes in the common project available for serialization, and being able to use them as RemoteClass-objects in my swf-project?
The basic structure is similar to this (I've tried so simplify it quite a bit):
swf-module (Flex):
Class MyObject.as:
package swf.model {
[RemoteClass(alias="server.model.MyObject")]
public class MyObject {
public var name:String;
public var common:MyCommonObject;
}
}
Class MyCommonObject.as:
package swf.model {
[RemoteClass(alias="common.model.MyCommonObject")]
public class MyCommonObject {
public var commonNumber:Number; }
}
server-module (Java):
Class MyObject.java:
package server.model;
import common.model.MyCommonObject;
public class MyObject {
private String name;
private MyCommonObject common;
public MyObject() {}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public MyCommonObject getCommon() {
return common;
}
public void setCommon(MyCommonObject common) {
this.common= common;
}
}
common-module (Java)
Class MyCommonObject.java:
package common.model;
public class MyCommonObject{
private Double commonNumber;
public MyCommonObject() {}
public Double getCommonNumber() {
return commonNumber;
}
public void setCommonNumber(Double commonNumber) {
this.commonNumber= commonNumber;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Java 服务器端 DTO 和 ActionScript 客户端 DTO 是独立的。我的意思是以下内容。当您的 BlazeDS 服务返回 AMF 序列化的 DTO 时,它们的二进制结构由 AMF 格式描述。 AMF 传输数据包含您在客户端使用
RemoteClass
元数据描述的完整类路径。这样客户端Flex项目和Java服务器项目在构建过程中就不会相互依赖。但是您可以将它们构建在一起以生成包含客户端和服务器部分的相同 WAR。Java server side DTOs and ActionScript client DTOs are independent. I mean the following. When your BlazeDS services return AMF-serialized DTOs their binary structure is described by AMF format. And AMF transfer data contains full classpath which you describe on a client side using
RemoteClass
metadata. In this way client Flex project and Java server project haven't dependencies on each other in process of building. But you can build them together to produce the same WAR which contains both client and server part.我实际上不得不这样做,你可以到这里,获取 BlazeDS 的源代码,将其添加到您的项目中并根据您的喜好进行调试。
I have actually had to do this, you can go here, get the source for BlazeDS, add it to your project and debug to your heart's content.
我认为你的公共模块 JAR 不在 Flex 模块/WAR/BlazeDS 的类路径中,
尝试将公共模块 JAR 放在 Flex 模块 war 中
表示部署时将 {common module}.jar 放入 {BlazeDS}\WEB-INF\lib\(
如果不存在)。
希望它有效
I Think your common-module JAR is not in classpath of Flex module/WAR/BlazeDS,
try to put common module JAR in Flex modules war
means PUT {common module}.jar in {BlazeDS}\WEB-INF\lib\ on deployment
if its not there.
Hopes it works