jeudi 20 novembre 2008

Flex: using multiple remoting-config.xml file with BlaseDS

Recently, I worked on a Java / Flex project using BlaseDS and I was quite surprised to discover It was not easy to split remote object definitions on separate configuration files. Every remoting object has to be listed in a single configuration file located in "/WEB-INF/flex/remoting-config.xml".

This is really not convenient in cases where remote objects come from different dev teams or third party librairies. I would expect BlaseDS to discover at runtime its remoting configuration.

So I wrote a simple BlaseDS service that discover any "META-INF/remoting-confg.xml" file in the classpath and register any declared remote object with the remoting service. I basically created a new Flex service that inherits from 'flex.messaging.services.AbstractBootstrapService'.

The simplified procedure is :
  1. look up remoting service from broker.
  2. list any existing 'META-INF/remoting-config.xml' file.
  3. parse config files and create destinations (using 'flex.messaging.services.Service.createDestination(String)').
  4. register created destination with flex remoting service (using 'flex.messaging.services.Service.addDestination(String)').
Unfortunately I had to write my own SAXHandler to parse configuration file. I would have preffered to reuse code but I was unable to find a simple way to parse only a subset of configuration files.

You can download implementation.

1 commentaire:

Thierry a dit…

Bonjour Jérôme,

J'ai besoin de ton aide pour ton script "export MySQL to XML" qui fonctionne bien, mais où j'aimerai inscrire les résultat directement dans un fichier xml.

Merci de me contacter : thierry@raetzer.ch

Salutations cordiales