Sunday, April 04, 2010

Configuring a default application-wide channel set in Spring BlazeDS

The Spring BlazeDS Integration project provides a very elegant framework for Flex-Java development. However the project documentation (as of 1.0.3) encourages the decoupling of the BlazeDS channel configuration in the client from the channel config in the server. While in many cases this is the right thing to do, in other cases developers may prefer to define the configuration in one place (in services-config.xml) and compile the client(s) against service-config. Developers using the joint Java-Flex project support in Flash Builder, for example, (provided under the hood by Eclipse WTP) will find this approach convenient, especially in the early stages as they are learning the framework.

Unfortunately neither the Spring BlazeDS Integration documentation (as of 1.0.3) nor Adobe's LCDS documentation (as of 3.0) provides an example of how to define an application-wide default channel set in services-config.xml.

You can define a default application-wide channel in service-config.xml as follows:-



With an application-wide default channel set in services-config you can define mx:RemoteObjects, mx:Producers and mc:Consumers in the client as follows without having to specify a channel configuration explicitly. (This assumes the client is compiled against service-config.xml which has been the default in Flex/Flash Builder for projects set up with BlazeDS support since WTP support was introduced in v2.0.1).



and also allows a simpler Spring config as follows:-



Additionally BlazeDS remoting endpoints annotated as Spring BlazeDS endpoints work too without having to specify a channel explicitly as follows:



While it may not always be the right thing to do, configuring an application-wide default channel set in service-config and compiling the client against services-config significantly reduces the complexity of the Spring BlazeDS config in the simple case.

1 comment:

Unknown said...

Thanks Graeme Harker,
I was stuck with an issue of Destination not found with new integration of Spring Blaze DS but your post has helped by saying that we need to add annotations to the service classes.
Once again Thanks.

Regards,
Lalit.D.S.
Software Engineer.