Flex to Java Notes (1)
















The red-circled parts, aka, Java Remoting Service are what I am going to talk about.

  • BlazeDS server is contained in a J2EE web application. That's why we need web server to host it.
  • A Flex client makes a request over a channel and the request is routed to an endpoint on the BlazeDS server. From the endpoint, the request is routed through a chain of Java objects that includes the MessageBroker object, a service object, a destination object, and finally an adapter object. The adapter fulfills the request either locally, or by contacting a backend system or a remote server such as Java Message Service (JMS) server.
  • Channels are client-side objects that encapsulate the connection behavior between Flex components and the BlazeDS server. Channels communicate with corresponding endpoints on the BlazeDS server. You configure the properties of a channel and its corresponding endpoint in the services-config.xml file. 
  • <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
  •     <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
  • </channel-definition>
  • How exactly Flex components know how to connect to BlazeDS, using which channel?
  • Answer: you can use automatic way or manual way.
  • Automatic way: compile Flex component using -service option, check your "Flex Compiler", you should find something like -services "C:/flex_workspace/EZQ5Browser/WebContent/WEB-INF/flex/services-config.xml" -locale en_US
  • Manual way: 
  • <RemoteObject id="ro" destination="Dest">
  •     <mx:channelSet>
  •         <mx:ChannelSet>
  •             <mx:channels>
  •                 <mx:AMFChannel id="myAmf"
  •                     uri="http://myserver:2000/myapp/messagebroker/amf"/>
  •             </mx:channels>
  •         </mx:ChannelSet>
  •     </mx:channelSet>
  • </RemoteObject>
  • Destination to channels