<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fusioncube &#187; cfml</title>
	<atom:link href="http://www.fusioncube.net/index.php/category/development/languages/cfml/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fusioncube.net</link>
	<description>The online journey of a technophile, by Steve Brownlee</description>
	<lastBuildDate>Wed, 01 Feb 2012 04:17:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ColdFusion to Flex Object Type Conversion via ColdSpring</title>
		<link>http://www.fusioncube.net/index.php/coldfusion-flex-object-conversion</link>
		<comments>http://www.fusioncube.net/index.php/coldfusion-flex-object-conversion#comments</comments>
		<pubDate>Thu, 02 Oct 2008 19:26:04 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=250</guid>
		<description><![CDATA[This article covers using the ColdSpring AOP feature to automatically convert ColdFusion queries to an array of value objects for consumption in Flex.  Using value objects (a.k.a. transfer objects) ensure proper data type conversion when passing data from ColdFusion to Flex.]]></description>
			<content:encoded><![CDATA[<h2>The Value Objects</h2>
<p>Otherwise known as a transfer object is simply a design pattern for exchanging data between disparate systems.  I&#8217;m working on a application with a Flex UI and a ColdFusion backend, and I initially discovered that if I return a query directly to Flex, it is converted into an ArrayCollection populated with simple Objects.</p>
<p>What I wanted was an array of specifically typed objects that I could cast as value objects in Flex.  Here&#8217;s a very simplistic example of an Employee value object in Flex. It has two properties:</p>
<ul>
<li>Employee ID</li>
<li>Employee Name</li>
</ul>
<h3>Flex Employee Value Object</h3>
<pre class="code"><code>package net.fusioncube.transferObjects
{
   [RemoteClass(alias="net.fusioncube.model.employee.Employee")]
   [Bindable]
   public class Employee
   {
      private var _employeeID:uint;
      private var _employeeName:String;

      /* constructor */
      public function Effort(employee_id:uint = 0,
                  employee_name:String = "")
      {
         this._employeeID= employee_id;
         this._employeeName= employee_name;
      }

        public function get employee_id():uint
        {
        	return _employeeID;
        }

        public function set employee_id(value:uint):void
        {
        	if(value != 0) _employeeID= value;
        }

        public function get employee_name():String
        {
        	return _employeeName;
        }

        public function set employee_name(value:String):void
        {
        	if(value != "") _employeeName= value;
        }
   }
}</code></pre>
<p>You may have noticed the <strong>RemoteClass</strong> metadata applied to the Actionscript class.  What this does is ensure that this Flex class maps directly to a ColdFusion component value object.  To make a ColdFusion component value object is simple: you use the &lt;cfproperty&gt; tag for each property and specify each one&#8217;s type.</p>
<p>In this example, I&#8217;ve also added an init() method, whose use we&#8217;ll discover later.</p>
<h3>ColdFusion Employee Value Object</h3>
<pre class="code"><code>&lt;cfcomponent displayname="Employee" output="false"&gt;
   &lt;cfproperty name="employee_id" type="numeric" default="" /&gt;
   &lt;cfproperty name="employee_name" type="string" default="" /&gt;

   &lt;cffunction name="init" access="public" returntype="net.fusioncube.model.employee.Employee" output="false"&gt;
      &lt;cfargument name="employee_id" type="numeric" required="false"  /&gt;
      &lt;cfargument name="employee_name" type="string" required="false"  /&gt; 

      &lt;cfset this['effort_id']       = arguments.effort_id /&gt;
      &lt;cfset this['employee_name']      = arguments.employee_name /&gt;

      &lt;cfreturn this /&gt;
   &lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<h2>Converting a Query to an Employee Array</h2>
<p>Again, as a very simple example, let&#8217;s say I have an EmployeeService component in my service layer and have a method listEmployees() that simply queries the <em>employees</em> table and returns all rows.</p>
<pre class="code"><code>&lt;cffunction name="listEmployees" access="public" output="false" returntype="query"&gt;
   &lt;cfset var effortQuery = "" /&gt;

   &lt;cfquery datasource="#variables.config.getSetting("datasource")#" name="employeeQuery"&gt;
   select e.* from employees e
   &lt;/cfquery&gt;

   &lt;cfreturn effortQuery /&gt;
&lt;/cffunction&gt;</code></pre>
<p>Since I don&#8217;t want to return a query, and I certainly don&#8217;t want to have two methods in every single component &#8211; one that returns a query and one that returns an array of objects &#8211; I use the handy, dandy AOP feature in ColdSpring to apply an advice that does it at runtime. </p>
<h3>QueryToVOAdvice Advice</h3>
<p>In this advice, I simply loop over the query&#8217;s rows and columns to create a simple structure containing the key/value pairs for each row.  It then creates a new component for each query row by passing that structure to the init() function &#8211; which you saw above &#8211; and adds it to an array.</p>
<p>The result is an array of Employee-typed objects.</p>
<pre class="code"><code>&lt;cfcomponent displayname="QueryToVOAdvice" extends="coldspring.aop.MethodInterceptor"&gt;

   &lt;cffunction name="init" returntype="utility.aop.advice.converters.QueryToVOAdvice" access="public" output="false"&gt;
      &lt;cfreturn this /&gt;
   &lt;/cffunction&gt;

   &lt;cffunction name="invokeMethod" access="public" returntype="any"&gt;
      &lt;cfargument name="methodInvocation" type="coldspring.aop.MethodInvocation" required="false" /&gt;

      &lt;cfscript&gt;
      var local = structNew();
      local.queryRow = 1;

      // Create an array to hold the value objects
      local.valueObjectArray = ArrayNew(1);

      // Store the resulting query object from the method execution
      local.queryObject = arguments.methodInvocation.proceed();

      // Loop over the query rows
      for(local.queryRow=1; local.queryRow lte local.queryObject.recordCount; local.queryRow = local.queryRow+1)
      {
         local.voStruct = structNew();

         // Loop over the query columns and create a key/value pair for each value
         // in this row of the query
         for(local.columnNum=1; local.columnNum lte listLen(local.queryObject.columnList); local.columnNum = local.columnNum+1)
         {
            local.columnName = listGetAt(local.queryObject.columnList, local.columnNum);
            local.voStruct[local.columnName] = local.queryObject[local.columnName][local.queryRow];
         }

         // Create an instance of the value object (obtained from the getValueObject method)
         // initializing it with the structure we created.  Add the value object to the array.
         arrayAppend(local.valueObjectArray, createObject('component', arguments.methodInvocation.getTarget().getValueObject()).init(argumentCollection=local.voStruct));
      }

      return local.valueObjectArray;
      &lt;/cfscript&gt;
   &lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<h3>ValueObject Property</h3>
<p>For each of my beans, in this case the Employee bean, I can simply apply an advice in the definition.  For this to work, I create a <strong>valueObject</strong> property in each component.</p>
<pre class="code"><code>&lt;component name="Employee"&gt;
   &lt;cffunction name="setValueObject" access="public" output="false" returntype="void"&gt;
      &lt;cfargument name="valueObject" type="string" required="true" /&gt;
      &lt;cfset variables.valueObject = arguments.valueObject /&gt;
   &lt;/cffunction&gt;

   &lt;cffunction name="getValueObject" access="public" output="false" returntype="string"&gt;
      &lt;cfreturn variables.valueObject /&gt;
   &lt;/cffunction&gt;
&lt;/component&gt;</code></pre>
<h3>Employee Bean Definition</h3>
<p>Now when I define my Employee bean, I specify the type of the value object (the type that gets returned from the init() function), and then apply the advisor (shown below).</p>
<pre class="code"><code>&lt;bean id="Employee" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
   &lt;property name="target"&gt;
      &lt;bean class="net.fusioncube.model.employee.EmployeeService"&gt;
         &lt;property name="valueObject"&gt;
            &lt;value&gt;net.fusioncube.model.employee.Employee&lt;/value&gt;
         &lt;/property&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;queryToValueObjectAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<h3>QueryToValueObjectAdvisor Definition</h3>
<pre class="code"><code>&lt;bean id="queryToValueObjectAdvisor" class="coldspring.aop.support.RegexMethodPointcutAdvisor"&gt;
   &lt;property name="advice"&gt;
      &lt;bean class="utility.aop.advice.converters.QueryToVOAdvice"/&gt;
   &lt;/property&gt;
   &lt;property name="pattern"&gt;
      &lt;value&gt;^list.*$&lt;/value&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<h3>The Flex Array of Typed Objects</h3>
<p>Here&#8217;s an image of an example array I get back from ColdFusion in one of my current apps.  You can see that each object was automatically converted into a Teammate (equivalent of an Employee) rather than a simple Object.</p>
<p><a href='http://www.fusioncube.net/wp-content/uploads/2008/10/transferobject_array.png'><img src="http://www.fusioncube.net/wp-content/uploads/2008/10/transferobject_array.png" alt="" title="Array of value objects" width="365" height="189" class="alignnone size-full wp-image-251" /></a></p>
<p>Caveat: If you&#8217;re passing back queries with a thousand or more rows, and are running CFMX 7 or older, then this solution may cause serious performance problems as object creation is notoriously &#8220;slow&#8221; in those versions of ColdFusion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldfusion-flex-object-conversion/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When to use autowiring in ColdSpring</title>
		<link>http://www.fusioncube.net/index.php/when-to-use-autowiring-in-coldsprin</link>
		<comments>http://www.fusioncube.net/index.php/when-to-use-autowiring-in-coldsprin#comments</comments>
		<pubDate>Mon, 15 Sep 2008 19:38:23 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[model-glue]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=248</guid>
		<description><![CDATA[Autowiring in ColdFusion Most of you may have heard of autowiring, and many of you may have implemented it in an application by now (most likely with Spring, ColdSpring, or Google Guice). If you don&#8217;t know what autowiring is, or are curious about how to do it, I&#8217;ll simply direct you to other people who [...]]]></description>
			<content:encoded><![CDATA[<h3>Autowiring in ColdFusion</h3>
<p>Most of you may have heard of autowiring, and many of you may have implemented it in an application by now (most likely with <a href="http://www.springframework.org/">Spring</a>, <a href="http://www.coldspringframework.org/">ColdSpring</a>, or <a href="http://code.google.com/p/google-guice/">Google Guice</a>).</p>
<p>If you don&#8217;t know what autowiring is, or are curious about how to do it, I&#8217;ll simply direct you to other people who have adequately explained it (see reference links at bottom of article) rather than doing it myself.  This article is about when to use it, not how to use it.</p>
<p>Most people I talk to, or have read articles by, promote autowiring as a positive thing.  It offers an effective way to automatically inject instantiated components into other components that require their methods.  Who wouldn&#8217;t be a fan of that??</p>
<p>Nevertheless, there are gadflies who point out that the overuse of autowiring defeats one of the benefits of your bean definition file: a documentation tool.  It is the one place in your application that clearly shows how services depends on each other.  I believe this is a valid point, as I often use my definition file as a quick reference to my application&#8217;s dependencies.</p>
<h3>Autowiring Incidental Dependencies</h3>
<p>I prefer to use the autowiring feature for beans that are not business logic:</p>
<ul>
<li>Datasources</li>
<li>Configuration settings</li>
<li>Resource libraries (e.g. Transfer ORM)</li>
<li>Transfer/Value objects</li>
</ul>
<p>For example, several of my apps are written using Model-Glue, and I define beans to pass the application&#8217;s datasource, and transfer service:</p>
<pre class="code"><code>&lt;bean id="datasource" factory-bean="transfer" factory-method="getDatasource" /&gt;
&lt;bean id="transferService" factory-bean="transfer" factory-method="getTransfer" /&gt;</code></pre>
<p>Most of my beans require one, or both, of these services, and I&#8217;m reluctant to pass them in as constructor arguments since I consider them incidental dependencies, rather than logical dependencies.  I see no benefit in having these clutter up my definition file since they offer no help to me, or anyone else, when determining if the Facility component requires the use of the Organization_Demographics component or not.</p>
<p>Instead of having dozens of these definitions filling up my definition file:</p>
<pre class="code"><code>&lt;bean id="DrugMapping" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
   &lt;property name="target"&gt;
      &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailService"&gt;
         &lt;constructor-arg name="transfer"&gt;
            &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="Offering"&gt;
            &lt;ref bean="Offering" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="Party"&gt;
            &lt;ref bean="Party" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="DetailGateway"&gt;
            &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailGateway"&gt;
               &lt;constructor-arg name="transfer"&gt;
                  &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
               &lt;/constructor-arg&gt;
               &lt;constructor-arg name="datasource"&gt;
                  &lt;bean factory-bean="transfer" factory-method="getDatasource" /&gt;
               &lt;/constructor-arg&gt;
            &lt;/bean&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="datasource"&gt;
            &lt;bean factory-bean="transfer" factory-method="getDatasource" /&gt;
         &lt;/constructor-arg&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<p>Instead I enjoy looking at a definition file that shows me how I&#8217;m wiring my application together.</p>
<pre class="code"><code>&lt;bean id="DrugMapping" class="coldspring.aop.framework.ProxyFactoryBean" autowire="byName"&gt;
   &lt;property name="target"&gt;
      &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailService"&gt;
         &lt;constructor-arg name="Offering"&gt;
            &lt;ref bean="Offering" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="Party"&gt;
            &lt;ref bean="Party" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="DetailGateway"&gt;
            &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailGateway" autowire="byName" /&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<h3>Reference Links</h3>
<p><a href="http://www.firemoss.com/post.cfm/ModelGlue--What-the-hell-is-autowiring">Joe Rinehart on autowiring</a><br />
<a href="http://aria-media.com/blog/index.cfm/2006/9/22/The-Mystery-of-AutoWiring">Nando demystifies autowiring</a><br />
<a href="http://rachaelandtom.info/node/1453">Download a small, sample app that provides autowiring code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/when-to-use-autowiring-in-coldsprin/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Preventing SQL Injection</title>
		<link>http://www.fusioncube.net/index.php/preventing-sql-injection</link>
		<comments>http://www.fusioncube.net/index.php/preventing-sql-injection#comments</comments>
		<pubDate>Thu, 28 Aug 2008 13:44:51 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=245</guid>
		<description><![CDATA[An old client of mine recently contacted me with a problem. Their home page, several sub-pages, and the administrative section weren&#8217;t displaying properly and functionality was broken. Turns out, they were a victim of the recent swarm of SQL injection attacks. After pulling the old code out of my repository, I discovered that I&#8217;d used [...]]]></description>
			<content:encoded><![CDATA[<p>An old client of mine recently contacted me with a problem. Their home page, several sub-pages, and the administrative section weren&#8217;t displaying properly and functionality was broken.  Turns out, they were a victim of the recent swarm of SQL injection attacks.</p>
<p>After pulling the old code out of my repository, I discovered that I&#8217;d used CFQUERYPARAM (I won&#8217;t iterate the hundreds of articles you can find by yourself stating, &#8220;USE CFQUERYPARAM, DUMMY!!&#8221;) in all of my business logic code, so I couldn&#8217;t quite figure out what was going on.  While perusing the web for other ideas, I ran across <a href="http://www.jasonbartholme.com/2-methods-to-help-prevent-sql-injections-with-coldfusion/">Jason Bartholme&#8217;s blog entry about preventing SQL injection attacks</a>.  He has a simple bit of code that he put in onRequestStart() so check if the keyword DECLARE was in the URL.</p>
<pre class="code"><code>&lt;cfif not structIsEmpty(URL) &gt;
   &lt;cfloop list="#StructKeyList(URL)#" index="i"&gt;
      &lt;cfif URL[i] CONTAINS "4445434C415245"&gt;
         &lt;cfmail to="me@mysite.com" from="them@theirsite.com" subject="SQL Injection Attempt" type="html"&gt;
            &lt;cfdump var="#URL#"&gt;
            &lt;cfdump var="#CGI#"&gt;
         &lt;/cfmail&gt;
         &lt;cfabort&gt;
      &lt;/cfif&gt;
   &lt;/cfloop&gt;
&lt;/cfif&gt;</code></pre>
<p>This worked like a charm and allowed me to see what exactly these jerkoffs were doing.  Turned out I had left CFQUERYPARAM out of some queries I was running for the Contact Us page and a few product display pages.  Once I added the tags, the attacks stopped.</p>
<p>If you&#8217;re seeing SQL injection attacks, just add the code to application.cfm or the onRequestStart() function of application.cfc to see if this is the method the attackers are using and what they are doing.</p>
<p>Thanks Jason!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/preventing-sql-injection/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The ColdFusion ServiceRunner &#8211; Part I</title>
		<link>http://www.fusioncube.net/index.php/the-coldfusion-servicerunner-part-1</link>
		<comments>http://www.fusioncube.net/index.php/the-coldfusion-servicerunner-part-1#comments</comments>
		<pubDate>Wed, 27 Aug 2008 22:54:19 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=244</guid>
		<description><![CDATA[I&#8217;ve been meaning to share this for many reasons, but I&#8217;ve been bogged down with projects lately. However, it has allowed the code to mature and get streamlined a bit, so it&#8217;s good that some time has passed. This is a pattern that we&#8217;ve come up with at work to handle remote calls to ColdFusion. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to share this for many reasons, but I&#8217;ve been bogged down with projects lately. However, it has allowed the code to mature and get streamlined a bit, so it&#8217;s good that some time has passed.</p>
<p>This is a pattern that we&#8217;ve come up with at work to handle remote calls to ColdFusion. It is one part of our SOA initiative that allows ColdFusion and Flex developers to make service calls to our core business components using a common approach.</p>
<p>I&#8217;ll start at the high level and work my way down.  The reason I started this project is because early on I started to notice that there were many common entities used throughout the gamut of application used by my business unit &#8211; Facilities, Teammates, Drugs, Treatments, Patients, Doctors, etc&#8230;</p>
<p>Each application developer had written their own code to handle retrieving information on each of these entities.  I&#8217;m sure you can see where the problem is in that, so I won&#8217;t belabor the point.  To stop the fragmentation, I began diagramming how to create a common service application that could be accessed by any client in the company using a simple interface.</p>
<h3>The Remote Call Service &#8211; RemotingService.cfc</h3>
<p>Let&#8217;s start off with the first part of the puzzle: the simple interface for calling ColdFusion Component methods in our service application.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;

	&lt;cffunction name="invokeService" access="remote" returntype="Any"&gt;
		&lt;cfargument name="eventName" type="string" required="true" /&gt;
		&lt;cfargument name="eventData" type="struct" required="false" default="#structNew()#" /&gt;

		&lt;cfreturn application.beanFactory.getBean("ServiceRunner").run(argumentCollection=arguments) /&gt;
	&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<p>Can&#8217;t get more simple than this.  Using any remoting technology supporting SOAP, any client can invoke this component&#8217;s invokeService() method.  This is the one entry point into our service application. As I&#8217;m sure you noticed by the <strong>application.beanFactory</strong> code, we&#8217;re using ColdSpring to manage all of our dependencies, AOP features, and event maps (more on this later).</p>
<h3>The Service Response Value Object &#8211; ResponseVO.cfc</h3>
<p>The next concept we tackled was not returning complex objects; we wanted a simple and logical structure to what gets returned to the client.  Also we didn&#8217;t want the response object sitting around in memory sucking up RAM on the machine.  We wanted this object to be created and destroyed on each remote request (shows below in the ServiceRunner code).</p>
<p>What got created was a simple Value Object that defines the keys of the response: name of the event, a success boolean, the data object, and an error structure (which is only populated if an error occurs).</p>
<pre class="code"><code>&lt;cfcomponent output="false"
	hint="Value object that is returned for every response"&gt;

	&lt;cfproperty name="eventName"  type="string" /&gt;
	&lt;cfproperty name="success"    type="boolean" /&gt;
	&lt;cfproperty name="data"       type="any" /&gt;
	&lt;cfproperty name="error"      type="Struct"/&gt;

	&lt;cfset this.eventName = "" /&gt;
	&lt;cfset this.success = true /&gt;
	&lt;cfset this.data = "" /&gt;
	&lt;cfset this.error = structNew() /&gt;

&lt;/cfcomponent&gt;</code></pre>
<h3>The Service Runner &#8211; ServiceRunner.cfc</h3>
<p>Once we&#8217;d defined how services would be called and what the response would be, we then had to write the mechanism to actually execute the method and populate the response VO.  The service runner is defined as a bean via ColdSpring (shown below) and is instantiated from the RemotingService component (shown above).  </p>
<p>The RemotingService then calls the public run() method which creates a VO, executes the requested event using the private runEvent() method, and then returns the populated VO.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;

	&lt;cffunction name="run" access="public" returntype="Any" output="false" description="Responds to remote request"&gt;
		&lt;cfargument name="eventName" type="string" required="true" /&gt;
		&lt;cfargument name="eventData" type="Struct" required="false" default="#structNew()#" /&gt;

		&lt;cfset var local = StructNew() /&gt;
		&lt;cfset var vo = createObject("component", "utility.remoting.ResponseVO") /&gt;

		&lt;cfset vo.success 	= true /&gt;
		&lt;cfset vo.eventName = arguments.eventName /&gt;

		&lt;cftry&gt;
			&lt;cfset local.eventData = arguments.eventData /&gt;

			&lt;cfif application.beanFactory.containsBean("event.#arguments.eventName#")&gt;
				&lt;cfset vo.data = runEvent(eventName=arguments.eventName, eventData=arguments.eventData) /&gt;
			&lt;cfelse&gt;
				&lt;cfthrow detail="Event definition not found" message="event.#arguments.eventName# was not found." /&gt;
			&lt;/cfif&gt;

			&lt;cfcatch type="any"&gt;
				&lt;cfset vo.success 	= false /&gt;
				&lt;cfset vo.data 		= "" /&gt;
				&lt;cfset vo.error 	= cfcatch /&gt;
			&lt;/cfcatch&gt;
		&lt;/cftry&gt;

		&lt;cfreturn vo /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="runEvent" access="private" returntype="any" output="false" hint="Calls the event defined in the EventMaps definition file"&gt;
		&lt;cfargument name="eventName" type="string" required="true" /&gt;
		&lt;cfargument name="eventData" type="Struct" required="true" /&gt;

		&lt;cfset var local = structNew() /&gt;
		&lt;cfset local.response = "" /&gt;

		&lt;cfset local.eventInfo = application.beanFactory.getBean("event.#arguments.eventName#") /&gt;
		&lt;cfset local.eventHandler = application.beanFactory.getBean(local.eventInfo.getBeanName()) /&gt;

		&lt;cfinvoke component="#local.eventHandler#" method="#local.eventInfo.getMethodName()#" returnvariable="local.response" argumentcollection="#arguments.eventData#" /&gt;

		&lt;cfreturn local.response /&gt;
	&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<h3>Defining Events as Beans &#8211; EventMaps.xml</h3>
<p>To define our events, we create a bean for each one using the RemoteEventMap.cfc as the template for each one. The RemoteEventMap (code shown below) has two properties: beanName and methodName.  These are used in the runEvent() method of the ServiceRunner (shown above) to obtain the properties needed for the CFINVOKE tag that executes the actual method we need.</p>
<pre class="code"><code>&lt;!DOCTYPE beans SYSTEM "ColdSpring.dtd"
[
   &lt;!ENTITY appName "yourAppName"&gt;
   &lt;!ENTITY appCFCMapping "&amp;appName;.model"&gt;
   &lt;!ENTITY eventCFCMap "utility.remoting.RemoteEventMap"&gt;
]&gt;
&lt;beans&gt;
   &lt;bean id="ServiceRunner" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
      &lt;property name="target"&gt;
         &lt;bean class="utility.remoting.ServiceRunner" /&gt;
      &lt;/property&gt;
      &lt;property name="interceptorNames"&gt;
         &lt;list&gt;
            &lt;value&gt;metricsAdvisor&lt;/value&gt;
         &lt;/list&gt;
      &lt;/property&gt;
   &lt;/bean&gt;

   &lt;bean id="event.getFacilities" class="&amp;eventCFCMap;"&gt;
      &lt;property name="beanName"&gt;
         &lt;value&gt;FacilityService&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="methodName"&gt;
         &lt;value&gt;getHeldFacilities&lt;/value&gt;
      &lt;/property&gt;
   &lt;/bean&gt;
&lt;/beans&gt;</code></pre>
<h3>The Event Bean &#8211; RemoteEventMap.cfc</h3>
<p>This is the simple RemoteEventMap that each event creates as a bean.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;

	&lt;cffunction name="init" access="public" output="false" returntype="RemoteEventMap"&gt;
		&lt;cfset variables.beanName = "" /&gt;
		&lt;cfset variables.methodName = "" /&gt;

		&lt;cfreturn this /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="getBeanName" access="public" output="false" returntype="string"&gt;
		&lt;cfreturn variables.beanName /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="setBeanName" access="public" output="false" returntype="void"&gt;
		&lt;cfargument name="beanName" type="string" required="true" /&gt;

		&lt;cfset variables.beanName = arguments.BeanName /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="getMethodName" access="public" output="false" returntype="string"&gt;
		&lt;cfreturn variables.methodName /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="setMethodName" access="public" output="false" returntype="void"&gt;
		&lt;cfargument name="methodName" type="string" required="true" /&gt;

		&lt;cfset variables.methodName = arguments.methodName /&gt;
	&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<p>In Part II &#8211; which I will hopefully finish up tomorrow &#8211; I will show implementation examples of this pattern for ColdFusion and for Flex.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/the-coldfusion-servicerunner-part-1/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Invoking ColdSpring beans with ajaxCFC</title>
		<link>http://www.fusioncube.net/index.php/invoking-coldspring-bean-with-ajaxcfc</link>
		<comments>http://www.fusioncube.net/index.php/invoking-coldspring-bean-with-ajaxcfc#comments</comments>
		<pubDate>Tue, 20 May 2008 16:07:43 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[ajaxCFC]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=216</guid>
		<description><![CDATA[As a heavy user of Rob Gonda&#8217;s ajaxCFC library, I&#8217;ve incorporated it into almost every app I&#8217;ve written in the past two years. The only restriction that required me to write workarounds was the fact that you could only invoke ColdFusion Components directly. The thing is, I also love ColdSpring to manage dependencies and to [...]]]></description>
			<content:encoded><![CDATA[<p>As a heavy user of Rob Gonda&#8217;s <a href="http://ajaxcfc.riaforge.org/">ajaxCFC</a> library, I&#8217;ve incorporated it into almost every app I&#8217;ve written in the past two years. The only restriction that required me to write workarounds was the fact that you could only invoke ColdFusion Components directly. The thing is, I also love <a href="http://www.coldspringframework.org/">ColdSpring</a> to manage dependencies and to implement my <a href="http://www.coldspringframework.org/docs/Aspect_Oriented_Programming_w__ColdSpring.htm#Introduction">Aspect Oriented Programming</a> components.</p>
<p>What I want is to be able to call my ColdSpring beans with ajaxCFC so that I can make my asynchronous calls, get serialized data back, and all the while utilizing the dependencies set up in my beans.  Well, I finally got around to modifying Rob&#8217;s code to allow for this. I use the jQuery branch, so my solution currently only works for that implementation.  I may try to work on the DWR version, but that&#8217;s unlikely because I don&#8217;t use it.</p>
<p>There are three changes to how you invoke ajaxCFC in order to work with ColdSpring beans.</p>
<h3>The URL Attribute</h3>
<p>Instead of the URL value being the path to your logic component, its value should be the path to the ajax.cfc component</p>
<pre class="brush: jscript; title: ; notranslate">
url:'com/company/common/ajax/ajax.cfc'
</pre>
<h3>The Bean Attribute</h3>
<p>This property&#8217;s value will be the name of the ColdSpring bean you want to use.</p>
<pre class="brush: jscript; title: ; notranslate">
bean: 'Facility'
</pre>
<h3>The Factory Attribute</h3>
<p>This property&#8217;s value will be the name of your ColdSpring bean factory.</p>
<pre class="brush: jscript; title: ; notranslate">
factory:'application.beanFactory'
</pre>
<h3>A Complete Invocation</h3>
<p>Here&#8217;s a sample call stripped directly from one of my applications</p>
<pre class="brush: jscript; title: ; notranslate">
$.AjaxCFC({
	url:'com/company/common/ajax/ajax.cfc',
	bean: 'Facility',
	factory:'application.beanFactory',
	method: 'getFacilities',
	data: { 'orderby':orderByField },
	useDefaultErrorHandler: false,
	success: function(results) {
		$('#facilitySelectContainer').html(results);
	},
	error: function(results) {
		Ext.MessageBox.alert('Error Notification', 'There was an error while loading the facilities. Please try again.')
	}
});
</pre>
<h3>The Code</h3>
<p>There are two files you need to replace.</p>
<ol>
<li>ajax.cfc</li>
<li>jquery.AjaxCFC.js</li>
</ol>
<p><a href='http://www.fusioncube.net/wp-content/uploads/2008/05/ajaxcfc-coldspring.zip' title='ColdSpring-enabled ajaxCFC'>Download ColdSpring-enabled ajaxCFC</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/invoking-coldspring-bean-with-ajaxcfc/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Calling Oracle functions in ColdFusion &#8211; BOOLEAN restriction</title>
		<link>http://www.fusioncube.net/index.php/calling-oracle-functions-in-coldfusion-boolean-restriction</link>
		<comments>http://www.fusioncube.net/index.php/calling-oracle-functions-in-coldfusion-boolean-restriction#comments</comments>
		<pubDate>Wed, 07 May 2008 19:54:30 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=206</guid>
		<description><![CDATA[I was trying to call an Oracle function from ColdFusion today and was just receiving error, after error, after error&#8230; well you get the point. Long story short, I couldn&#8217;t successfully get a response since there is no binding between ColdFusion and the Oracle BOOLEAN type, and the function was returning BOOLEAN. So I changes [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to call an Oracle function from ColdFusion today and was just receiving error, after error, after error&#8230; well you get the point. Long story short, I couldn&#8217;t successfully get a response since there is no binding between ColdFusion and the Oracle BOOLEAN type, and the function was returning BOOLEAN.  So I changes the response to 0/1 and it works.</p>
<p>Just something to keep in mind.</p>
<pre class="code"><code>&lt;cfquery name="myQueryName" datasource="myDS"&gt;
    select myPackage.myFunction(myArg1, myArg2) response from dual
&lt;/cfquery&gt;
&lt;cfdump var="#myQueryName.response#"&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/calling-oracle-functions-in-coldfusion-boolean-restriction/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using overloaded Java methods via ColdFusion</title>
		<link>http://www.fusioncube.net/index.php/using-overloaded-java-methods-via-coldfusion</link>
		<comments>http://www.fusioncube.net/index.php/using-overloaded-java-methods-via-coldfusion#comments</comments>
		<pubDate>Wed, 26 Mar 2008 15:03:22 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=204</guid>
		<description><![CDATA[While helping a colleague out with a tricky problem accessing Excel files, I downloaded the Java Excel API library from SourceForge. After a quick scan of the documentation, I started to write some ColdFusion code. &#60;cfscript&#62; jxlWorkbook = createObject('java','jxl.Workbook'); file = createObject('java','java.io.File').init("C:\\temp\\test.xls"); excelFile = jxlWorkbook.getWorkbook(file); &#60;/cfscript&#62; I&#8217;m immediately alerted with the message The selected method [...]]]></description>
			<content:encoded><![CDATA[<p>While helping a colleague out with a tricky problem accessing Excel files, I downloaded the <a href="http://jexcelapi.sourceforge.net/">Java Excel API</a> library from SourceForge. After a quick scan of the documentation, I started to write some ColdFusion code.</p>
<pre class="code"><code>&lt;cfscript&gt;
jxlWorkbook = createObject('java','jxl.Workbook');
file = createObject('java','java.io.File').init("C:\\temp\\test.xls");
excelFile = jxlWorkbook.getWorkbook(file);
&lt;/cfscript&gt;</code></pre>
<p>I&#8217;m immediately alerted with the message</p>
<pre class="code"><code>The selected method getWorkbook was not found.

Either there are no methods with the specified method name and argument types,
or the method getWorkbook is overloaded with arguments types that ColdFusion can't
decipher reliably. If this is a Java object and you verified that the method exists,
you may need to use the javacast function to reduce ambiguity.</code></pre>
<p>I dump out the object, and there are actually 5 method signatures for getWorkbook() and the one I want accepts a single argument of type <em>java.io.File</em>. I also know that the JavaCast() function certainly can&#8217;t handle a complex type like <em>java.io.File</em>. What&#8217;s a poor coder to do?  I thought this was the end of the line, but figured I&#8217;d try something anyway&#8230;</p>
<pre class="code"><code>&lt;cfscript&gt;
jxlWorkbook = createObject('java','jxl.Workbook');
excelFile = jxlWorkbook.getWorkbook(createObject('java','java.io.File').init("C:\\temp\\test.xls"));
&lt;/cfscript&gt;</code></pre>
<p>Lo, and behold, that worked perfectly! I never knew that you could use createObject() inside a method call.</p>
<p>There was another snag that I&#8217;d never ran across before: another method of the library wouldn&#8217;t accept integers passed from ColdFusion. In a simple from-to loop producing an index, the value of the index wasn&#8217;t being accepted by the method.</p>
<pre class="code"><code>&lt;cfloop from="0" to="#transactions.getRows() - 1#" index="row"&gt;
	&lt;cfloop from="0" to="#transactions.getColumns() - 1#" index="col"&gt;
		&lt;cfset currentCell = transactions.getCell(<strong>col</strong>, <strong>row</strong>)&gt;
		&lt;cfoutput&gt;#currentCell.getContents()#&lt;/cfoutput&gt;
	&lt;/cfloop&gt;
	&lt;br/&gt;
&lt;/cfloop&gt;</code></pre>
<p>I had to use JavaCast() to force them into the native int type.</p>
<pre class="code"><code>&lt;cfset currentCell = transactions.getCell(JavaCast("int", col), JavaCast("int", row))&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/using-overloaded-java-methods-via-coldfusion/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ColdSpring Remote Proxies as WebServices&#8230; Whew!</title>
		<link>http://www.fusioncube.net/index.php/coldspring-remote-proxies-as-webservices-whew</link>
		<comments>http://www.fusioncube.net/index.php/coldspring-remote-proxies-as-webservices-whew#comments</comments>
		<pubDate>Tue, 11 Mar 2008 20:59:48 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=202</guid>
		<description><![CDATA[You know the word caveat, right? Well, today I learned that there are a few caveats when setting up ColdSpring remote proxy beans. When invoking a webservice that has logically optional arguments, you still have to pass all defined arguments with the omit attribute set to yes on the &#60;cfinvokeargument&#62; tag (see Listing 1.1 below). [...]]]></description>
			<content:encoded><![CDATA[<p>You know the word caveat, right? Well, today I learned that there are a few caveats when <a href="http://www.coldspringframework.org/docs/Developing_w__ColdSpring.htm#Using_AOP_to_create_remote_proxies">setting up ColdSpring remote proxy beans</a>.</p>
<ul>
<li>When invoking a webservice that has logically optional arguments, you still have to pass all defined arguments with the <strong>omit</strong> attribute set to yes on the &lt;cfinvokeargument&gt; tag (see Listing 1.1 below). Otherwise you&#8217;ll get the result of a Java method exception. It will look something like this &#8211; &#8221; Web service operation &#8220;someMethod&#8221; with parameters {ARGUMENT={1}} could not be found&#8221;</li>
<li>When you have optional arguments in a component method that you want to access as a webservice, you have to provide a default value for each one. Otherwise, you&#8217;ll get <em>premature end of file</em> Axis errors (see Listing 1.2 below)</li>
<li>You must define the (somewhat) undocumented <strong>beanFactoryName</strong> property of ColdSpring&#8217;s RemoteFactoryBean. This will be the package name of where your ColdSpring definitions are located in the application namespace. For those using Model-Glue, this will be <strong>{app name}.framework</strong> (see Listing 1.3 below)</li>
</ul>
<h3>Listing 1.1</h3>
<pre class="code"><code>&lt;cfscript&gt;
billGroupService = createObject("webservice", "http://localhost/webapps/charm/remote/BillingGroup.cfc?wsdl");
&lt;/cfscript&gt;
&lt;cfinvoke method="getGroups" webservice="#billGroupService#"&gt;
	&lt;cfinvokeargument name="BILLING_RULE_GRP_CD" value="1"&gt;
	&lt;cfinvokeargument name="DESCR" <strong>omit="yes"</strong>&gt;
	&lt;cfinvokeargument name="ACTIVE_IND" <strong>omit="yes</strong>"&gt;
	&lt;cfinvokeargument name="DEFAULT_FLAG" <strong>omit="yes"</strong>&gt;
&lt;/cfinvoke&gt;</code></pre>
<h3>Listing 1.2</h3>
<pre class="code"><code>&lt;cffunction name="getGroups" access="public" output="false" returntype="array"&gt;
	&lt;cfargument name="BILLING_RULE_GRP_CD" <strong>default=""</strong> type="string" required="false" /&gt;
	&lt;cfargument name="DESCR" <strong>default=""</strong> type="string" required="false" /&gt;
	&lt;cfargument name="ACTIVE_IND" <strong>default=""</strong> type="string" required="false" /&gt;
	&lt;cfargument name="DEFAULT_FLAG" <strong>default=""</strong> type="string" required="false" /&gt;

	&lt;cfreturn variables.GroupGateway.getByAttributes(argumentCollection=arguments) /&gt;
&lt;/cffunction&gt;</code></pre>
<h3>Listing 1.3</h3>
<pre class="code"><code>&lt;bean id="RemoteBillingRuleGroup" class="coldspring.aop.framework.RemoteFactoryBean"&gt;
	&lt;property name="interceptorNames"&gt;
		&lt;list&gt;
			&lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
			&lt;value&gt;metricsAdvisor&lt;/value&gt;
		&lt;/list&gt;
	&lt;/property&gt;
	&lt;property name="target"&gt;
		&lt;ref bean="BillingRuleGroupTarget" /&gt;
	&lt;/property&gt;
	&lt;property name="serviceName"&gt;
		&lt;value&gt;BillingGroup&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="relativePath"&gt;
		&lt;value&gt;/webapps/charm/remote/&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="<strong>beanFactoryName</strong>"&gt;
		&lt;value&gt;<strong><em>charm.framework</em></strong>&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="remoteMethodNames"&gt;
		&lt;value&gt;*&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldspring-remote-proxies-as-webservices-whew/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Find list elements using Regular Expressions</title>
		<link>http://www.fusioncube.net/index.php/find-list-elements-regex</link>
		<comments>http://www.fusioncube.net/index.php/find-list-elements-regex#comments</comments>
		<pubDate>Tue, 16 Jan 2007 19:29:41 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/index.php/find-list-elements-regex.html</guid>
		<description><![CDATA[A colleague of mind asked me this afternoon if I knew of a way, in ColdFusion, and one of line of code, to determine if all of the elements in a short list are contained in a larger list. He also wanted to discount the order of the elements in the larger list &#8211; the [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague of mind asked me this afternoon if I knew of a way, in ColdFusion, and one of line of code, to determine if all of the elements in a short list are contained in a larger list.  He also wanted to discount the order of the elements in the larger list &#8211; the elements could be anywhere.  I quickly indexed my mental store of ColdFusion list functions, and nothing came to mind, so my first answer was no.  Then I thought about it for a minute and realized that he could use my trusted friend and companion &#8211; regular expressions.</p>
<p>I figured if there was a way to convert the list itself into a regular expression pattern using lookaheads, then it would be a snap.  I then went to LiveDocs and discovered the ListChangeDelims() function which I had never used before.  It was perfect.</p>
<pre class="code"><code>&lt;cfset largeList = "127.0.0.1,192.168.0.1,63.25.178.45,12.87.65.102,155.189.37.121"&gt;
&lt;cfset smallList = "192.168.0.1,12.87.65.102"&gt;

&lt;cfset allElementsInLargeList = ReFind( "^(?=.*#ListChangeDelims(smallList,')(?=.*', ',')#).*$", largeList)&gt;
&lt;cfdump var="#allElementsInLargeList#"&gt;</code></pre>
<p>Works like a charm and all done on one line of ColdFusion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/find-list-elements-regex/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How CFLOCK doesn&#8217;t</title>
		<link>http://www.fusioncube.net/index.php/how-cflock-doesnt</link>
		<comments>http://www.fusioncube.net/index.php/how-cflock-doesnt#comments</comments>
		<pubDate>Tue, 21 Nov 2006 22:03:04 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=123</guid>
		<description><![CDATA[I&#8217;ve one word for you, just one word&#8230; frames. Amazing how simple it is to completely bust the CFLOCK tag. First, you create a simple page that has frames and loads another page into each frame. &#60;html&#62; &#60;head&#62; &#60;meta http-equiv="pragma" content="no-cache"&#62; &#60;meta http-equiv="expires" content="tue, 04 jan 2000 1:00:00 gmt"&#62; &#60;cfheader name="cache-control" value="no-cache, no-store, must-revalidate"&#62; &#60;/head&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve one word for you, just one word&#8230; frames.</p>
<p>Amazing how simple it is to completely bust the CFLOCK tag.  First, you create a simple page that has frames and loads another page into each frame.</p>
<pre class="code"><code>&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv="pragma" content="no-cache"&gt;
	&lt;meta http-equiv="expires" content="tue, 04 jan 2000 1:00:00 gmt"&gt;
	&lt;cfheader name="cache-control" value="no-cache, no-store, must-revalidate"&gt;
&lt;/head&gt;
&lt;frameset rows="1" cols="*,*"&gt;
	&lt;frame src="thread.cfm?id=1"&gt;
	&lt;frame src="thread.cfm?id=2"&gt;
&lt;/frameset&gt;
&lt;/html&gt;</code></pre>
<p>Now for the code that is supposed to lock in the first frame, then release and then get picked up subsequently by the second frame.</p>
<pre class="code"><code>&lt;cfoutput&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv="pragma" content="no-cache"&gt;
	&lt;meta http-equiv="expires" content="tue, 04 jan 2000 1:00:00 gmt"&gt;
	&lt;cfheader name="cache-control" value="no-cache, no-store, must-revalidate"&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;cflock name="globallockthatbreaks" type="exclusive" timeout="10" throwontimeout="true"&gt;
		#id#: got lock @ #timeformat(now(), "hh:mm:ss")#-#gettickcount()#&lt;p&gt;

		<!--- the following nested lock breaks the "globallockthatbreaks". comment it out and things work fine. --->
		&lt;cflock name="globallockthatbreaks" type="exclusive" timeout="10" throwontimeout="true"/&gt;

		 <!--- stall 2 seconds to simulate work --->
		&lt;cflock name="stall_out_#id#" throwontimeout="yes" timeout="1" type="readonly"&gt;
			&lt;cftry&gt;&lt;cflock name="stall_out_#id#" throwontimeout="no" timeout="2" type="exclusive" /&gt;&lt;cfcatch/&gt;&lt;/cftry&gt;
		&lt;/cflock&gt;

		#id#: give up lock @ #timeformat(now(), "hh:mm:ss")#&lt;p&gt;
	&lt;/cflock&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;/cfoutput&gt;</code></pre>
<p>If you run this simple code, you&#8217;ll see that the lock is not honored and the threads in each frame are run simultaneously.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/how-cflock-doesnt/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

