<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>blog.onepixeloff - modelglue</title>
			<link>http://blog.onepixeloff.com/index.cfm</link>
			<description>One Pixel Off Incorporated&apos;s group blog. Detailing our adventures in development</description>
			<language>en-us</language>
			<pubDate>Sun, 05 Sep 2010 16:05:32 -0400</pubDate>
			<lastBuildDate>Thu, 27 Jul 2006 12:39:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>clayton@onepixeloff.com</managingEditor>
			<webMaster>clayton@onepixeloff.com</webMaster>
			
			
			
			
			
			<item>
				<title>Flash Remoting with ModelGlue2</title>
				<link>http://blog.onepixeloff.com/index.cfm/2006/7/27/Flash-Remoting-with-ModelGlue2</link>
				<description>
				
				I was wondering if anyone has figured out a better way to expose a cfc for Flash Remoting or as a webservice when using MG:2 than the way I have been doing it. I know it&apos;s possible to to just target a cfc directly but I want to have Coldspring configure of the cfc I&apos;m targeting as have the ability to use Reactor within it.

Coldspring actully has a very cool ability to create a facade of a bean for use for flash remoting. The tricky part was getting this to work with Coldspring and Reactor as part of MG:2.

Here is the way I did it:

The Coldspring documentation describes how you can create a remoting facade for a bean configured in Coldsrping, so in my Coldspring.xml file I use something like this:

&lt;pre&gt;
&amp;lt;bean id=&quot;myRemoting&quot; class=&quot;mg2test.model.remoting.myRemoting&quot; autowire=&quot;byName&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;br/&gt;
&amp;lt;bean id=&quot;myRemoting_Facade&quot; class=&quot;coldspring.aop.framework.RemoteFactoryBean&quot;&amp;gt;&lt;br/&gt;
	&amp;lt;property name=&quot;target&quot;&amp;gt;&lt;br/&gt;	
		&amp;lt;ref bean=&quot;myRemoting&quot; /&amp;gt;&lt;br/&gt;
	&amp;lt;/property&amp;gt;&lt;br/&gt;
	&amp;lt;property name=&quot;serviceName&quot;&amp;gt;&lt;br/&gt;
		&amp;lt;value&amp;gt;myRemotingService&amp;lt;/value&amp;gt;&lt;br/&gt;
	&amp;lt;/property&amp;gt;&lt;br/&gt;
	&amp;lt;property name=&quot;relativePath&quot;&amp;gt;&lt;br/&gt;
		&amp;lt;value&amp;gt;mg2test/remotefacades/&amp;lt;/value&amp;gt;&lt;br/&gt;
	&amp;lt;/property&amp;gt;&lt;br/&gt;
	&amp;lt;property name=&quot;remoteMethodNames&quot;&amp;gt;&lt;br/&gt;
		&amp;lt;value&amp;gt;get*&amp;lt;/value&amp;gt;&lt;br/&gt;
	&amp;lt;/property&amp;gt;&lt;br/&gt;
&amp;lt;/bean&amp;gt;&lt;br/&gt; 
&lt;/pre&gt;

Then I can just (but not quite) target mg2test.remotefacades.myRemotingService with my remoting calls.

There are a couple of additional things I had to set up before this would work though.

1. You have to call getBean on the bean factory for myRemoting_Facade before Coldspring will create the mg2test.remotefacades.myRemotingService cfc for you. I do this by having a setmyRemoting_Facade method in on of my model-glue controllers, and because of autowiring it is created automatically. Also it makes the the facade available in my MG controller.

2. The cfc  generated by Coldspring &quot;myRemotingService&quot; won&apos;t be able to find a reference to the coldspring bean factory unless it is an a scope that it can access. By default it looks for it at application[&quot;coldspring.beanfactory.root&quot;]. I got arround this by adding the following to the end of my project&apos;s index.cfm:

&lt;pre&gt;
&amp;lt;cfif StructKeyExists(_modelglue, &quot;beanFactory&quot;)&amp;gt;&lt;br/&gt;
	&amp;lt;cflock name=&quot;setUpForRemoting&quot; type=&quot;exclusive&quot; timeout=&quot;10&quot; throwOnTimeout=&quot;true&quot;&amp;gt;&lt;br/&gt;
		&amp;lt;cfset application[&quot;coldspring.beanfactory.root&quot;] = &lt;br/&gt;
			application[ModelGlue_APP_KEY].framework.GetBeanFactory()&amp;gt;&lt;br/&gt;
		&amp;lt;cfset application.reactor = &lt;br/&gt;
			application[ModelGlue_APP_KEY].framework.GETORMSERVICE()&amp;gt;&lt;br/&gt;
	&amp;lt;/cflock&amp;gt;&lt;br/&gt;
&amp;lt;/cfif&amp;gt;&lt;br/&gt;
&lt;/pre&gt;

I also put a reference to reactor in the application scope for easy access from within myRemoting.cfc. Both application scope references should be reset if model-glue is forced to reload (the mg2test/remotefacades/myRemotingService.cfc should be recreated too for that matter).

3. With steps 1 and 2 you won&apos;t be able to make a request directly to mg2test.remotefacades.myRemotingService until at least one regular MG request has been made.

This set up seems to work pretty well and I haven&apos;t found anything on the interweb yet describing another way of doing this with MG:2.

I wonder though, is there anyway this could be improved or simplified?
Or is there a completely different way that this could be done that is far simpler?
				
				</description>
						
				
				<category>coldfusion</category>				
				
				<category>modelglue</category>				
				
				<pubDate>Thu, 27 Jul 2006 12:39:00 -0400</pubDate>
				<guid>http://blog.onepixeloff.com/index.cfm/2006/7/27/Flash-Remoting-with-ModelGlue2</guid>
				
			</item>
			
		 	
			</channel></rss>