开发者

Flex + BlazeDS + Multi module maven project

开发者 https://www.devze.com 2023-03-02 02:24 出处:网络
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.

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() {}

    p开发者_StackOverflow社区ublic Double getCommonNumber() {
        return commonNumber;
    }
    public void setCommonNumber(Double commonNumber) {
        this.commonNumber= commonNumber;
    }
}


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号