In a recent project I had to dynamically create a Flex Remoting endpoint (Channels) at runtime in the embedded BlazeDS of ColdFusion (this was due to the fact that we did not wanted the customer to mess around with the services-config.xml file).
By default, the "ColdFusion" Remoting destination only uses a non-secure AMFChannel but we wanted to use the SecureAMFChannel on that destination as well. Usually, you'd need to edit the remoting-config.xml file, add the "my-cfamf-secure" channel to the list of channels for the "ColdFusion" destination and then restart the server. With runtime channel configuration, you can just add (or even remove) channels at runtime with no server restart. Actually, you can do anything you want as long as the BlazeDS API supports it.
In my case, I use the onApplicationStart methode of the Application.cfc to call the configureChannels method which will add the existing "my-cfamf-secure" channel to the "ColdFusion" endpoint in case it has not been done already:
<cffunction name="configureChannels" returntype="void" access="private">
<cfscript>
var cls = createObject("java", "flex.messaging.MessageBroker");
var broker = cls.getMessageBroker(javacast("null", ""));
var service = broker.getService("remoting-service");
if (service.getDefaultChannels().size() == 1)
{
service.addDefaultChannel("my-cfamf-secure");
}
destination = service.getDestination("ColdFusion");
if (destination.getChannels().size() == 1)
{
destination.addChannel("my-cfamf-secure");
}
</cfscript>
</cffunction>
That's it.
Dirk.
There are no comments for this entry.