By Peter Bell

Added Custom Factory Support for LightWire 0.5

Custom factory support added to LightWire. Seems solid as I was able to use the TransferFactory to create transfer which was then ready for injection (I tested using tblog and have just commented out the necessary config in the LightWireTest project as it'll only work if you have transfer and tblog installed).

Let me know if any problems at all! Below is an updated zip file (although unlike Brian I'm still doing this manually. Ant scripts are on the list for later this spring :->).

Also committed to svn: http://svn.riaforge.org/lightwire

Comments
Dude, I know nothing about ANT and still had the xml file to clean up my files (i.e. remove unneeded files), copy it and zip it up done in like 20 minutes, and 19 of those were spent learning the prerequisite knowledge.
# Posted By Brian Rinaldi | 3/11/07 8:17 PM
Yeah. I watched the presos at 360 flex and I've been looking around at the CF blog postings, but I still haven't had a chance to sit down with this. So, ya gonna post some XML and one of your amazingly cool guides?! (if your fingers don't bleed from the OSS report) :->
# Posted By Peter Bell | 3/11/07 8:48 PM
Peter, I want to use LightWire on a new project but I'm stuck with a problem. I'm trying to use LightWire to instantiate Transfer but the factory method call won't work. I'm running the exact same code you have in the examples:

addSingleton("transfer.TransferFactory");
addConstructorProperty("TransferFactory", "datasourcePath", "/H2O/config/datasource.xml.cfm");
addConstructorProperty("TransferFactory", "configPath", "/H2O/config/transfer.xml.cfm");
addConstructorProperty("TransferFactory", "definitionPath", "/H2O/config/definitions");
addSingletonFromFactory("TransferFactory", "getTransfer", "transfer");

I keep getting the following error:
Element CONSTRUCTORDEPENDENCYSTRUCT is undefined in a CFML structure referenced as part of an expression

I looked in the files and sure enough it seems that structure isn't defined for an object created from a factory. Am I missing something here? I've got the latest LightWire from SVN, but also tried it using the one that comes with ColdBox and I get the same error.
# Posted By Thomas Messier | 9/5/07 11:32 AM
Hi Thomas,

Received. Let me check this out. Expect response some time today including patch and comments. Of course, if you happen to see a way to patch this, please just dorp in and email me and I'll review and implement!
# Posted By Peter Bell | 9/5/07 12:20 PM
I just added the following lines to the end of the addBeanFromFactory() method in BaseConfigObject.cfc:


variables.config[BeanName].ConstructorDependencyStruct = StructNew();
variables.config[BeanName].SetterDependencyStruct = StructNew();
variables.config[BeanName].MixinDependencyStruct = StructNew();
variables.config[BeanName].InitMethod = "";

Basically I added a bunch of properties that are set by addBean(). Just not sure it's really meant to be that way, I haven't used LightWire enough to know if this can cause problems elsewhere.
# Posted By Thomas Messier | 9/5/07 1:11 PM
Hi Thomas,

That should work fine. I'll play with this tonight and create a release. Problem is that I don't actually use the factory support, so it hasn't got beaten up much. Will keep you posted - thanks!

Also, please let me know after that change if you happen to run into any problems or not.
# Posted By Peter Bell | 9/5/07 2:32 PM
Hi, Peter.

I started having the same problem with Lightwire and Transfer as Thomas (above). The modification to the Lightwire code that Thomas recommends worked though.
# Posted By LT | 2/1/08 1:39 PM
Hi LT,

Thanks for the heads up. Things got a little busy, but I've got some code debt repayment scheduled for mid-February, so I've put this on the list to review/fix.
# Posted By Peter Bell | 2/1/08 1:52 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.