开发者

How does one create Channels at runtime using BlazeDS?

开发者 https://www.devze.com 2023-01-11 21:07 出处:网络
So as you may or may not know, BlazeDS (open source version of LiveCycle Data Services) is a nice way to get your server-side Java and client-side Flex application to play together.Unfortunately, it d

So as you may or may not know, BlazeDS (open source version of LiveCycle Data Services) is a nice way to get your server-side Java and client-side Flex application to play together. Unfortunately, it does have several pitfalls that need to be corrected. I'll try to explain one of them here.

All of BlazeDS's configuration is written via XML files in the flex/ folder of your webapp. The default names are separated for clarity, such as services-config.xml, remoting-config.xml, messaging-config.xml, etc. In these configuration files (particularly services-config.xml), Channels are defined; these setup URIs and objects used to capture and send information between the server and the client. In these config files, it is quite common to use a syntax like so:

    <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
        <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
        <properties>
            <add-no-cache-headers>false</add-no-cache-headers>
        </properties>
    </channel-definition>

Unfortunately, what they don't tell you is that some of these key-i开发者_JAVA技巧n replacements (ie: {context.root}) are not replaced dynamically upon execution but upon compilation of the WAR file you intend to distribute. Obviously not a good idea when switching domains.

So, instead I seek to dynamically define these channels. According to the documentation, that's all good and fine, but it only works if the channel already exists when the webapp is launched. I feel like that sort of defeats the point.

So my question is, how do you truly create channels dynamically so that both the client and the server recognize their existence?


Read this blog post; I believe it is what you're after.

I believe these xml config files have no direct relation to the server at all. They are used to tell the SWF how to find the server.

During Compile time of your Flex App; the services-config information is, in essence, hard coded into the SWF.

0

精彩评论

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