Announcement Announcement Module
Collapse
No announcement yet.
Understanding BlazeDS and its integration into Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Understanding BlazeDS and its integration into Spring

    Hello,

    I just started using BlazeDS and want to integrate it with Spring framework.
    I managed to run an example but still don't understand how it works.

    Questions:
    1. RemoteObject on client side means that we use AMF?
    2. RemoteObject refers to Destination and channel (which is AMF again(?!) and URL). Does it mean we can have several Destinations on one URL? Can we have several Channels in Channel Set where not all Channels are AMF for RemoteObject?
    3. Server side defines Service which is composite of Destination, Adapter and Channel. Destination is Java class, Adapter is the way to access Java classes in general (please tell me if I am wrong). What does Service's class mean?
    4. And why do we need Channel declaration on server side? From official doc I understand that it is client's abstraction.
    5. I am using DispatchServlet from Spring to recieve requests. All requests are transferred to BlazeDS's MessageBroker because of <flex:message-broker/> tag. I'd like to declare BlazeDS's beans in Spring configuration using <flex:remoting-object/> tag. Can someone tell me how to do that using my classes? (I tried to do that but failed)

    Thanks a lot.

    Here is what I have:

    ---------------------
    excerpt from web.xml:

    <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:web-application-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>



    ----------------------
    web-application-context.xml for Spring

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:flex="http://www.springframework.org/schema/flex"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/flex
    http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">

    <flex:message-broker/>

    </beans>
    ----------------------
    service-config.xml:

    <services-config>
    <channels>
    <channel-definition id="amfChannel"
    class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://localhost:8180/server-1.0/messagebroker/amf"
    class="flex.messaging.endpoints.AMFEndpoint"/>
    </channel-definition>
    </channels>

    <services>
    <service id="mapService"
    class="flex.messaging.services.RemotingService">

    <adapters>
    <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.J avaAdapter" default="true"/>
    </adapters>

    <default-channels>
    <channel ref="amfChannel"/>
    </default-channels>

    <destination id="mapServiceDestination">
    <properties>
    <source>org.unihistory.server.frontend.blazeds.map .MapService</source>
    </properties>
    </destination>

    </service>

    </services>
    </services-config>

    ------------------------

    client code:

    <fx:Script><![CDATA[

    public function test():void {
    mapService.sayHello();
    }

    ]]></fx:Script>

    <s:layout>
    <s:BasicLayout/>
    </s:layout>

    <fxeclarations>
    <s:RemoteObject id="mapService" destination="mapServiceDestination">
    <s:channelSet>
    <s:ChannelSet id="uniset">
    <s:channels>
    <s:AMFChannel uri="http://localhost:8180/server-1.0/messagebroker/amf"/>
    </s:channels>
    </s:ChannelSet>
    </s:channelSet>
    </s:RemoteObject>

    </fxeclarations>

    <s:Button label="Say Hello" click="test()"/>

  • #2
    1. RemoteObject on client side means that we use AMF?
    The RemoteObject class gives you access to classes on a remote application server. And as far as i know RemoteObject end point is always AMFChannel (or SecureAMFChannel)

    2. RemoteObject refers to Destination and channel (which is AMF again(?!) and URL). Does it mean we can have several Destinations on one URL? Can we have several Channels in Channel Set where not all Channels are AMF for RemoteObject?
    All channels will be AMF. Same destination can be exposed to different channels

    3. Server side defines Service which is composite of Destination, Adapter and Channel. Destination is Java class, Adapter is the way to access Java classes in general (please tell me if I am wrong). What does Service's class mean?
    org.springframework.stereotype.Service java doc comments says,

    Indicates that an annotated class is a "Service" (e.g. a business service facade). This annotation serves as a specialization of {@link Component @Component}, allowing for implementation classes to be autodetected through classpath scanning.
    I think of this as the configuration in which we can specify the service name that can be referred from the flex client remote object (destination)

    4. And why do we need Channel declaration on server side? From official doc I understand that it is client's abstraction.
    To specify which channel should this destination use.

    5. I am using DispatchServlet from Spring to recieve requests. All requests are transferred to BlazeDS's MessageBroker because of <flex:message-broker/> tag. I'd like to declare BlazeDS's beans in Spring configuration using <flex:remoting-object/> tag. Can someone tell me how to do that using my classes? (I tried to do that but failed)
    There is no tag like this <flex:remoting-object/> in spring (as far as i know ). But if you don't like to do annotations on the java code (@Service, @RemoteDestination), you can always do this

    Code:
    <flex:message-destination id="SampleDestination" channels="my-amf" />
    Didn't try your code. is there any specific problems with the code?

    Comment


    • #3
      Your services-config.xml can be to following,

      Code:
      <services-config>
      <channels>
      <channel-definition id="amfChannel"
      class="mx.messaging.channels.AMFChannel">
      <endpoint url="http://localhost:8180/server-1.0/messagebroker/amf"
      class="flex.messaging.endpoints.AMFEndpoint"/>
      </channel-definition>
      </channels>
      </services-config>
      Your web-application-context.xml should have the remoting service tag and default channels

      Code:
      <flex:message-broker>
      	<flex:remoting-service default-channels="amfChannel" />
      </flex:message-broker>
      When you use spring-flex you don't need the blaze ds remoting-config.xml configurations.

      You can use xml configurations or annotations to define the remote service (destination)

      Comment

      Working...
      X