<?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"
	>

<channel>
	<title>Cranky Bit</title>
	<atom:link href="http://blog.crankybit.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.crankybit.com</link>
	<description>Take a byte out of tech!</description>
	<pubDate>Tue, 17 Nov 2009 18:03:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Line Debugging Causes CF to Not Start</title>
		<link>http://blog.crankybit.com/line-debugging-causes-cf-to-not-start/</link>
		<comments>http://blog.crankybit.com/line-debugging-causes-cf-to-not-start/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 18:01:24 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[How To]]></category>

		<category><![CDATA[ColdFusion cf9 troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=335</guid>
		<description><![CDATA[So you go to turn on line debugging in ColdFusion, and when you save your changes, it warns you that the ColdFusion service will fail to start if the debugging port is already in use. Great, but what do you do if this actually happens?
I was at a loss for a few minutes on how [...]]]></description>
			<content:encoded><![CDATA[<p>So you go to turn on line debugging in ColdFusion, and when you save your changes, it warns you that the ColdFusion service will fail to start if the debugging port is already in use. Great, but what do you do if this actually happens?</p>
<p>I was at a loss for a few minutes on how to get ColdFusion started again so that I could fix the issue. Well, the configuration change is in your ColdFusion installation under ~/runtime/bin/jvm.config. So on a typical Windows installation, it may be c:\coldfusion9\runtime\bin\jvm.config. </p>
<p><strong><em>Note: Before proceeding, it is always good practice to make a copy of the config file before editing it.</em></strong></p>
<p>In jvm.config, there is an &#8220;Arguments to VM&#8221; section that has a java.args setting that may start with something like this:</p>
<p><font face="courier new, courier, mono">java.args=-Xdebug -Xrunjdwp:transport=dt_socket, server=y, suspend=n, address=5095 -server -Xmx512m</font></p>
<p><em>(There will likely be many more arguments as well.)</em></p>
<p>The first two arguments contain the debugging settings that are probably preventing ColdFusion from starting. Remove the <font face="courier new, courier, mono">-Xdebug</font> and<br />
<font face="courier new, courier, mono">-Xrunjdwp:transport</font> arguments, so that the beginning of the line will now look like this:</p>
<p><font face="courier new, courier, mono">java.args=-server -Xmx512m</font> <em>(and additional arguments&#8230;)</em></p>
<p>This will be enough to get ColdFusion to start up. You can then go into ColdFusion Administrator to either change the debugging port or turn off the line debugging.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/line-debugging-causes-cf-to-not-start/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Notes: Improved Flash Remoting and Adobe AIR Integration in ColdFusion 9</title>
		<link>http://blog.crankybit.com/notes-max09-improved-flash-remoting-and-air-in-cf9/</link>
		<comments>http://blog.crankybit.com/notes-max09-improved-flash-remoting-and-air-in-cf9/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 00:57:25 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[AIR]]></category>

		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[MAX2009]]></category>

		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=334</guid>
		<description><![CDATA[These notes are taken at Adobe MAX 2009.
You can use HTTPService, WebService, RemoteObject components in Flex to pull data in different ways. Now what about ColdFusion 9?
ColdFusion&#8217;s Flash Remoting has been improved. So Flash applications that have ColdFusion 9 as a backend will interact much faster, and it can handle circular references.
There is now direct [...]]]></description>
			<content:encoded><![CDATA[<p>These notes are taken at Adobe MAX 2009.</p>
<p>You can use HTTPService, WebService, RemoteObject components in Flex to pull data in different ways. Now what about ColdFusion 9?</p>
<p>ColdFusion&#8217;s Flash Remoting has been improved. So Flash applications that have ColdFusion 9 as a backend will interact much faster, and it can handle circular references.</p>
<p>There is now direct data translation between ActionScript and CF types, instead of previously having an intermediate Java layer that handled this. This involves changes in services-config.xml, but no code changes are required in your apps. Support for the old style remoting is still present for backward compatibility.</p>
<p>So how much faster is it? Drastically faster. Easily x9 faster, and that increases as the number of transactions occurs, according to the whitepaper Adobe has released about it.</p>
<p><strong>BlazeDS.</strong> ColdFusion 9 is now integrated with BlazeDS as the default installation.</p>
<p><strong>Configuration File.</strong> Services-Config.xml is now split into 4 files. There are a handful of ColdFusion-specific properties under the channel definition now. An &#8220;enable-small-messages&#8221; property is there and should be set to &#8220;false&#8221;. This is important for the new Flash Remoting in CF9, because BlazeDS&#8217;s default is &#8220;true&#8221;. </p>
<p>There is an AMFChannel component in Flex for the new Flash Remoting (Note: You can alternatively tell the AMFChannel component to have enableSmallMessages=&#8221;false&#8221;). Finally, the endpoint class is changed for the new CF9 one.</p>
<p><strong>Offline AIR apps with ColdFusion 9</strong></p>
<p>Now the fun stuff. ColdFusion 9 has an ORM for AIR! Build offline AIR apps without the SQL mess and conflict handling. There is a CF-AIR persistent framework for SQLite on the client side. CF keeps track of all updates to local database and synchronizes with the server, including conflict resolution.</p>
<p>By having ORM on the client- and server-side, these two are integrated through the CF-AIR persistent framework.</p>
<p>In the application code for the demo, there were customer.cfc and address.cfc persistent objects. Then a sync CFC is used for providing the fetch and sync functions for communication with the AIR client.</p>
<p>Step #1: Create the persistent CFCs.</p>
<p>Step #2: Create the sync CFC. He called it custmgr.cfc. The CFC has implements=&#8221;ISyncManager&#8221; as an attribute. Then you have fetch() and sync() methods that handle the transactions. Here you can provide your logic for handling certain scenarios, such as conflicts.</p>
<p>Step #3: On client side, create equivalent AS classes that map to the CFC via the [RemoteClass(alias=&#8221;")] metadata tag.</p>
<p>Step #4: Use the CF-built AIR libraries provided to fetch data from server, with the SyncManager component. It&#8217;s very simple, practically just point it to the sync CFC and do a fetch() method. To work with the database, you then openSession() and can create new AS objects and call save() on the session to insert/update/etc.  Finally, using commit() will commit the results and invoke the sync() process.</p>
<p>On the client side, it can receive conflict notification and receive both versions of the data so that you can decide what to do with the conflict.</p>
<p>It is very exciting to have some help implementing synchronization without having to purchase LCDS. Using the CF9/AIR integration libraries will be very nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/notes-max09-improved-flash-remoting-and-air-in-cf9/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Notes: Advanced ORM in ColdFusion 9</title>
		<link>http://blog.crankybit.com/notes-max09-advanced-orm-cf9/</link>
		<comments>http://blog.crankybit.com/notes-max09-advanced-orm-cf9/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 23:30:55 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[MAX2009]]></category>

		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=333</guid>
		<description><![CDATA[These are notes from Adobe MAX 2009 about advanced ORM in ColdFusion 9.
Join Mapping. You can have a CFC whose primary table is &#8220;Person&#8221;, but it has properties that fetch values from a joined table, such as the &#8220;City&#8221; property from an &#8220;Address&#8221; table. Interesting.
ORM Initialization. When application first starts, it looks to see if [...]]]></description>
			<content:encoded><![CDATA[<p>These are notes from Adobe MAX 2009 about advanced ORM in ColdFusion 9.</p>
<p><strong>Join Mapping.</strong> You can have a CFC whose primary table is &#8220;Person&#8221;, but it has properties that fetch values from a joined table, such as the &#8220;City&#8221; property from an &#8220;Address&#8221; table. Interesting.</p>
<p><strong>ORM Initialization.</strong> When application first starts, it looks to see if ORM is enabled. If so, it creates/loads the Hibernate configuration, the loads Hibernate mapping files, searches for persistent CFCs (you can point it at only a particular directory to speed things up), generate Hibernate mapping for persistent CFCs, then even generate the schema on the database if it doesn&#8217;t exist, and then finally build the Hibernate Session Factory. Once this is done, it will not occur again unless you tell it to, because this initial setup is an expensive operation. You can use ormReload() to force it.</p>
<p><strong>ORM Session.</strong> All ORM operations happen in the session. It provides some simple caching. The session tracks changes made to the objects. So it doesn&#8217;t actually execute SQL until a session is flushed, which happens when the request completes or when you force it with ormFlush().</p>
<p>When using CFTRANSACTION, the Hibernate session will be flushed and closed at the end of your CFTRANSACTION.</p>
<p><strong>Object States.</strong> When you create an object with EntityNew(), CreateObject(), etc, the object is transient and is not known by Hibernate yet. Once an object is saved or loaded, it is in a persistent state. The kicker is &#8220;detached&#8221; objects. If the Hibernate session ends, and object that you have will become &#8220;detached&#8221; since the session ended. So if you have lazy loading for your object, for instance, it will throw an error because Hibernate has nowhere to lazy load the object&#8217;s data. However, you can use EntityMerge() or redo an EntityLoad() to bring it back into a persistent state.</p>
<p><strong>Concurrency Control.</strong> You can use the &#8220;optimisticlock&#8221; attribute of a CFC to &#8220;All&#8221;, &#8220;Dirty&#8221;, &#8220;Version&#8221;, or &#8220;None&#8221; to control how record updates occur. &#8220;Version&#8221; is the default which uses a timestamp to check the version of the record vs. the object. &#8220;All&#8221; does a where statement of all record fields, and &#8220;Dirty&#8221; only handles the changed fields.</p>
<p><strong>Fetching strategy.</strong> How will you fetch relationships of tables? &#8220;Immediate&#8221;, &#8220;Lazy&#8221;, &#8220;Eager&#8221;, or &#8220;Batch&#8221; fetching. &#8220;Immediate&#8221; fetches everything immediately. The default &#8220;Lazy&#8221; fetches things on demand. &#8220;Eager&#8221; fetching fetches everything in a single SQL statement, good for frequently used one-to-one relationships. There was a bit of confusion in regard to &#8220;Batch&#8221; fetching.</p>
<p><strong>Caching.</strong> Session-level cache fetches data the first time and will not reload subsequent requests. EntityReload() will force a reload. Secondary-level cache can cache data across Hibernate sessions. It can be in-memory, disk, clustered. They have the default caching engine as EHCache.</p>
<p>How to use secondary cache? Enable it first. In application.cfc, use ormsettings.secondarycacheenabled=&#8221;true&#8221;. Then in your ORM CFC, the cacheuse=&#8221;" attribute defines the caching strategy (such as &#8220;read-only&#8221;, the most performant), and cachename=&#8221;" defines the name of this specific cache.</p>
<p>Secondary cache can also be used on relationships. And when using ormExecuteQuery() functions to use HQL to query the database, you can cache as well with cacheable=&#8221;true&#8221; as one of the options. This can be used in EntityLoad() too.</p>
<p>When cleaning up caches, there are ormEvictXXX() functions to remove entities, collections, and queries.</p>
<p><strong>Event Handling.</strong> Hibernate lets you set ormsettings.eventhandling=&#8221;true&#8221; to have many CFC level events, like preLoad(), postLoad(), preInsert(), postInsert(), preLoad(), postLoad(), etc. This can be used for logging or other nifty features. Wow! That&#8217;s awesome. Nice hooks.</p>
<p><strong>Interesting user questions.</strong> One gentleman asked about using an XML file as a datasource through Hibernate. That would be interesting to try/use.</p>
<p>This session could have been 90 minutes. There are a lot of advanced things that can be done with the ColdFusion integration with Hibernate from the ColdFusion API.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/notes-max09-advanced-orm-cf9/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Notes: Managing, Monitoring, and Upgrading Your ColdFusion Servers</title>
		<link>http://blog.crankybit.com/notes-max09-managing-monitoring-upgrading-cf-servers/</link>
		<comments>http://blog.crankybit.com/notes-max09-managing-monitoring-upgrading-cf-servers/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 22:13:23 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[MAX2009]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=332</guid>
		<description><![CDATA[These are notes from Adobe MAX 2009. This is what is new in ColdFusion Administrator for ColdFusion 9.
Mail. You can sign mail with a keystore. You can view undeliverable email by clicking a button instead of browsing to the directory on the server.
Document. You can configure ColdFusion to point to an OpenOffice installation on the [...]]]></description>
			<content:encoded><![CDATA[<p>These are notes from Adobe MAX 2009. This is what is new in ColdFusion Administrator for ColdFusion 9.</p>
<p><strong>Mail.</strong> You can sign mail with a keystore. You can view undeliverable email by clicking a button instead of browsing to the directory on the server.</p>
<p><strong>Document.</strong> You can configure ColdFusion to point to an OpenOffice installation on the server. This is necessary for a lot of the document integration features in ColdFusion.</p>
<p><strong>Data Collections.</strong> You can now have Verity <em>or</em> Solr collections. You can configure Solr in the Administrator. So ColdFusion 9 includes both Verity and Solr.</p>
<p><strong>Security.</strong> Since there are ColdFusion services (CFaaS) now, you can configure which IP addresses may use your server for these services.</p>
<p><strong>Server Monitor.</strong> The server monitor allows you to see how the server is using memory, which templates are running slow, the database pooling, how are template and database queries running, etc. </p>
<p><strong>Server Manager.</strong> A basic AIR app that provides a way to perform administrative functions on ColdFusion server(s). It provides a nice way to manage multiple servers at once. At the CF Unconference, this became a topic of light debate on Wednesday at lunch, because there are typical 1.0 weaknesses in the interface of the server manager that make it a little bit of a pain to use. But it is a great start, and hopefully the next iteration will be a little more fine-tuned.</p>
<p><strong>Migrating to CF9.</strong> Beware using these keywords: interface, pageencoding, finally, import, local. These are new CF9 keywords that will cause a conflict if your code was using them. BlazeDS now ships out of the box with CF9, which is great. LCDS Express Edition is no longer supported. It is recommended to upgrade from Verity to Solr. To do this, you&#8217;ll need to add engine=&#8221;solr&#8221; in your CFCOLLECTION tags. What&#8217;s more, the CFSEARCH tag will need some slight syntax changes when migrating to Solr! Ugh.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/notes-max09-managing-monitoring-upgrading-cf-servers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Notes: Migrating from Flex 3 to Flex 4</title>
		<link>http://blog.crankybit.com/notes-migrating-from-flex-3-to-flex-4/</link>
		<comments>http://blog.crankybit.com/notes-migrating-from-flex-3-to-flex-4/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 18:57:16 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[MAX2009]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=331</guid>
		<description><![CDATA[These are notes from Adobe MAX 2009. This session will help us see what problems we may encounter moving to Flex 4, as well as what new features we can use.
Packages. The old mx packages are still there. But now everything new is in the spark packages. Why two different packages? At first, they had [...]]]></description>
			<content:encoded><![CDATA[<p>These are notes from Adobe MAX 2009. This session will help us see what problems we may encounter moving to Flex 4, as well as what new features we can use.</p>
<p><strong>Packages.</strong> The old mx packages are still there. But now everything new is in the spark packages. Why two different packages? At first, they had them all in the same package, but the component had a prefix for the new version. It wasn&#8217;t received well. So instead, Adobe just put the new components in new namespaces.</p>
<p>The MX namespace is also called &#8220;Halo&#8221;. Don&#8217;t consider it a &#8220;legacy&#8221; namespace. These are still fully supported. Spark is all of the new stuff. The general MXML has a new 2009 namespace, but the legacy namespace is still supported.</p>
<p><strong>Graphics</strong></p>
<p>You can add graphic primitives enabling you to draw lines, ellipses, and curves, directly within the MXML. With the new FXG file format, you can import a graphic in as a vector graphic that appears as code. Cool. Using a static FXG image is great for icons or other static simple images, because its rendering is faster than an MXML graphic container.</p>
<p><strong>Flex States</strong></p>
<p>Instead of using AddChild and RemoveChild for changing states, you have includeIn=&#8221;" and excludeIn=&#8221;" attributes that go directly on components. What&#8217;s more, you can set various attributes of a component for the different states by using a dot notation. For instance, title.mystate=&#8221;Title&#8221;. This seems like a pretty drastic change.</p>
<p>With states, you have to use the OLD way with the 2006 namespace, and you have to use the NEW way with the 2009 namespace.</p>
<p><strong>Skinning</strong></p>
<p>Components all have separate skin files. This will allow you to create a custom skin for any component easily.</p>
<p><strong>Common migration issues</strong></p>
<p>Type selectors need namespaces now in your Flex CSS. For instance, if you&#8217;re styling a button, Flex doesn&#8217;t know if it is a Spark button or a Halo button. So you need to define the namespace in your stylesheet and update your selectors accordingly.</p>
<p>You must compile against Flash Player 10. This won&#8217;t be an issue if you use Flash Builder 4 with Flex 4.</p>
<p>Application.application should now be renamed to FlexGlobals.topLevelApplication. Just a direct rename.</p>
<p>RSLs are on by default.</p>
<p>The &#8220;Declarations&#8221; tag is a problem child. In Flex 4, anything that is not a display object or default property must be within the fx:Declarations tag. Even tags like RadioButtonGroup. Formatters, Effects, RPC stuff, Validators, etc. need to go in the Declarations.</p>
<p>&#8220;If Looks Could Kill.&#8221; The default theme is now Spark, which looks different than the old Halo theme. You can switch back to the Halo theme. To do so, turn on &#8220;Use Flex 3 compatibility mode&#8221; in the project properties, or go into the &#8220;Flex Theme&#8221; panel and change the theme (this is the preferred way).</p>
<p>If moving to Flex 4, try to use as many Spark components as you can. They <em>should</em> play nicely with MX components. You can intermix them together. Caveats: (1) The graphic primitives cannot go in an MX component, just wrap them with a group; (2) you cannot put MX components in Spark containers; (3) MX effects do not work on Spark graphic primitives; (4) MX navigators (ViewStack, Accordion, etc) should use NavigatorContent component.</p>
<p>Other things to watch out for:</p>
<ul>
<li>Spark components don&#8217;t support the Halo theme.</li>
<li>Cannot create spark component based itemRenderers for MX List based components</li>
<li>APIs between MX and Spark components are different (e.g. addChild vs. addElement)!</li>
<li>When using MX and Spark components together, you may see a text difference since they are themed differently. There is a TLFText theme that can help with this.</li>
</ul>
<p>So, migrating an app from Flex 3 to Flex 4 is a bit of a slippery slope. And even just beginning to use Flex 4 with current Flex 3 knowledge will require a bit of a slowdown as you undo some of those brain synapses to do things the new Flex 4 way. But these changes going forward are good for the Flex framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/notes-migrating-from-flex-3-to-flex-4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Notes: What&#8217;s New in ColdFusion 9</title>
		<link>http://blog.crankybit.com/notes-max09-whats-new-in-coldfusion-9/</link>
		<comments>http://blog.crankybit.com/notes-max09-whats-new-in-coldfusion-9/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 17:36:30 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[MAX2009]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=330</guid>
		<description><![CDATA[These are notes from Adobe MAX 2009. The talk was given by Adam Lehman.
First, ColdFusion 9 also introduces the new ColdFusion Builder product, an Eclipse-based IDE &#8220;to rule them all&#8221;. Because it is based on Eclipse, you can also combine other products, like Flash Builder, so that one IDE gets the job done for everything, [...]]]></description>
			<content:encoded><![CDATA[<p>These are notes from Adobe MAX 2009. The talk was given by Adam Lehman.</p>
<p>First, ColdFusion 9 also introduces the new <strong>ColdFusion Builder</strong> product, an Eclipse-based IDE &#8220;to rule them all&#8221;. Because it is based on Eclipse, you can also combine other products, like Flash Builder, so that one IDE gets the job done for everything, whether it is HTML, CFML, JS, Flex, ActionScript, CSS, etc.</p>
<p>ColdFusion Builder also supports some interesting server integration features. You can access ColdFusion Administrator and other functionality right from ColdFusion Builder; you can see and browse all of the databases that ColdFusion has datasources for. With such functionality, you can do cool stuff like auto-generate ORM-based CFCs by pointing it to an existing database table! Now, it doesn&#8217;t generate <em>just</em> the bean CFC. It generates the entire service layer: DAO and Gateway beans as well!! Now, this obviously is just a starter step. It&#8217;s expected that you&#8217;d tweak it from that point. With the Flash Builder integration, you can take this to the next step by also generating ActionScript objects to help with Flex integration as well.</p>
<p><strong>CFML Enhancements</strong></p>
<p>Well, in CF7, they introduced Application.cfc that supported hooks for application events. But now in CF9, there is a Server.cfc with an onServerStart() method for handling that event.</p>
<p>Various other holes have been filled. You can now have nested CFTRANSACTION tags. Error catching now supports &#8220;finally&#8221;. And looping now supports CFCONTINUE.</p>
<p>Variable level enhancements: You can now pass implicit structures/arrays to tags and functions. Before you had to assign it to a var and then pass it. There is assignment chaining (a=b=c). Direct access to elements of returned arrays (i.e. myFunction()[x] couldn&#8217;t be done previously). And, finally, ternary operators! For instance, you can do something like:  a = (b&lt;c)?b:c</p>
<p>CFSCRIPT enhancements. Starting in CF9, you can now write 100% script-based code, including classes/components.</p>
<p>CFC enhancements. There is now an explicit LOCAL scope. Instead of doing var myvar=1, you can do LOCAL.myvar=1.  What&#8217;s more, you can declare a variable with <em>var</em> anywhere in the code, not just at the top. CFCs also support implicit getters/setters by using the CFPROPERTY tag. These are worth using if there is no special handling going on, because they&#8217;re 7x faster than your own getters/setters.</p>
<p>Here&#8217;s an awesome feature. You no longer have to use CreateObject() to create a CFC. You can use the IMPORT keyword to point to a directory of CFCs and have them be first-class citizens in your code. And you can use the NEW keyword to create CFCs, like user = new User(). Looking more Java-like all the time.</p>
<p><strong>How to convince your boss to upgrade</strong> </p>
<p>First, with CFIMAP, you can now access email with IMAP support, such as GMail.</p>
<p>There are many PDF support enhancements. Create PDF packages, add/remove headers and footers, optimize PDFs (down-sample images, for instance), extract text/images, high-quality thumbnails, convert Word documents to PDF.</p>
<p>There are presentation options. The CFPRESENTATION tag will generate PPT files from CFML/HTML content. And you can go the other way: Convert PPT <em>to</em> HTML or Flash. Supports Microsoft PowerPoint &#8216;97 to &#8216;08 and Open Office Presentations.</p>
<p>Spreadsheet support. The CFSPREADSHEET helps you create, read, and merge native Excel spreadsheets. This isn&#8217;t just a CSV file. This is a real Excel spreadsheet with formulas and formatting support.</p>
<p>SharePoint integration. Native access to SharePoint data and services (Sites, templates, sub-sites, web parts, and workspaces). You can get lists including data, views, and alerts and querying against lists. Users, permissions, site groups, cross-site groups, security groups, and distribution groups. Build web parts with CFML. Integrate with SharePoint Single sign-on. You may wonder, &#8220;Why is this necessary since SharePoint has web services and exposes information as XML?&#8221; Because it&#8217;s painful. ColdFusion makes it significantly easier and faster.</p>
<p>ColdFusion Server Manager. A Flex-based AIR application that helps you manage multiple ColdFusion servers. And it receives system notifications and alerts. Helps apply settings for multiple servers.</p>
<p><strong>The next generation of applications</strong></p>
<p>Coldfusion 9 ORM functionality. Powered by the Java Hibernate framework, so it is industry standard. Various ormXXX() and entityXXX() functions provide this functionality for you. With this feature, no more SQL is necessary, so apps can be developed faster (and potentially with fewer errors). CFCs will just be automagically saved. But it&#8217;s not <em>just</em> a matter of saving time on development; it also makes it so that your app is no longer database-dependent. It can point to any database server and it should just work.</p>
<p>Enhanced caching. ColdFusion is already pretty optimized for speed (esp. between CF7 to CF8). So to get more speed, developers need to use these new caching features. Using cacheGet(), cachePut(), and cacheGetMetaData(), you can save/retrieve objects from a built-in cache. Page fragment caching allows you to have a combination of static and dynamic content on a page. This provides a HUGE performance boost, depending on what you&#8217;re doing. For instance, you only want to generate a menu dynamically the first time, but then another area of the page is dynamic every time.</p>
<p>Performance gains. Okay, Adam lied. ColdFusion 9 is actually 40% faster than ColdFusion 8, with no changes to code, just upgrading ColdFusion. CFC creation is 8x faster, method invocation is 3x faster. And UUID creation is 100x faster. These are some huge bottlenecks that have been blown away. There is a performance brief that Adobe will be releasing on ColdFusion 9 in the near future.</p>
<p>Search engine. ColdFusion 9 now includes Apache Solr. Verity is still included, but so is Solr, which is actually even faster than Verity. So you may choose to upgrade to Solr! They even provide a Verity-to-Solr migration utility.</p>
<p>ColdFusion Server API. You can have direct access to ColdFusion services for CFCHART, CFDOCUMENT, CFPDF, CFIMAGE, and more. This makes it even easier to access ColdFusion mail/pdf/images services directly within Flex without having to custom code some ColdFusion code.</p>
<p>What&#8217;s more, Flash Remoting is 9x faster. It may arguably be the fastest flash remoting server-side technology around.</p>
<p>There are various JavaScript/Ajax tags, like CFMAP for Google Maps, CFMESSAGEBOX, CFSLIDER, and more. Ajax functionality in CF is powered by ExtJS 3.0 (which is nice, because ExtJS isn&#8217;t free anymore, so getting CF9 gets you a copy of ExtJS basically), and JQuery is also supported.</p>
<p>This presentation was very rapid fire, which is testimony to how feature-rich of an upgrade ColdFusion 9 is.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/notes-max09-whats-new-in-coldfusion-9/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Notes: What&#8217;s Coming in AIR 2</title>
		<link>http://blog.crankybit.com/notes-max09-whats-coming-in-air-2/</link>
		<comments>http://blog.crankybit.com/notes-max09-whats-coming-in-air-2/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 00:32:09 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[AIR]]></category>

		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[MAX2009]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=329</guid>
		<description><![CDATA[These are notes taken at MAX 2009. This is obviously subject to change before AIR 2 is launched.
Multi-touch gestures. This is especially useful for Flash&#8217;s new ability to compile down to iPhone, but it will even work on tablets or laptops that support multi-touch, such as the track pad on MacBooks.
Opening Files. There is now [...]]]></description>
			<content:encoded><![CDATA[<p>These are notes taken at MAX 2009. This is obviously subject to change before AIR 2 is launched.</p>
<p><strong>Multi-touch gestures.</strong> This is especially useful for Flash&#8217;s new ability to compile down to iPhone, but it will even work on tablets or laptops that support multi-touch, such as the track pad on MacBooks.</p>
<p><strong>Opening Files.</strong> There is now a File.openWithDefaultApplication() method which does just what it says. So you can open data document of any type in its native app from your AIR app, i.e. open a Word document in Word from your AIR app. Executables are blacklisted, such as *.exe, *.bat, or other executables.</p>
<p><strong>File &#8220;downloaded&#8221;.</strong> You can use myFile.downloaded=true to set the bit on a file that will notify the user with a message like, &#8220;This file has been downloaded from the Internet. Are you sure you want to open it?&#8221; the first time it opens.</p>
<p><strong>Volume Detection.</strong> Listen for mounting and unmounting of volumes. Query system for volume info. So this gives you the ability to work with external volumes including optical media or attached cameras.</p>
<p><strong>Native processes.</strong> You can start native processes outside of AIR, or even reference it and launch it. This includes passing in arguments and utilizing stdin, stdout, stderr! Now, you can&#8217;t use this ability from an app that has been installed straight from an AIR file. You have to have the app in a native installer. This way, someone on a Mac won&#8217;t try to run an app that wants to run a Windows executable, or something similar. In the demo, the Mac screenshot process was invoked, and in another demo, Spotlight functionality was invoked and its output was incorporated into the app!</p>
<p><strong>File promises.</strong> Ability to tell the OS about files you don&#8217;t have yet. Gives you the ability to drag and drop files in cases when they are on the network or Internet.</p>
<p><strong>Listening on a socket.</strong> Ability for inter-application communication. Better protocol support (such as FTP). Networking utilities. You just use ServerSocket.bind() and ServerSocket.listen() methods in conjunction with an event listener to act on activity. Demonstrated it with an HTTP proxy app called HTTPeek (on Google Code). Very fast. Handles the socket connection well.</p>
<p><strong>Advanced Networking.</strong> Get network information. Support for IPv6. UDP support. A DNS resolver. More coming.</p>
<p><strong>Audio Encoding.</strong> Surprisingly, this wasn&#8217;t supported before. Now you can encode data directly from the microphone.</p>
<p><strong>Global Error Handling.</strong> You can now catch all uncaught errors and error events in your app. This is useful because on a client that does not have the debugger version of Flash, the app will just stop working. With this global error handling feature, you can log the errors to a file or over the network, or do other things.</p>
<p><strong>Accessibility.</strong> Functionality from Flash Player 10 will now be supported in AIR. It has 28 accessible Flex components, supporting MSAA (Microsoft Active Accessibility) in JAWS or Microsoft Narrator, for example.</p>
<p><strong>JavaScript Profiling.</strong> Can access profiling information via Aptana.</p>
<p><strong>Optimization.</strong> Lower memory consumption, lower CPU utilization especially when the app is idle.</p>
<p><strong>Misc.</strong> Improved printing. SQLite supports nested transactions. Exit even on shutdown (can now see when the event is not cancelable). Various WebKit enhancements.</p>
<p>Flex 3 will work for AIR 2, but Flex 4 with Flash Builder 4 will be a cleaner, more set up approach for developing AIR 2. You&#8217;ll have to overlay AIR 2 SDK on your Flex Builder 3 installation if you want to develop for AIR 2 in Flex 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/notes-max09-whats-coming-in-air-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Importance of Understanding Factories, Part 2: Transient Factories</title>
		<link>http://blog.crankybit.com/factories-2/</link>
		<comments>http://blog.crankybit.com/factories-2/#comments</comments>
		<pubDate>Tue, 05 May 2009 06:01:04 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[General Web Dev.]]></category>

		<category><![CDATA[factories]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=327</guid>
		<description><![CDATA[In my last post, I discussed some of the mistakes that can be made when using ColdSpring as our factory. It became evident that using ColdSpring to inject transient objects&#8212;that is, objects that have a state for a momentary use and then are discarded&#8212;into our service objects or other related singletons is problematic. This is [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post, I discussed some of the <em>mistakes</em> that can be made when using ColdSpring as our factory. It became evident that using ColdSpring to inject transient objects&mdash;that is, objects that have a state for a momentary use and then are discarded&mdash;into our service objects or other related singletons is problematic. This is largely due to the concurrency issue with reusing that injected bean in the service object's methods, and mistakes that can be made if we forget about objects being <em>passed by reference</em>. Ray Camden also discussed this recently in <a href="http://www.coldfusionjedi.com/index.cfm/2009/5/1/ColdFusion-and-Pass-by-Reference-versus-Value" target="_blank">ColdFusion and Pass by Reference versus Value</a>.</p>
<p><strong>The answer is to build a transient factory for those beans.</strong> We can do it without losing the benefits of ColdSpring's dependency and configuration management. <em>And</em> it doesn't take much to make a factory. Take a look at this sample that works with my previous post's code.</p>
<div class="igBar"><span id="lcfm-5"><a href="#" onclick="javascript:showCodeTxt('cfm-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-5">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;">&lt;cfcomponent&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #808080; font-style: italic; background-color:#FFFF99;">&lt;!----------------- Constructor ----------------------&gt;</span></span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"init"</span> returntype=<span style="color: #009900;">"BeanFactory"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.config=<span style="color: #0000FF;">StructNew</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> this /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #808080; font-style: italic; background-color:#FFFF99;">&lt;!------------------ Config --------------------------&gt;</span></span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"setConfig"</span> returntype=<span style="color: #009900;">"void"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"Settings"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"struct"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.config=arguments.settings /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"getConfig"</span> returntype=<span style="color: #009900;">"struct"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> variables.config /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #808080; font-style: italic; background-color:#FFFF99;">&lt;!--------------- Create Methods ---------------------&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"createBean"</span> returntype=<span style="color: #009900;">"any"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> <span style="color: #000000; font-weight: bold;">var</span> com=<span style="color: #0000FF;">CreateObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"component"</span>,<span style="color: #009900;">"Bean"</span><span style="color: #0000FF;">&#41;</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> com.setConfig<span style="color: #0000FF;">&#40;</span>getConfig<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> com.init<span style="color: #0000FF;">&#40;</span>argumentCollection=arguments<span style="color: #0000FF;">&#41;</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;/cfcomponent&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The factory has a <code>setConfig()</code> method, just like the Bean does, and can be used to conveniently inject all configuration information with ColdSpring. Now, let's look at the <code>createBean()</code> method where the action is. It performs 3 key actions: <strong>(a)</strong> Create a fresh object. <strong>(b)</strong> Pass in configuration. <strong>(c)</strong> Call the <code>init()</code> method and return the object.</p>
<p>Our ColdSpring file can now be rewritten like this:</p>
<div class="igBar"><span id="lxml-6"><a href="#" onclick="javascript:showCodeTxt('xml-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-6">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"BeanService"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.BeanService"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;constructor</span>-arg <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"BeanFactory"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">"BeanFactory"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/constructor</span>-arg<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"BeanFactory"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.BeanFactory"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Config"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;map<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"dsn"</span><span style="font-weight: bold; color: black;">&gt;</span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>MyDSN<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/entry<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/map<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>See, we use the same XML for injecting configuration, it's just injected it into <code>BeanFactory</code>. We then inject <em>BeanFactory</em> into <code>BeanService</code>, instead of the Bean itself. It can use the factory to get a fresh bean whenever it needs one&mdash;properly instantiated and configured.</p>
<p>An example of <code>BeanService</code> tweaked to accept and use the factory:</p>
<div class="igBar"><span id="lcfm-7"><a href="#" onclick="javascript:showCodeTxt('cfm-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-7">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cfcomponent</span> <span style="color: #0000FF">hint</span>=<span style="color: #009900;">"Handles beans."</span> output=<span style="color: #009900;">"false"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"init"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"BeanFactory"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"BeanFactory"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.BeanFactory=Arguments.BeanFactory /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> this /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"workWithBean"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000099;"><span style="color: #990000;">&lt;cfscript&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> myBean=variables.BeanFactory.createBean<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; myBean.setX<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"I changed X on the bean!"</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; myBean.setY<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"I changed Y on the bean!"</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; return myBean;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #990000;">&lt;/cfscript&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #990000;">&lt;/cffunction&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #990000;">&lt;/cfcomponent&gt;</span> </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Let's make the factory better.</strong> First, your app probably has more than one type of transient object. You don't need a separate transient factory for each type of object. Just have a different <code>create<em>BeanName</em>()</code> method for each object type, with creation code specific for each object. And if your objects are all essentially created with the same conventions, you can handle create methods for all of them with a single onMissingMethod handler. Something like this:</p>
<div class="igBar"><span id="lcfm-8"><a href="#" onclick="javascript:showCodeTxt('cfm-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-8">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #808080; font-style: italic; background-color:#FFFF99;">&lt;!--- Create Methods ---&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"onMissingMethod"</span> returntype=<span style="color: #009900;">"any"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"MissingMethodName"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"MissingMethodArguments"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000099;"><span style="color: #990000;">&lt;cfscript&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0000FF;">method</span>=Arguments.MissingMethodName ;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> args=Arguments.MissingMethodArguments ;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> classList=<span style="color: #009900;">"MyBean,DiffBean,AnotherBean"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> className=<span style="color: #0000FF;">RemoveChars</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">method</span>,<span style="color: #FF0000;color:#800000;">1</span>,<span style="color: #FF0000;color:#800000;">6</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> com=<span style="color: #009900;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #0000FF;">&#40;</span> <span style="color: #0000FF;">Left</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">method</span>,<span style="color: #FF0000;color:#800000;">6</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF">=</span>=<span style="color: #009900;">"create"</span> &amp;&amp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ListFindNoCase</span><span style="color: #0000FF;">&#40;</span>classList,className<span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000FF;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; com=<span style="color: #0000FF;">CreateObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"component"</span>,className<span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; com.setConfig<span style="color: #0000FF;">&#40;</span>getConfig<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">StructKeyExists</span><span style="color: #0000FF;">&#40;</span>com,<span style="color: #009900;">"setFactory"</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; com.setFactory<span style="color: #0000FF;">&#40;</span>this<span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; return com.init<span style="color: #0000FF;">&#40;</span>argumentCollection=args<span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000FF;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #990000;">&lt;/cfscript&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #990000;">&lt;/cffunction&gt;</span> </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>See how the first <code>if</code> statement checks to make sure the method is a valid method name: One that starts with "create" and ends with an acceptable class name as we define in our <code>classList</code> variable. So this onMissingMethod handler will work with <code>createMyBean()</code>, <code>createDiffBean()</code>, and <code>createAnotherBean()</code>. Note how it also checks for the existence of a <code>setFactory()</code> method in the object it creates. If it is there, it will use the method to inject itself into the new object! This is a simple example of how autowiring is accomplished.</p>
<p><strong>Take it even <em>further!</em></strong> Head over to Paul Marcotte's blog post, <a href="http://www.fancybread.com/blog/post.cfm/A-Coldfusion-Transient-Factory-Example" target="_blank">A Coldfusion Transient Factory Example</a>, which shows how to make a very generic transient factory that receives configuration on which classes it should create through ColdSpring. Very cool stuff.</p>
<p><strong>Review.</strong> Transient factories don't require a lot of code, and are a vital step to simplifying and centralizing our instantiation and configuration of transient objects, or objects that have a state. Doing so doesn't negate the need for ColdSpring, in fact it complements it as it was intended, since ColdSpring works well with instantiation of singletons, and transient factories as described here are used as singletons. By utilizing ColdSpring and a transient factory, we can be well on our way to cleaner and more organized development.</p>
<p><strong>Get the files.</strong> Download sample code to play with: <a href='/wp-content/uploads/2009/05/coldspringbeantest.zip'>ColdSpring Bean Test</a>. It walks us through the issues discussed in the previous post as well as using transient factories like we just discussed.</p>
<p>This post has gotten pretty long, so I'll save the race condition demonstration for "Part 3". <img src='http://blog.crankybit.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/factories-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Importance of Understanding Factories, Part 1: ColdSpring Misunderstandings</title>
		<link>http://blog.crankybit.com/factories-1/</link>
		<comments>http://blog.crankybit.com/factories-1/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 13:33:26 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[General Web Dev.]]></category>

		<category><![CDATA[ColdSpring]]></category>

		<category><![CDATA[factories]]></category>

		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=326</guid>
		<description><![CDATA[As ColdFusion developers progress in the use of object oriented programming concepts with CFCs, our applications become more flexible and able to support additional interfaces such as Ajax or Flex through web services. We also potentially benefit just from overall code maintainability, extensibility, and reusability by using best practices and design patterns common in OOP. [...]]]></description>
			<content:encoded><![CDATA[<p>As ColdFusion developers progress in the use of object oriented programming concepts with CFCs, our applications become more flexible and able to support additional interfaces such as Ajax or Flex through web services. We also potentially benefit just from overall code maintainability, extensibility, and reusability by using best practices and design patterns common in <abbr title="object-oriented programming">OOP</abbr>. </p>
<p>The benefits are many, but there are certainly pitfalls along the way. Perhaps we're ready to begin using service objects. And we'd like to create and pass in our transient objects with ColdSpring as a factory for all objects.</p>
<p>Let's cover the groundwork of our example, and then consider a pitfall. Here's our transient object:</p>
<p><strong>Bean.cfc</strong></p>
<div class="igBar"><span id="lcfm-13"><a href="#" onclick="javascript:showCodeTxt('cfm-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-13">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cfcomponent</span> <span style="color: #0000FF">hint</span>=<span style="color: #009900;">"Represents a bean."</span> output=<span style="color: #009900;">"false"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"init"</span> <span style="color: #0000FF">access</span>=<span style="color: #009900;">"public"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returntype=<span style="color: #009900;">"Bean"</span> output=<span style="color: #009900;">"false"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"x"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"any"</span> <span style="color: #0000FF">required</span>=<span style="color: #009900;">"true"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"y"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"any"</span> <span style="color: #0000FF">required</span>=<span style="color: #009900;">"true"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"z"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"any"</span> <span style="color: #0000FF">required</span>=<span style="color: #009900;">"true"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> setX<span style="color: #0000FF;">&#40;</span>arguments.x<span style="color: #0000FF;">&#41;</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> setY<span style="color: #0000FF;">&#40;</span>arguments.y<span style="color: #0000FF;">&#41;</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> setZ<span style="color: #0000FF;">&#40;</span>arguments.z<span style="color: #0000FF;">&#41;</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> this /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #808080; font-style: italic; background-color:#FFFF99;">&lt;!------------------- Config -------------------------&gt;</span></span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"setConfig"</span> <span style="color: #0000FF">access</span>=<span style="color: #009900;">"public"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output=<span style="color: #009900;">"false"</span> returntype=<span style="color: #009900;">"void"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF">hint</span>=<span style="color: #009900;">"Method to pass in configs."</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"Settings"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"struct"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.instance.config=arguments.settings/<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #808080; font-style: italic; background-color:#FFFF99;">&lt;!------------------ Setters -----------------------&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"setX"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"newval"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.instance.<span style="color: #0000FF;">data</span>.x=arguments.newval /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"setY"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"newval"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.instance.<span style="color: #0000FF;">data</span>.y=arguments.newval /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"setZ"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"newval"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.instance.<span style="color: #0000FF;">data</span>.z=arguments.newval /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #808080; font-style: italic; background-color:#FFFF99;">&lt;!------------------ Getters -----------------------&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"getMemento"</span> <span style="color: #0000FF">access</span>=<span style="color: #009900;">"public"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returntype=<span style="color: #009900;">"struct"</span> output=<span style="color: #009900;">"false"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> variables.instance /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;/cfcomponent&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This is an overly-simplified example of a bean. It just has 3 properties (X, Y, Z) and corresponding setter methods. It also has a typical <code>init()</code> method, a <code>setConfig()</code> method to pass in configuration, and a getter method so we can quickly dump the state of the object. It'll be enough for our samples.</p>
<p>Perhaps we might write a ColdSpring configuration like this:</p>
<div class="igBar"><span id="lxml-14"><a href="#" onclick="javascript:showCodeTxt('xml-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-14">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"BeanService"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.BeanService"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;constructor</span>-arg <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Bean"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">"Bean"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/constructor</span>-arg<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"Bean"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.Bean"</span> <span style="color: #000066;">singleton</span>=<span style="color: #ff0000;">"false"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Config"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;map<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"dsn"</span><span style="font-weight: bold; color: black;">&gt;</span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>MyDSN<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/entry<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/map<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;constructor</span>-arg <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"x"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>One<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/constructor</span>-arg<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;constructor</span>-arg <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"y"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>Two<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/constructor</span>-arg<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;constructor</span>-arg <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"z"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>Three<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/constructor</span>-arg<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This seems like it should work, eh? We're instantiating a service object, instantiating and configuring a bean, and passing the bean into the service object. Here's a really simple example of the bean service object:</p>
<p><strong>BeanService.cfc</strong></p>
<div class="igBar"><span id="lcfm-15"><a href="#" onclick="javascript:showCodeTxt('cfm-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-15">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cfcomponent</span> <span style="color: #0000FF">hint</span>=<span style="color: #009900;">"Handles beans."</span> output=<span style="color: #009900;">"false"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"init"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"Bean"</span> /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> variables.Bean=Arguments.Bean /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> this /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"getBean"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> variables.Bean /<span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"workWithBean"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000099;"><span style="color: #990000;">&lt;cfscript&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> myBean=variables.Bean;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; myBean.setX<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"I changed X on the bean!"</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; myBean.setY<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"I changed Y on the bean!"</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; return myBean;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #990000;">&lt;/cfscript&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #990000;">&lt;/cffunction&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #990000;">&lt;/cfcomponent&gt;</span> </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This BeanService object has a constructor that receives the bean and stores it in its variables scope. It then has a the <code>getBean()</code> method so we can see the bean, and a <code>workWithBean()</code> method that simulates doing some work with the bean.</p>
<p><strong><em>And now, the pitfall: ColdSpring singletons and objects passed by reference.</em></strong></p>
<p>This code technically runs, and appears fine: The Bean instance that we pass into the service is <em>not</em> a singleton, so each BeanService we instantiate (<em>if</em> we were to instantiate multiple) would have a separate Bean instance. And <code>workWithBean()</code> appears to use a local var copy of Bean.</p>
<p>Wrong. </p>
<p>First, the <a target="_blank" href="http://www.coldspringframework.org/coldspring/examples/quickstart/index.cfm?page=singletons">Singleton vs. Transient Objects With ColdSpring</a> page explains that ColdSpring isn't ideal for generating transient components. Its overhead is more appropriate for less frequent creation of components that typically go in a shared scope, such as in the Application scope. Performance aside, though, the approach of injecting a transient bean into a singleton like BeanService does technically work.</p>
<p>So now the second point, how BeanService is working with Bean in our example <code>workWithBean()</code> method. The key misunderstanding is that CFCs like the Bean object are <em>passed by reference</em> when being assigned to variables. So when we do <code>var myBean=variables.Bean</code>, the local myBean variable is pointing to the same copy of Bean that <code>variables.Bean</code> points to. When it executes methods that change the bean's state, the one copy of Bean is being altered. Whoah, that wasn't an intended behavior. This could have very negative consequences, with Bean not being in the state you might expect it to be in.</p>
<p>So, how to fix it? Hmm. I don't want to use <code>CreateObject()</code> because that would become a dependency we'd have to manage, and we'd have to handle properly configuring the bean. This was the whole point of injecting the bean with ColdSpring in the first place.</p>
<p>Well, a quick solution could be to just use <code>Duplicate()</code> to make a copy of the injected bean before working on it! So, we could replace our <code>workWithBean()</code> method with this:</p>
<div class="igBar"><span id="lcfm-16"><a href="#" onclick="javascript:showCodeTxt('cfm-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-16">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"workWithBean"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000099;"><span style="color: #990000;">&lt;cfscript&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> myBean=<span style="color: #0000FF;">Duplicate</span><span style="color: #0000FF;">&#40;</span>variables.Bean<span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myBean.setX<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"I changed X on the bean!"</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myBean.setY<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"I changed Y on the bean!"</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; return myBean;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #990000;">&lt;/cfscript&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #990000;">&lt;/cffunction&gt;</span> </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now, <code>variables.Bean</code> will always be the pristine, original bean injected by ColdSpring, and the local myBean variable will perform its work with a duplicate of that bean. Our code will now be working the way we intended; disaster has been averted.</p>
<p>Well, this <em>does</em> work. But it is neither graceful nor efficient, and it is <em>not</em> recommended. Consider Sean Corfield's blog post, <a href="http://corfield.org/blog/index.cfm/do/blog.entry/entry/duplicate_is_bad_for_your_objects_health" target="_blank">Duplicate() is Bad For Your (Object's) Health</a>. In an informal test, he clocked Duplicate() as being drastically slower&mdash;we're talking 50 to 1&mdash;than using <code>CreateObject()</code>. </p>
<p>Ugh. If we're back to using <code>CreateObject()</code>, what good is using ColdSpring for managing these component relationships, and what about dealing with configuration? <strong><em>Enter the world of factories.</em></strong> Yes, ColdSpring itself is a factory, but <em>it is a factory oriented around creating and configuring our singletons,</em> which can <em>include other factories</em> whose purpose is to properly create transient objects like Bean. </p>
<p>So instead of having ColdSpring inject Bean into BeanService, we can make a BeanFactory and inject <em>that</em> into BeanService, giving BeanService the ability to create Beans to work with any time it needs to. This may seem like a lot of effort, but we'll come to see that creating transient factories is easy and will clean up the mess of an architecture in this sample to something graceful and maintainable.</p>
<p>In this post, I described a few of the <em>mistakes</em> that can be made as we start to utilize ColdSpring. Hopefully these mistakes point to the importance of factories&mdash;not just ColdSpring, but our own transient factories as well. In the next blog post, we'll rework the sample to use a factory and review the benefits the factory provides and how it doesn't duplicate the purpose of ColdSpring. We'll review one more scenario that underscores the importance of factories: the dreaded race condition. And I'll provide source code that has executable demonstrations of these undesirable mistakes in action. <img src='http://blog.crankybit.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/factories-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPtouch</title>
		<link>http://blog.crankybit.com/wptouch/</link>
		<comments>http://blog.crankybit.com/wptouch/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 12:14:28 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Site Configuration]]></category>

		<category><![CDATA[iPod/iPhone]]></category>

		<category><![CDATA[Apple]]></category>

		<category><![CDATA[iPhone]]></category>

		<category><![CDATA[JQuery]]></category>

		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=324</guid>
		<description><![CDATA[I have another blog that I use entirely for my own note-taking and reference, and I very frequently refer to my notes on my iPhone. Safari on the iPhone renders the pages wonderfully, but it is a bit of a pain to have to zoom in on the text of the page. This is when [...]]]></description>
			<content:encoded><![CDATA[<p>I have another blog that I use entirely for my own note-taking and reference, and I very frequently refer to my notes on my iPhone. Safari on the iPhone renders the pages wonderfully, but it <u>is</u> a bit of a pain to have to zoom in on the text of the page. This is when I realized an iPhone-optimized version of the blog would be so nifty.</p>
<p><a href="http://www.bravenewcode.com/wptouch/" target="_blank">WPtouch</a> is the <em>best</em> solution for <a href="http://wordpress.org/" target="_blank">WordPress</a> blogs. It's as simple as a plugin installation, and it is very decently polished.</p>
<p>It renders in "mobile" mode only for iPhone/iPod/Android clients. It has an option for those clients to still view the site in "normal" mode. It uses <a href="http://jquery.com/" target="_blank">JQuery</a> for various AJAX and visual effects. It just works and looks good while doing it, and I've recently installed it on this blog as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/wptouch/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get a Struct or Array in That Simple Value Field</title>
		<link>http://blog.crankybit.com/struct-in-simple-value-field/</link>
		<comments>http://blog.crankybit.com/struct-in-simple-value-field/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 14:11:49 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=322</guid>
		<description><![CDATA[In some environments and scenarios, I used to use initialization (*.ini) files for storing simple configuration settings. Now I typically store this kind of information in a ColdSpring configuration file, or at least in an XML file of some sort. But at times I have to live (and work) with the apps I wrote that [...]]]></description>
			<content:encoded><![CDATA[<p>In some environments and scenarios, I used to use initialization (*.ini) files for storing simple configuration settings. Now I typically store this kind of information in a ColdSpring configuration file, or at least in an XML file of some sort. But at times I have to live (and work) with the apps I wrote that use *.ini configuration files.</p>
<p><strong>The nice thing about *.ini files.</strong> Not that they're all bad. It's ridiculously easy to extract settings from these files with ColdFusion. For instance:</p>
<div class="igBar"><span id="ltext-21"><a href="#" onclick="javascript:showCodeTxt('text-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">TEXT:</span>
<div id="text-21">
<div class="text">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">&#91;</span>Settings<span style="">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mysetting=Hello</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">anothersetting=Goodbye </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>To retrieve the <em>mysetting</em> configuration setting, I just make one call:</p>
<div class="igBar"><span id="lcfm-22"><a href="#" onclick="javascript:showCodeTxt('cfm-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-22">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">x=GetProfileString(pathToFile,&quot;Settings&quot;,&quot;mysetting&quot;); </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It can't get much easier than that to retrieve a value from a configuration file!</p>
<p><strong>The bad thing about *.ini files.</strong> The only problem is that these files are restricted to name=value pairs of simple values. You may go into a project with no need for configuration settings that are any more complicated than simple numbers or strings, but what about 3 years from now when the business logic now could use some structs or arrays in the configuration?</p>
<p>Of course, you could change your whole configuration methodology when--and if--that time comes, but ugh. Using XML (especially in conjunction with IoC such as ColdSpring) is so much more scalable. The future you will thank you.</p>
<p>But it's too late. You and I already have complex app XYZ that is using *.ini config files, and you need to add feature X without rebuilding the configuration logic of the app. What to do?</p>
<p><strong>Embed a string representation of your struct or array in the config file!</strong> After all, ColdFusion 8 allows implicit struct and array creation, right? Well, half-right. Doing something like x=Evaluate(myStructString) just isn't allowed by ColdFusion. </p>
<p>However, we <em>can</em> effectively do the same thing with <strong>JSON</strong> representations of structs and arrays. So, try this:</p>
<div class="igBar"><span id="ltext-23"><a href="#" onclick="javascript:showCodeTxt('text-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">TEXT:</span>
<div id="text-23">
<div class="text">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">&#91;</span>Settings<span style="">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mysetting=<span style="">&#123;</span>&quot;one&quot;:&quot;Hello&quot;,&quot;two&quot;:&quot;Goodbye&quot;<span style="">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">anothersetting=Yomomma </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now, retrieving <em>mysetting</em> with GetProfileString() will still get you a string, but using JSON functions built into ColdFusion 8 will get you a struct:</p>
<div class="igBar"><span id="lcfm-24"><a href="#" onclick="javascript:showCodeTxt('cfm-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-24">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">x=GetProfileString(pathToFile,&quot;Settings&quot;,&quot;mysetting&quot;);</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myStruct=DeserializeJSON(x); </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Your <em>myStruct</em> variable will be a struct with two keys ("one" and "two") just as you would expect from the JSON. </p>
<p>You could achieve similar results using XmlParse(), but in a case like this, the less verbose, the better. And JSON is less verbose than XML.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/struct-in-simple-value-field/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reset Access Datasources Without Resetting ColdFusion</title>
		<link>http://blog.crankybit.com/reset-access-ds-not-cf/</link>
		<comments>http://blog.crankybit.com/reset-access-ds-not-cf/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 16:30:44 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[How To]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=323</guid>
		<description><![CDATA[I am "stuck" with a few web applications that provide web front-ends to Access databases. I am not the owner of these databases, and for various reasons, the database owner will not upgrade it to SQL Server.  Alas, this sometimes causes headaches like the following.
The Access databases are on a network fileserver. Occasionally, this [...]]]></description>
			<content:encoded><![CDATA[<p>I am "stuck" with a few web applications that provide web front-ends to Access databases. I am not the owner of these databases, and for various reasons, the database owner will not upgrade it to SQL Server.  Alas, this sometimes causes headaches like the following.</p>
<p>The Access databases are on a network fileserver. Occasionally, this server goes down or resets, and ColdFusion's datasource connection to the database gets stuck in a disrupted state. I've come to learn two things you can try to get ColdFusion's connection to the Access datasource working again without resetting the entire ColdFusion Application Server service, which is obviously disruptive to your entire site and all of its applications.</p>
<ol>
<li><strong>Reset the ODBC services.</strong> The ColdFusion ODBC services (such as "ColdFusion 8 ODBC Agent" and "ColdFusion 8 ODBC Server") actually handle the ODBC connections to DataDirect driver databases such as Microsoft Access databases. This is handy. Just reset these services and often connectivity is restored.</li>
<li><strong>Use the "Disable Connections" option in the datasource configuration.</strong> If you are using JDBC drivers (for instance, perhaps to <a href="/msaccess2007-and-cf8/">connect to Microsoft Access 2007 databases</a>), resetting the ColdFusion 8 ODBC Server service won't help. Darn. However, if you go into the datasource's configuration in ColdFusion Administrator, you can check the "Disable Connections" checkbox and submit the change. This will force ColdFusion to disconnect from the database. Immediately go back in and uncheck the checkbox and submit again. Your datasource will now have connectivity reestablished without a ColdFusion restart!</li>
</ol>
<p>Happy days! The second option won't be helpful to you if you have many, many datasources. However, this is better than a ColdFusion reset that would disrupt all of your apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/reset-access-ds-not-cf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CFExecute Output Not Going in Your Variable?</title>
		<link>http://blog.crankybit.com/cfexecute-output-in-var/</link>
		<comments>http://blog.crankybit.com/cfexecute-output-in-var/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 17:29:34 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=321</guid>
		<description><![CDATA[I'm blogging this because it's a little tidbit I always waste about 30 minutes figuring out before I remember it.
The &#60;cfexecute&#62; tag can return the output of the execution into a variable if you supply one with the variable="" attribute. However, I will try to do this, and (a) the script returns too quickly, and [...]]]></description>
			<content:encoded><![CDATA[<p>I'm blogging this because it's a little tidbit I always waste about 30 minutes figuring out before I remember it.</p>
<p>The &lt;cfexecute&gt; tag can return the output of the execution into a variable if you supply one with the variable="" attribute. However, I will try to do this, and <strong>(a)</strong> the script returns too quickly, and <strong>(b)</strong> there is no output when there should be.</p>
<p>There is an easy solution! &lt;cfexecute&gt; is expecting the timeout="" attribute. Supply it a timeout value in seconds, and it will then wait for the script to finish executing and thus have output to store in your variable.</p>
<p>You may be wondering why this is necessary, because even without the timeout="" attribute, the execution still occurs. &lt;cfexecute&gt; just doesn't return any output. That's because &lt;cfexecute&gt; is indeed running, it is just immediately timing out--effectively giving up on the executed process--and thus not returning the output. By supplying a timeout, ColdFusion hangs around waiting for the process to complete before returning its output.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/cfexecute-output-in-var/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Generating a Decrypted Memento for a Transfer Decorator</title>
		<link>http://blog.crankybit.com/generating-a-decrypted-memento-for-a-transfer-decorator/</link>
		<comments>http://blog.crankybit.com/generating-a-decrypted-memento-for-a-transfer-decorator/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 12:57:27 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[General Web Dev.]]></category>

		<category><![CDATA[How To]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[Transfer]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=319</guid>
		<description><![CDATA[In my last blog post, I discussed how to efficiently handle multiple encrypted fields while using Transfer. The key was using onMissingMethod in the Transfer decorator. However, what about when we use the memento with Transfer's getMemento() method? This approach can be especially handy to quickly transfer an object's properties when using web services to [...]]]></description>
			<content:encoded><![CDATA[<p>In my last blog post, I discussed how to efficiently handle multiple encrypted fields while using Transfer. The key was using onMissingMethod in the Transfer decorator. However, what about when we use the memento with Transfer's getMemento() method? This approach can be especially handy to quickly transfer an object's properties when using web services to Flex or AJAX front ends.</p>
<p>For reference, here was the object definition we were using in our sample Transfer configuration.</p>
<div class="igBar"><span id="lxml-27"><a href="#" onclick="javascript:showCodeTxt('xml-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-27">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Reg"</span> <span style="color: #000066;">table</span>=<span style="color: #ff0000;">"Regs"</span> <span style="color: #000066;">decorator</span>=<span style="color: #ff0000;">"MyProj.com.Reg"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"ID"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegID"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"numeric"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"FName"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegFName"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"LName"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegLName"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"LastMod"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"date"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegLastMod"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Expires"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"date"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegExpires"</span> <span style="color: #000066;">nullable</span>=<span style="color: #ff0000;">"true"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncHome"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regHome"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncWork"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regWork"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncMobile"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regMobile"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncSMS"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regSMS"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The process is very simple. Recall that we prefixed our Transfer properties with "Enc" to know which fields are encrypted. Let's create a getDecryptedMemento() method. It will loop through all of the keys in the memento, which is just a struct, and decrypt any of the encrypted fields, saving them as new keys in the struct (i.e. "EncHome" is decrypted as "Home" in the struct). </p>
<p>Something like this will do the trick:</p>
<div class="igBar"><span id="lcfm-28"><a href="#" onclick="javascript:showCodeTxt('cfm-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-28">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"getDecryptedMemento"</span> <span style="color: #0000FF">access</span>=<span style="color: #009900;">"public"</span> returntype=<span style="color: #009900;">"struct"</span> output=<span style="color: #009900;">"false"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> <span style="color: #000000; font-weight: bold;">var</span> memento=getMemento<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> <span style="color: #000000; font-weight: bold;">var</span> key=<span style="color: #009900;">""</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> <span style="color: #000000; font-weight: bold;">var</span> newkey=<span style="color: #009900;">""</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfloop</span> <span style="color: #0000FF">index</span>=<span style="color: #009900;">"key"</span> <span style="color: #0000FF">list</span>=<span style="color: #009900;">"#StructKeyList(memento)#"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfif</span> <span style="color: #0000FF;">Left</span><span style="color: #0000FF;">&#40;</span>key,<span style="color: #FF0000;color:#800000;">3</span><span style="color: #0000FF;">&#41;</span> is <span style="color: #009900;">"Enc"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> newkey=<span style="color: #0000FF;">RemoveChars</span><span style="color: #0000FF;">&#40;</span>key,<span style="color: #FF0000;color:#800000;">1</span>,<span style="color: #FF0000;color:#800000;">3</span><span style="color: #0000FF;">&#41;</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfset</span> memento<span style="color: #0000FF;">&#91;</span>newkey<span style="color: #0000FF;">&#93;</span>=decryptValue<span style="color: #0000FF;">&#40;</span>memento<span style="color: #0000FF;">&#91;</span>key<span style="color: #0000FF;">&#93;</span><span style="color: #0000FF;">&#41;</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cfif&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;/cfloop&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfreturn</span> memento&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;/cffunction&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Not much to it. Note that we would use the same decryption function as we are using in onMissingMethod for the dynamic accessors. I'm calling it decryptValue() for this sample.</p>
<p>In the end, our getDecryptedMemento() method returns a memento that looks just like the Transfer-generated getMemento() output, with decrypted versions of the encrypted fields!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/generating-a-decrypted-memento-for-a-transfer-decorator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Handling Multiple Encrypted Fields in a Transfer Decorator</title>
		<link>http://blog.crankybit.com/multiple-encrypted-fields-in-a-transfer-decorator/</link>
		<comments>http://blog.crankybit.com/multiple-encrypted-fields-in-a-transfer-decorator/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 12:55:55 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[General Web Dev.]]></category>

		<category><![CDATA[How To]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[Transfer]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=318</guid>
		<description><![CDATA[I had a recent project that had multiple fields in a particular table that needed to be encrypted for privacy and security considerations. I was using Transfer for the project. The typical way to handle the encryption is to create custom accessor methods in a decorator component. The Transfer wiki has a decent explanation of [...]]]></description>
			<content:encoded><![CDATA[<p>I had a recent project that had multiple fields in a particular table that needed to be encrypted for privacy and security considerations. I was using <a href="http://docs.transfer-orm.com/" target="_blank">Transfer</a> for the project. The typical way to handle the encryption is to create custom accessor methods in a <a href="http://en.wikipedia.org/wiki/Decorator_pattern" target="_blank">decorator</a> component. The Transfer wiki has a decent explanation of this concept on a page entitled <a href="http://docs.transfer-orm.com/wiki/How_to_Encrypt_User_Passwords_Using_a_Decorator.cfm" target="_blank">How to Encrypt User Passwords Using a Decorator</a>. However, it is intentionally simple, demonstrating a single property. Multiply your getter/setter methods by how many properties you will be working with, and the lines of code can add up. This framework stuff is supposed to prevent that kind of repetition! Well, utilizing onMissingMethod() and the core concept on the Transfer decorator example, we can handle this scenario efficiently.</p>
<p>First, let's consider the object definition in our sample Transfer configuration file.</p>
<div class="igBar"><span id="lxml-31"><a href="#" onclick="javascript:showCodeTxt('xml-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-31">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Reg"</span> <span style="color: #000066;">table</span>=<span style="color: #ff0000;">"Regs"</span> <span style="color: #000066;">decorator</span>=<span style="color: #ff0000;">"MyProj.com.Reg"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"ID"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegID"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"numeric"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"FName"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegFName"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"LName"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegLName"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"LastMod"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"date"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegLastMod"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Expires"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"date"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"RegExpires"</span> <span style="color: #000066;">nullable</span>=<span style="color: #ff0000;">"true"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncHome"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regHome"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncWork"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regWork"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncMobile"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regMobile"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"EncSMS"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"regSMS"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Note that I have prefixed the Transfer properties with "Enc". This isn't required, but will simplify our processing later on. So in this sample, we have 4 properties: Home, Work, Mobile, and SMS. The concept is that these are client phone numbers that we want to protect with encryption. So, Transfer will generate getEncHome(), getEncWork(), getEncMobile(), getEncSMS(), and corresponding setters. However, we want to provide getHome(), getWork(), getMobile(), getSMS(), and corresponding setters, that get and set the properties <em>after</em> encryption/decryption.</p>
<p><strong>Use onMissingMethod()</strong></p>
<p>To accomplish this, we might have an onMissingMethod() function in the decorator like this:</p>
<div class="igBar"><span id="lcfm-32"><a href="#" onclick="javascript:showCodeTxt('cfm-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-32">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cffunction</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"onMissingMethod"</span> <span style="color: #0000FF">access</span>=<span style="color: #009900;">"public"</span> returntype=<span style="color: #009900;">"any"</span> output=<span style="color: #009900;">"false"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"missingMethodName"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"string"</span> <span style="color: #0000FF">required</span>=<span style="color: #009900;">"true"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #333333;"><span style="color: #990000;">&lt;cfargument</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"missingMethodArguments"</span> <span style="color: #0000FF;">type</span>=<span style="color: #009900;">"struct"</span> <span style="color: #0000FF">required</span>=<span style="color: #009900;">"true"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000099;"><span style="color: #990000;">&lt;cfscript&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> func=<span style="color: #009900;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> encList=<span style="color: #009900;">"Home,Mobile,SMS,Work"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0000FF;">method</span>=Arguments.missingMethodName;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> args=Arguments.missingMethodArguments;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> firstArg=args<span style="color: #0000FF;">&#91;</span><span style="color: #0000FF;">ListFirst</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">StructKeyList</span><span style="color: #0000FF;">&#40;</span>args<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> prop=<span style="color: #0000FF;">RemoveChars</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">method</span>,<span style="color: #FF0000;color:#800000;">1</span>,<span style="color: #FF0000;color:#800000;">3</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Handle encryption/decryption of encrypted values:</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #0000FF;">&#40;</span> <span style="color: #0000FF;">ListFindNoCase</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"get,set"</span>,<span style="color: #0000FF;">Left</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">method</span>,<span style="color: #FF0000;color:#800000;">3</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span> and </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ListFindNoCase</span><span style="color: #0000FF;">&#40;</span>encList,prop<span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000FF;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; func=variables<span style="color: #0000FF;">&#91;</span><span style="color: #0000FF;">Insert</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">"Enc"</span>,<span style="color: #0000FF;">method</span>,<span style="color: #FF0000;color:#800000;">3</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #0000FF;">&#40;</span> <span style="color: #0000FF;">Left</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">method</span>,<span style="color: #FF0000;color:#800000;">3</span><span style="color: #0000FF;">&#41;</span> is <span style="color: #009900;">"get"</span><span style="color: #0000FF;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; return decryptValue<span style="color: #0000FF;">&#40;</span>func<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; func<span style="color: #0000FF;">&#40;</span>encryptValue<span style="color: #0000FF;">&#40;</span>firstArg<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000FF;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #990000;">&lt;/cfscript&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #990000;">&lt;/cffunction&gt;</span> </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As a good security measure, we use an "encList" string to check that only proper methods can be called. Then we examine the method name. If it starts with "get" or "set" and ends with one of the list items, we proceed. Thus, we'll process a method like getHome(), but not a method like getFoo(). We then call getEncHome() and decrypt it for getters, encrypt and call setEncHome() for setters. </p>
<p><strong>Dynamic Method Calling</strong></p>
<p>But alas, how do we do this dynamically without a long if-then-else chain? We call the proper method by referencing it from the component's variables scope. Terrence Ryan describes this in his blog post <a href="http://www.terrenceryan.com/blog/post.cfm/cheap-and-easy-dynamic-method-calling-in-cfscript" target="_blank">Cheap and Easy Dynamic Method Calling in CFScript</a>. We construct the method name, in our case, by inserting "Enc" after the "get" or "set" prefix of the method name passed into onMissingMethod (thus "getHome" becomes the Transfer method "getEncHome"). Assign the function to the local "func" variable, then call it as if "func" was the function. Finally, handle any encryption or decryption that you will be doing. For this sample, I have encryptValue() and decryptValue() methods handling the details of that work.</p>
<p><strong>Summary</strong></p>
<p>We've used two solutions to handle multiple encrypted fields in the decorator. First, we used onMissingMethod() to handle processing of all of the properties in a single method. Then, we used dynamic method calling to call the Transfer-generated accessors within onMissingMethod().</p>
<p>The end result is being able to use setHome(), getHome(), etc. with the encryption and decryption being handled automatically. Great!</p>
<p>In addition to accessors, we may sometimes want to use the object's memento with the Transfer method getMemento(). In my next blog post, I'll demonstrate how that process can also be done very efficiently.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/multiple-encrypted-fields-in-a-transfer-decorator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Loose Cables Cause Sporadic Behavior in Computers</title>
		<link>http://blog.crankybit.com/loose-cables-cause-sporadic-behavior-in-computers/</link>
		<comments>http://blog.crankybit.com/loose-cables-cause-sporadic-behavior-in-computers/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 13:22:25 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Macintosh]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=315</guid>
		<description><![CDATA[Loose cables and electronics are bad. In electronics as sophisticated as computers, they can cause really odd behavior!
My wife's Mac Mini was exhibiting odd behavior, namely, sporadic loss of sound. The internal speaker would suddenly become unavailable to the operating system. Furthermore, the speakers did have a slight hum when they were plugged into the [...]]]></description>
			<content:encoded><![CDATA[<p>Loose cables and electronics are bad. In electronics as sophisticated as computers, they can cause really odd behavior!</p>
<p>My wife's Mac Mini was exhibiting odd behavior, namely, sporadic loss of sound. The internal speaker would suddenly become unavailable to the operating system. Furthermore, the speakers did have a slight hum when they were plugged into the Mac Mini. I had opened the Mac Mini up a couple times to upgrade the RAM, so I figured I must have inadvertently pulled the audio line. A few months later, the Mac Mini just outright refused to start up. I'd push the power button, I could hear it power on, but there was no startup chime and no boot-up. I figured the Mac had finally died, but I naturally wasn't going to give up on it without an autopsy.</p>
<p>If you've ever looked at a <a href="http://www.methodshop.com/gadgets/tutorials/macmini-ram/index.shtml" target="_blank">tutorial on opening the Mac Mini</a>, you know it isn't the worst thing ever, but it definitely is more complicated than opening, say, a Mac Pro, or really any tower computer. One of the challenges is separating the top chassis, since it is connected with a few cables. One of these is a ribbon in the back, and this ribbon is what was giving me trouble. Take a look at the photo below.</p>
<p style="text-align: center;"><a title="This connector was loose, thus the ribbon was not securely fastened." rel="lightbox" href="http://blog.crankybit.com/wp-content/uploads/2008/11/cimg3666.jpg"><img class="alignnone size-medium wp-image-316 glossy" title="The Loose Connector" src="http://blog.crankybit.com/wp-content/uploads/2008/11/cimg3666-300x225.jpg" alt="This connector was loose, thus the ribbon was not securely fastened." width="300" height="225" /></a></p>
<p style="text-align: left;">As you can see, the connector was actually in the open position, so the ribbon was sitting loosely in the connector, sporadically losing its connection and wreaking havoc on the system. The ribbon must have eventually pulled away enough so that the computer couldn't start up at all.</p>
<p style="text-align: left;">Here's the ribbon properly inserted and the connector closed shut:</p>
<p style="text-align: center;"><a title="The ribbon properly inserted and the connector closed shut." rel="lightbox" href="http://blog.crankybit.com/wp-content/uploads/2008/11/cimg3668.jpg"><img class="alignnone size-medium wp-image-317 glossy" title="Properly inserted and closed shut." src="http://blog.crankybit.com/wp-content/uploads/2008/11/cimg3668-300x225.jpg" alt="The ribbon properly inserted and the connector closed shut." width="300" height="225" /></a></p>
<p style="text-align: left;">The Mac started fine after that, and it hasn't had any startup or sound problems since.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/loose-cables-cause-sporadic-behavior-in-computers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Separating a Large Repository</title>
		<link>http://blog.crankybit.com/separating-large-repo/</link>
		<comments>http://blog.crankybit.com/separating-large-repo/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 12:52:45 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[Batch Scripting]]></category>

		<category><![CDATA[How To]]></category>

		<category><![CDATA[Subversion]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=312</guid>
		<description><![CDATA[A few months ago, I posted an article about combining multiple Subversion repositories into one large repository. Some folks have expressed an interest in doing the opposite--separating one large repository into multiple smaller repositories. The process is not without its quirks, but it can be done.
At first glance, you'd conclude the process would work much [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I posted an article about <a href="http://blog.crankybit.com/combining-repos/">combining multiple Subversion repositories into one large repository</a>. Some folks have expressed an interest in doing the opposite--separating one large repository into multiple smaller repositories. The process is not without its quirks, but it can be done.</p>
<p>At first glance, you'd conclude the process would work much the same way: Loop through the individual directories in the large repository, create smaller repositories for each one, then dump and import the contents of each directory into its small repository.</p>
<p>The tricky part is that the Subversion dump command dumps everything in the repository, by revision. In order to pull just a single directory, you must filter a complete dump with the "svndumpfilter" command. <a href="http://allmybrain.com/2007/10/15/using-piped-svndumpfilter-commands-to-separate-an-svn-repository/" target="_blank">This blog post</a> by <a href="http://allmybrain.com/" target="_blank">AllMyBrain.com</a> basically explains how to accomplish this in Linux. I usually have to work on a Windows box on the job, so I wrote up a script to accomplish this in a Windows batch script.</p>
<p>The strategy is the same as the Linux script, though. We're going to use "svnadmin dump" the large repository, then use "svndumpfilter" to filter by just the directory we want, then "svnadmin load" the results into the newly created repository. All of this can be combined into a single statement via piping:</p>
<div class="igBar"><span id="ldos-35"><a href="#" onclick="javascript:showCodeTxt('dos-35'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">DOS:</span>
<div id="dos-35">
<div class="dos">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">svnadmin dump c:\my\large\repo\ |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">svndumpfilter include MyDirectory |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">svnadmin load MySmallRepo\MyDirectory </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This will make a little more sense when we look at the full script. Let's just put it out there and then go through it.</p>
<div class="igBar"><span id="ldos-36"><a href="#" onclick="javascript:showCodeTxt('dos-36'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">DOS:</span>
<div id="dos-36">
<div class="dos">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.ss64.com/nt/set.html"><span style="color: #b1b100; font-weight: bold;">SET</span></a> <span style="color: #448844;">SmallRepoPath</span>=c:\SmallRepos</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.ss64.com/nt/set.html"><span style="color: #b1b100; font-weight: bold;">SET</span></a> <span style="color: #448844;">PathToRepo</span>=c:\BigRepo</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.ss64.com/nt/set.html"><span style="color: #b1b100; font-weight: bold;">SET</span></a> <span style="color: #448844;">UNCToRepo</span>=file:///c:/BigRepo</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.ss64.com/nt/set.html"><span style="color: #b1b100; font-weight: bold;">SET</span></a> <span style="color: #448844;">PathToChkout</span>=c:\BigRepoChkout</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mkdir %<span style="color: #448888;">PathToChkout</span>%</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">svn co %<span style="color: #448888;">uncToRepo</span>% %<span style="color: #448888;">PathToChkout</span>% --ignore-externals</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.ss64.com/nt/dir.html"><span style="color: #b1b100; font-weight: bold;">dir</span></a> /A:D /B %<span style="color: #448888;">PathToChkout</span>%&gt; %<span style="color: #448888;">PathToChkout</span>%\dirs.tmp</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.ss64.com/nt/for.html"><span style="color: #00b100; font-weight: bold;">for</span></a> /F %%i <a href="http://www.ss64.com/nt/in.html"><span style="color: #00b100; font-weight: bold;">in</span></a> <span style="color: #66cc66;">&#40;</span>%<span style="color: #448888;">PathToChkout</span>%\dirs.tmp<span style="color: #66cc66;">&#41;</span> <a href="http://www.ss64.com/nt/do.html"><span style="color: #00b100; font-weight: bold;">do</span></a> <span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.ss64.com/nt/if.html"><span style="color: #00b100; font-weight: bold;">if</span></a> <a href="http://www.ss64.com/nt/not.html"><span style="color: #000000; font-weight: bold;">not</span></a> %%i==.svn <span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.ss64.com/nt/echo.html"><span style="color: #b1b100; font-weight: bold;">echo</span></a> Processing &quot;%%i&quot;...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; mkdir %<span style="color: #448888;">SmallRepoPath</span>%\%%i</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; svnadmin create %<span style="color: #448888;">SmallRepoPath</span>%\%%i</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; svnadmin dump %<span style="color: #448888;">PathToRepo</span>% | svndumpfilter include %%i | svnadmin load %<span style="color: #448888;">SmallRepoPath</span>%\%%i</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">del %<span style="color: #448888;">PathToChkout</span>%\dirs.tmp</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rmdir /S /Q %<span style="color: #448888;">PathToChkout</span>% </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>First, we're setting our paths. "SmallRepoPath" will be the directory holding all of the small repositories we'll be creating. "PathToRepo" and "UNCToRepo" point to the big repository as DOS and UNC paths, respectively. "PathToChkout" points to a Subversion checkout of the large repository.</p>
<p>First, we check out the large repository with the "svn co" command. We do this just so that we can call the "dir /A:D /B" command, which says, "List just the directories in the checkout directory." We use that output to loop through each directory in the large repository.</p>
<p>Then, for each directory in the large repository, we create a corresponding small repository, then do our dump/filter/load combo. Again, we're dumping the contents of the large repository, using "svndumpfilter" to filter by directory, then loading that filtered dump into the new small repository.</p>
<p>Finally, we just do some cleanup by removing our temp files and the checkout directory.</p>
<p><strong>There <u>are</u> a few caveats with this code.</strong> </p>
<p>First, it will import <em>all</em> of the large repository's revisions into the smaller repository. There are svndumpfilter arguments to prevent this, such as --drop-empty-revs and --renumber-revs, but I found the Windows Subversion binaries to be problematic with these arguments. The end result is that you have more revision numbers than needed, but only the relevant data is actually imported into the repository, and viewing logs on just the imported directory will still obviously show revision logs related to that directory, so there's really little harm done.</p>
<p>Second, the dump/filter/load action doesn't always work on a directory that has been moved (copied/deleted) from another location within the large repository. What's worse, it won't <em>fail,</em> it just won't load any data into the small repository. To address this, use the --revision argument on the "svnadmin dump" command to do a dump starting at a revision after the move took place. Doing so will give the "svndumpfilter" command something it can work with.</p>
<p>This process is certainly more complicated to <em>explain</em>, but ultimately there's not that much more going on. Hopefully this explanation is helpful to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/separating-large-repo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Best Reason to Use CFQueryParam: Avoid Odd SQL Parsing by ColdFusion</title>
		<link>http://blog.crankybit.com/best-reason-to-use-cfqueryparam/</link>
		<comments>http://blog.crankybit.com/best-reason-to-use-cfqueryparam/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 19:02:29 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[General Web Dev.]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=314</guid>
		<description><![CDATA[After banging my head against the wall for a couple hours over an odd application error, I've finally come up with the best, most definitive reason to use &#60;cfqueryparam&#62; absolutely 100% of the time: It helps you avoid odd--dare I say erroneous--SQL parsing performed by ColdFusion in the &#60;cfquery&#62; tag. 
Huh? Say again?
That's right. In my [...]]]></description>
			<content:encoded><![CDATA[<p>After banging my head against the wall for a couple hours over an odd application error, I've finally come up with the best, most definitive reason to use &lt;cfqueryparam&gt; absolutely 100% of the time: It helps you avoid odd--dare I say erroneous--SQL parsing performed by ColdFusion in the &lt;cfquery&gt; tag. </p>
<p>Huh? Say again?</p>
<p>That's right. In <em>my </em>experience, anyway, the &lt;cfquery&gt; tag will erroneously parse the SQL and tag legitimate content as disallowed SQL. Let's take a look at an example.</p>
<p>Here's a basic query that inserts some HTML content into a field:</p>
<div class="igBar"><span id="lcfm-39"><a href="#" onclick="javascript:showCodeTxt('cfm-39'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-39">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cfquery</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"insertStuff"</span> <span style="color: #0000FF">datasource</span>=<span style="color: #009900;">"myDS"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;INSERT INTO myTable (fldTitle,fldContent) </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;VALUES ('Title','&amp;middot; Grant Deadline Extended')</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;/cfquery&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Never mind <em>why</em> you might do this; the point is that it is allowable SQL. There's just an HTML special entity in the string. However, ColdFusion 8 sees the semicolon followed by the word "GRANT", and if the GRANT statement is disallowed for the ColdFusion data source, ColdFusion will throw an error similar to: "Error Executing Database Query. Executing the SQL statement is not allowed."</p>
<p>Of course, there is no error in the SQL, and the same statement executes just fine when you run it at the command line or SQL Query Analyzer. ColdFusion is doing a security check by parsing the SQL and attempting to verify that the SQL statement(s) only use allowed SQL as defined for the data source in ColdFusion Administrator. </p>
<p>If a SQL keyword is not immediately following the semicolon, ColdFusion won't make this mistake. And naturally, if your data source is configured to allow the offending keyword (in my example, "GRANT"), it will execute the SQL and it will execute properly, not actually executing the grant statement. </p>
<p>But if my code had used &lt;cfqueryparam&gt;, this wouldn't have been an issue:</p>
<div class="igBar"><span id="lcfm-40"><a href="#" onclick="javascript:showCodeTxt('cfm-40'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CFM:</span>
<div id="cfm-40">
<div class="cfm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;cfquery</span> <span style="color: #0000FF;">name</span>=<span style="color: #009900;">"insertStuff"</span> <span style="color: #0000FF">datasource</span>=<span style="color: #009900;">"myDS"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;INSERT INTO myTable (fldTitle,fldContent) </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;VALUES (</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #333333;"><span style="color: #990000;">&lt;cfqueryparam</span> <span style="color: #0000FF;">value</span>=<span style="color: #009900;">"Title"</span> cfsqltype=<span style="color: #009900;">"cf_sql_varchar"</span><span style="color: #990000;">&gt;</span></span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #333333;"><span style="color: #990000;">&lt;cfqueryparam</span> <span style="color: #0000FF;">value</span>=<span style="color: #009900;">"&amp;middot; Grant Deadline Extended"</span> cfsqltype=<span style="color: #009900;">"cf_sql_varchar"</span><span style="color: #990000;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;)</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #333333;"><span style="color: #990000;">&lt;/cfquery&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This code will happily pass the SQL on to the database server. </p>
<p>This scenario may be a bit apparent when presented cleanly as I have here, but when the string being passed in is 3,000 characters or something similar, you're banging your head on the wall wondering what the heck is wrong with your query, especially when it has been working for years and now fails on just a single particular set of data. To my credit, the offending code is about 6 years old and all of my queries do indeed use &lt;cfqueryparam&gt; now. And more than ever, I'm now convinced to continue that habit. <img src='http://blog.crankybit.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>This oddity probably comes up rarely, but I'm sure someone else has or will experience this. I hope this post will help you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/best-reason-to-use-cfqueryparam/feed/</wfw:commentRss>
		</item>
		<item>
		<title>DST in cfexchangecalendar</title>
		<link>http://blog.crankybit.com/dst-in-cfexchangecalendar/</link>
		<comments>http://blog.crankybit.com/dst-in-cfexchangecalendar/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 14:54:44 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[General Web Dev.]]></category>

		<category><![CDATA[Adobe]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=313</guid>
		<description><![CDATA[I have an app that uses &#60;cfexchangecalendar&#62; to look at appointments in an Exchange calendar and display them on a form on a web page. Everything was going smoothly until the department called and notified me that new appointments they were entering were an hour off on the web app. The calendar in Outlook would [...]]]></description>
			<content:encoded><![CDATA[<p>I have an app that uses &lt;cfexchangecalendar&gt; to look at appointments in an Exchange calendar and display them on a form on a web page. Everything was going smoothly until the department called and notified me that new appointments they were entering were an hour off on the web app. The calendar in Outlook would say 11am, for instance, but my app would say 12pm. </p>
<p>After a little investigation, I came to realize that only new appointments with a date <em>after </em>daylight savings time ends were an hour off. Okay, that makes sense, but the query results returned by &lt;cfexchangecalendar&gt; don't provide any time zone information for me to properly handle the hour difference caused by DST!</p>
<p>As it turns out, Adobe has tracked this as Issue #70474, and the hot fix can be downloaded in <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403070" target="_blank">ColdFusion 8 Cumulative Hot Fix 3</a>. After applying the cumulative hot fix, &lt;cfexchangecalendar&gt; now returns the appointments exactly as they appear in Outlook.</p>
<p>It seems to me that it would be nice if the query results returns the GMT offset. But at least Adobe has addressed the inconsistency between the data ColdFusion retrieves and what Outlook displays.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/dst-in-cfexchangecalendar/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Avoiding the Password Prompt for SSH</title>
		<link>http://blog.crankybit.com/avoiding-the-password-prompt-for-ssh/</link>
		<comments>http://blog.crankybit.com/avoiding-the-password-prompt-for-ssh/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 16:22:11 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
		
		<category><![CDATA[How To]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[Open Source]]></category>

		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://blog.crankybit.com/?p=311</guid>
		<description><![CDATA[It's handy to establish an SSH key between machines so that SSH-related commands don't prompt you for a password. This is handy to quickly SSH into another machine, and it's even more handy when setting up SSH commands in automated scripts. For instance, you may want to execute some rsync statements in a script that [...]]]></description>
			<content:encoded><![CDATA[<p>It's handy to establish an SSH key between machines so that SSH-related commands don't prompt you for a password. This is handy to quickly SSH into another machine, and it's even more handy when setting up SSH commands in automated scripts. For instance, you may want to execute some rsync statements in a script that runs on a regular basis. It's better to have an established SSH key between the two machines than to have a password embedded in the script.</p>
<p>I recently reinstalled the OS on one of my Macs, and I've got backup scripts on my CentOS Linux box that use rsync to back up some pertinent data, so I had to reestablish the SSH key between the machines and had a hard time remembering how to do it. So this time I'm documenting what I had to re-learn.</p>
<p>First of all, there's a <a href="http://nixcraft.com/1196-post2.html" target="_blank">great post over at nixCraft</a> that basically explains how to do it. But allow me to explain more thoroughly, ahem, dumbed down to my level. </p>
<p>The key is remembering which machine is filling which role when you're reading the instructions. I'll call them the "Acting" machine--the one who is taking action and performing a command, let's say an rsync command--and the "Target" machine--the one who is being acted upon. In my case, the Linux server is the acting machine performing the rsync command, and my Mac is the target.</p>
<p>The process is simple. On the "Target" machine, generate a key, and then give that key to the "Acting" machine, which effectively gives it "permission" to login without the need to supply username/password credentials.</p>
<p>So, from the "Target" machine, in this case, my Mac, type the following command:</p>
<p>ssh-keygen -t rsa</p>
<p>This will generate a couple files that serve as a key for accessing the Mac. The ssh-keygen command may ask you where to store the key and what password to use. Just hit enter to use the default path and a blank password.</p>
<p>Next, still from the "Target" machine (my Mac), type:</p>
<p>ssh <em>MyUsername@ActingServer</em> "mkdir .ssh"<br />
scp .ssh/id_rsa.pub <em>MyUsername@ActingServer</em>:.ssh/authorized_keys2</p>
<p>In the code above, <em>MyUsername@ActingServer</em> would be the username and address (for instance, perhaps the IP address) of the "Acting" machine, in my case, the Linux server. In the first line, you're just creating the .ssh directory if it doesn't exist. In the second line, you're copying the key you generated from the "Target" machine to the "Acting" machine, or from the Mac to the Linux server.  Note that the scp command will ask for the password to the <em>MyUsername</em> account because it is connecting to that server to send it the key.</p>
<p>Voile. As if by magic, the "Acting" machine should now be able to SSH into the "Target" machine without a password prompt. Correspondingly, you should be able to perform rsync and other SSH commands without a password prompt. Please note, however, that <em>this is only a one-way key.</em><em> </em>We only gave my Linux server permission to access my Mac.</p>
<p><strong>What if I want my Mac to similarly login to the server without a password prompt?</strong> In that case, the Mac and the server have effectively switched roles; the Mac is now the "Acting" machine and the server is the "Target" machine, so we just have to repeat the process from the other direction. Generate a key from the server and send it to the Mac. At that point, both machines will be able to access each other without a password prompt. </p>
<p><strong>What if I have multiple "Targets" that the "Acting" machine will connect to?</strong> For instance, perhaps I have multiple Macs, and the Linux server is running scripts on all of them. When you're sending the key to the "Acting" server with the scp command, use a different name for each key file, don't overwrite the same file each time! So in the example code above, we're sending the key as "authorized_keys2". When repeating this process for multiple targets, send the keys as "authorized_keys3", and so forth.</p>
<p>Hopefully this will clear up some confusion regarding this process.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crankybit.com/avoiding-the-password-prompt-for-ssh/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
