Re: Coldbox and ColdSpring How to?
One of the minor side-effects of the way ColdSpring easily handles more and more complexity is that I found my ColdSpring XML file got out of control unless I took an organised approach to the layout. My first few ColdSpring sites had about 20 CFCs or so to manage, and without thinking much, I'd just add a new CFC to the bottom of the XML and that would be fine. But then i built a site that had many more CFCs than that, and i found my XML file got unmanageable. I was getting errors because i was duplicating the XML definition of CFCs and omitting some altogether.I found i had to be more organised than the XML equivalent of the shoebox filing system. I tried putting the CFCs into the XML file in alphabetical order, and that didn't really work. It improved things a bit, but what worked most was to put CFCs related to different parts of the application together - all the USER cfcs together and all the CONTENT cfcs together and all the CATALOG cfcs together etc. With comments between the sections of the XML file, so they are easy to find. THEN Coldspring showed its magic. It happily handled the management of hundreds of CFCs, all their dependencies, locations, how they are to be instantiated, and all i ever had to do in a calling page was something like: cfset UsersDAO = application.beanfactory.getbean(UsersDAO) and i never had to worry again about how to instantiate it, where it was, what other cfcs it depended on, where to find them, whether parameters or other objects were required in the init() method, etc. If i ever change my hard drive layout - move my CFCs around - there's only one file that ever needs to know where to find them - the coldspring XML file. As i said, MAGIC! All i have to do is 'hey Coldspring - give me a UsersDAO object' and it knows what to do , and just does it! Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On Sun, Jul 26, 2009 at 1:25 AM, Glyn Jacksonglyn.jack...@newebia.co.uk wrote: I see, thanks for taking the time to explain, you have been very helpful. Glyn. On Fri, Jul 24, 2009 at 1:36 AM, Glyn Jacksonglyn.jack...@newebia.co. uk wrote: what are the benefits of working this way, am just ignorant having never used it or AOP before in CF. Any docs online you can point me to (I dont know what I would be looking for) As the number of CFCs being created / initialized increases, the benefits of ColdSpring increase because you don't need all that code inside your CFCs (this could have been all done in the init() method or I could have extended the CFC or I could have passed in the details from config CFC without ColdSpring). That means that dependency changes can be made without changing your code, including using AOP to add logging, security etc etc. ColdSpring is one of those tools where you can't really get it until you've experienced the problem it solves and then it's a real lightbulb moment. I wasn't sold on IoC / DI tools at first. When I really saw the light it was working on a Mach-II application (years ago, at Macromedia) and having to deal with complex and ever-growing configuration data. I needed a way to separate configuration from code and Mach-II's XML-based approach wasn't cutting it. So I rewrote the app using Model-Glue 1.0 and an external XML file for configuration data (using ChiliBeans, MG1's IoC container). As far as I was concerned, it was still just externalizing configuration, albeit object-based configuration. As the application grew, the bean factory really started to take the load off my hands as it could take care of increasing complexity without impact to my code. Then I switched to ColdSpring because it was more capable than ChiliBeans and I never looked back! -- Sean A Corfield -- (904) 302-SEAN Railo Technologies US -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324967 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
On Sat, Jul 25, 2009 at 11:15 PM, Mike Kearafpwebwo...@gmail.com wrote: I tried putting the CFCs into the XML file in alphabetical order, and that didn't really work. It improved things a bit, but what worked most was to put CFCs related to different parts of the application together - all the USER cfcs together and all the CONTENT cfcs together and all the CATALOG cfcs together etc. With comments between the sections of the XML file, so they are easy to find. Another useful trick is to use the import directive so you can break your ColdSpring XML file down into multiple files with each file containing CFCs for a specific part of the application, then you have: import resource=user-beans.xml/ import resource=content-beans.xml/ import resource=catalog-beans.xml/ Each imported file must be a syntactically complete ColdSpring XML file, i.e., must contain beans .. /beans and some bean definitions. -- Sean A Corfield -- (904) 302-SEAN Railo Technologies US -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret At ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324968 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
I see, thanks for taking the time to explain, you have been very helpful. Glyn. On Fri, Jul 24, 2009 at 1:36 AM, Glyn Jacksonglyn.jack...@newebia.co. uk wrote: what are the benefits of working this way, am just ignorant having never used it or AOP before in CF. Any docs online you can point me to (I dont know what I would be looking for) As the number of CFCs being created / initialized increases, the benefits of ColdSpring increase because you don't need all that code inside your CFCs (this could have been all done in the init() method or I could have extended the CFC or I could have passed in the details from config CFC without ColdSpring). That means that dependency changes can be made without changing your code, including using AOP to add logging, security etc etc. ColdSpring is one of those tools where you can't really get it until you've experienced the problem it solves and then it's a real lightbulb moment. I wasn't sold on IoC / DI tools at first. When I really saw the light it was working on a Mach-II application (years ago, at Macromedia) and having to deal with complex and ever-growing configuration data. I needed a way to separate configuration from code and Mach-II's XML-based approach wasn't cutting it. So I rewrote the app using Model-Glue 1.0 and an external XML file for configuration data (using ChiliBeans, MG1's IoC container). As far as I was concerned, it was still just externalizing configuration, albeit object-based configuration. As the application grew, the bean factory really started to take the load off my hands as it could take care of increasing complexity without impact to my code. Then I switched to ColdSpring because it was more capable than ChiliBeans and I never looked back! -- Sean A Corfield -- (904) 302-SEAN Railo Technologies US -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324961 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
On Thu, Jul 23, 2009 at 2:59 PM, Glyn Jacksonglyn.jack...@newebia.co.uk wrote: I think I have it now in my handler... variables.oUserService = getPlugin(ioc).getBean(UserService).getUserGateway(); and i now see all common.cfc methods is this right? If it has autowire by name enabled. Otherwise you need a property tag in the userService definition to inject the userGateway bean. -- Sean A Corfield -- (904) 302-SEAN Railo Technologies US -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwoo ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324917 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
Thanks Mr Corfield, perfect. last question I promise (fingers crossed). I am just playing with ColdSpring, however maybe I am missing the point with what I have done in the example so far. this could have been all done in the init() method or I could have extended the CFC or I could have passed in the details from config CFC without ColdSpring. I could have also cached my CFC in CB or on app start. I have read the docs on ColdSpring it seems to be adding an easy to use system yes, but an extra layer to my app also. what are the benefits of working this way, am just ignorant having never used it or AOP before in CF. Any docs online you can point me to (I dont know what I would be looking for) ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324919 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Coldbox and ColdSpring How to?
On Fri, Jul 24, 2009 at 1:36 AM, Glyn Jacksonglyn.jack...@newebia.co.uk wrote: what are the benefits of working this way, am just ignorant having never used it or AOP before in CF. Any docs online you can point me to (I dont know what I would be looking for) As the number of CFCs being created / initialized increases, the benefits of ColdSpring increase because you don't need all that code inside your CFCs (this could have been all done in the init() method or I could have extended the CFC or I could have passed in the details from config CFC without ColdSpring). That means that dependency changes can be made without changing your code, including using AOP to add logging, security etc etc. ColdSpring is one of those tools where you can't really get it until you've experienced the problem it solves and then it's a real lightbulb moment. I wasn't sold on IoC / DI tools at first. When I really saw the light it was working on a Mach-II application (years ago, at Macromedia) and having to deal with complex and ever-growing configuration data. I needed a way to separate configuration from code and Mach-II's XML-based approach wasn't cutting it. So I rewrote the app using Model-Glue 1.0 and an external XML file for configuration data (using ChiliBeans, MG1's IoC container). As far as I was concerned, it was still just externalizing configuration, albeit object-based configuration. As the application grew, the bean factory really started to take the load off my hands as it could take care of increasing complexity without impact to my code. Then I switched to ColdSpring because it was more capable than ChiliBeans and I never looked back! -- Sean A Corfield -- (904) 302-SEAN Railo Technologies US -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324958 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Coldbox and ColdSpring How to?
I am trying to get my head around ColdBox and ColdSpring (manly ColdSpring) so please be kind and any example code with comments would be much appreciate. My question I have a CFC called model/common.cfc This CFC contains all my SQL code that interacts with the database. However in common.cfc I currently use the following code inside common.cfc on init() to get my DNS details... ! CONSTRUCTOR cfproperty name=dsn type=coldbox:datasource:DBDetails scope=instance!---inject datasource--- cfscript instance = structnew(); /cfscript cffunction name=init access=public returntype=any output=false cfargument name=dsn type=any _wireme=coldbox:datasource:DBDetails / cfreturn this /cffunction I can then call it anywhere inside common like so #instance.dsn.getName()# Now this works fine, but wanting to expand my knowledge I have decided to introduced ColdSpring (no experience of it before) I understand why I would use an IOC so I wanted to start simple. I want to replace the above code and inject the DNS details into common.cfc and use âoneâ bean for all. I have followed the documentation on CB but am struggling mainly because of my understanding I think. Here is what I have so far I created my coldspring.xml (below) what I think it should do is inject DNS into UserService.cfc this cfc is then called by common (userGateway). then in my handler i can just called the one bean, right... coldspring.xml... beans bean id=coldboxFactory class=coldbox.system.extras.ColdboxFactory / bean id=ConfigBean factory-bean=ColdboxFactory factory-method=getConfigBean / bean id=dsnBean factory-bean=ColdboxFactory factory-method=getDatasource constructor-arg name=alias valueDBDetails/value /constructor-arg /bean bean id=userGateway class=model.Common / bean id=UserService class=model.UserService property name=dsnBean ref bean=dsnBean / /property property name=ConfigBean ref bean=ConfigBean / /property /bean /beans I assumed this would allow me to access dns inside common.cfc but it does not. userservice.cfc cfcomponent name=User Service cffunction name=init access=public returntype=any hint=Constructor. cfreturn this / /cffunction cffunction name=getUserGateway access=public returntype=any output=false hint=Return the UserGateway. cfreturn variables.instance['userGateway'] / /cffunction cffunction name=setUserGateway access=public returntype=void output=false hint=Set the UserGateway. cfargument name=userGateway type=any required=true hint=UserGateway / cfset variables.instance['userGateway'] = arguments.userGateway / /cffunction cffunction name=setDSNBean access=public returntype=void cfargument name=DSNBean type=Any required=true/ cfset variables.dsn = arguments.DSNBean.getName() /cffunction cffunction name=setConfigBean access=public returntype=void cfargument name=configBean type=Any required=true/ !--- cfset variables.mailName = arguments.configBean.getKey(mailUsername)--- /cffunction /cfcomponent I dont know what to do in common.cfc to pull it... any help/examples on what I need to do here or is my understanding of what I am doing all wrong? If you were doing this how would you go about it, i learn best from examples (visual keys) Thanks ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324850 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
Common.cfc has to be managed by ColdSpring for the dependency injection to take place. I.e., you need: bean id=common class=model.Common ... etc ... /bean And you need to get the common bean from ColdSpring wherever you use it. Your XML has the bean named userGateway which doesn't seem right (since you have a property injector method in Common.cfc for userGateway)? Sean On Thu, Jul 23, 2009 at 5:28 AM, Glyn Jacksonglyn.jack...@newebia.co.uk wrote: I am trying to get my head around ColdBox and ColdSpring (manly ColdSpring) so please be kind and any example code with comments would be much appreciate. My question I have a CFC called model/common.cfc This CFC contains all my SQL code that interacts with the database. However in common.cfc I currently use the following code inside common.cfc on init() to get my DNS details... ! CONSTRUCTOR cfproperty name=dsn type=coldbox:datasource:DBDetails scope=instance!---inject datasource--- cfscript instance = structnew(); /cfscript cffunction name=init access=public returntype=any output=false cfargument name=dsn type=any _wireme=coldbox:datasource:DBDetails / cfreturn this /cffunction I can then call it anywhere inside common like so #instance.dsn.getName()# Now this works fine, but wanting to expand my knowledge I have decided to introduced ColdSpring (no experience of it before) I understand why I would use an IOC so I wanted to start simple. I want to replace the above code and inject the DNS details into common.cfc and use one bean for all. I have followed the documentation on CB but am struggling mainly because of my understanding I think. Here is what I have so far I created my coldspring.xml (below) what I think it should do is inject DNS into UserService.cfc this cfc is then called by common (userGateway). then in my handler i can just called the one bean, right... coldspring.xml... beans bean id=coldboxFactory class=coldbox.system.extras.ColdboxFactory / bean id=ConfigBean factory-bean=ColdboxFactory factory-method=getConfigBean / bean id=dsnBean factory-bean=ColdboxFactory factory-method=getDatasource constructor-arg name=alias valueDBDetails/value /constructor-arg /bean bean id=userGateway class=model.Common / bean id=UserService class=model.UserService property name=dsnBean ref bean=dsnBean / /property property name=ConfigBean ref bean=ConfigBean / /property /bean /beans I assumed this would allow me to access dns inside common.cfc but it does not. userservice.cfc cfcomponent name=User Service cffunction name=init access=public returntype=any hint=Constructor. cfreturn this / /cffunction cffunction name=getUserGateway access=public returntype=any output=false hint=Return the UserGateway. cfreturn variables.instance['userGateway'] / /cffunction cffunction name=setUserGateway access=public returntype=void output=false hint=Set the UserGateway. cfargument name=userGateway type=any required=true hint=UserGateway / cfset variables.instance['userGateway'] = arguments.userGateway / /cffunction cffunction name=setDSNBean access=public returntype=void cfargument name=DSNBean type=Any required=true/ cfset variables.dsn = arguments.DSNBean.getName() /cffunction cffunction name=setConfigBean access=public returntype=void cfargument name=configBean type=Any required=true/ !--- cfset variables.mailName = arguments.configBean.getKey(mailUsername)--- /cffunction /cfcomponent I dont know what to do in common.cfc to pull it... any help/examples on what ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324879 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Coldbox and ColdSpring How to?
Hi Sean, thanks for the reply. Quote: Common.cfc has to be managed by ColdSpring for the dependency injection to take place So the dependency injection would be... bean id=common class=model.Common property name=dsnBean ref bean=dsnBean / /property property name=ConfigBean ref bean=ConfigBean / /property /bean Quote: Your XML has the bean named userGateway which doesn't seem right (since you have a property injector method in Common.cfc for userGateway)? could you expand on this. Common is the userGateway layer right? last in common.cfc how to a use the injected DNS in common.cfc i,e. getDatasource(password)? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324899 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
PS would i also not have to change my User Service as all i want to do is call my User Service and have common available otherwise I dont see the point i can set this in init method. i.e would it be something like so only the user service is called... User Service cfcomponent name=User Service cffunction name=init access=public returntype=any hint=Constructor. cfreturn this / /cffunction cffunction name=getUserGateway access=public returntype=any output=false hint=Return the UserGateway. cfreturn variables.instance['common'] / /cffunction cffunction name=setUserGateway access=public returntype=void output=false hint=Set the UserGateway. cfargument name=userGateway type=any required=true hint=UserGateway / cfset variables.instance['userGateway'] = arguments.userGateway / /cffunction sorry for all the questions I really want to better under stand this. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324900 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
On Thu, Jul 23, 2009 at 1:31 PM, Glyn Jacksonglyn.jack...@newebia.co.uk wrote: PS would i also not have to change my User Service as all i want to do is call my User Service and have common available otherwise I dont see the point i can set this in init method. i.e would it be something like so only the user service is called... Ah, I misunderstood your code... User Service cfcomponent name=User Service OK, *this* component needs to be managed by ColdSpring. cffunction name=setUserGateway access=public returntype=void output=false hint=Set the UserGateway. cfargument name=userGateway type=any required=true hint=UserGateway / cfset variables.instance['userGateway'] = arguments.userGateway / /cffunction User Service has to be under ColdSpring's control for it to know about calling this method. -- Sean A Corfield -- (904) 302-SEAN Railo Technologies US -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really ali ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324901 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Coldbox and ColdSpring How to?
sorry, so do i go back to how I was before... bean id=Common class=model.Common property name=dsnBean ref bean=dsnBean / /property /bean bean id=UserService class=model.UserService / but then how does UserService know what common? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324907 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
how about below would this allow me to call any method from common.cfc using the user service bean. beans bean id=coldboxFactory class=coldbox.system.extras.ColdboxFactory / bean id=ConfigBean factory-bean=ColdboxFactory factory-method=getConfigBean / bean id=dsnBean factory-bean=ColdboxFactory factory-method=getDatasource constructor-arg name=alias valueDBDetails/value /constructor-arg /bean bean id=userGateway class=model.Common property name=dsnBean ref bean=dsnBean / /property /bean bean id=UserService class=model.UserService / /beans userservice.cfc cfcomponent name=User Service cffunction name=init access=public returntype=any hint=Constructor. cfreturn this / /cffunction cffunction name=setUserGateway access=public returntype=void output=false hint=Set the UserGateway. cfargument name=userGateway type=any required=true hint=UserGateway / cfset variables.instance['userGateway'] = arguments.userGateway / /cffunction cffunction name=getUserGateway access=public returntype=any output=false hint=Return the UserGateway. cfreturn variables.instance['userGateway'] / /cffunction ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324910 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Coldbox and ColdSpring How to?
I think I have it now in my handler... variables.oUserService = getPlugin(ioc).getBean(UserService).getUserGateway(); and i now see all common.cfc methods is this right? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324911 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4