Happy new year to everyone

Thanks to all the people that follow mytweets and blog posts. 2010 hasn't been the greatest of years for me personally but here is to 2011 being a lot better! (with more posts)

Posted: 31-Dec-2010

View: 2170

Permalink: here

My blog has moved

Please update your bookmarks and feeds for my site.

I now have a Mango Blog at:

http://www.andyjarrett.com/blog

Feed URL: http://feeds.feedburner.com/andyjarrett

Posted: 12-May-2009

View: 1924

Permalink: here

ColdSpring and Remote Facades

ColdSpring is just indispensable when developing any size app but as a part of its Inversion of Control, or IoC it does a lot more. When developing a project with a framework I usually have a need to have remote access to my model. One of the usual methods is to still go through the framework itself. The reason is that you've got ColdSpring (in most cases) handling all the injections and its just easier to keep it one place. For me I prefer to use a single service layer component which can access the model and this is where CS fits in.

CS can create remote facades which exposes any remote methods(access="remote") you have in a component.

What I am going to explain over a couple of posts is a technique that I am looking at implement in project thats slowly being worked on

I am assuming if you've made it this far you know CS so I'm going to jump straight in. If you don't, I know a good place to start. First of the directory structure for this guide.

  • web root
    • remote_cs
      • com
        • users
      • config

In the config folder we're going to place our ColdSpring.xml configuration file which at the moment looks like this with reference to one bean:

Posted: 19-May-2008

View: 3840

Permalink: here

Passing Application scoped variables to ColdSpring within Model Glue

Passing defaultProperties in ColdSpring with Model Glue

Or Using defaultProperties with CS and MG. I couldn't figure out which title would be better.

Basically this is a guide on how to pass variables into ColdSpring. In my case from the Application scope. Recently I've been working on a Model Glue, Transfer, and ColdSpring app and came across a problem which I couldn't find a direct answer to online. The application I'm working is only a small part of the site and has some settings in the Application scope which needs to remain there. Usually I put all my variables in a ColdSpring/Model Glue simpleConfig Bean (using the class ModelGlue.Bean.CommonBeans.SimpleConfig) but this time I needed CS to get the variables from the application scope. This actually isn't too hard as you can pass properties(dynamic variables) into the config.xml e.g.

Here's the code for creating the bean factory. You would find this in onApplicationStart or at the top of your Application.cfm.

Code for Application.cfm/cfc

view plain print about
1<!-- First we create our global vars in the Application scope -->
2<cfset application.settings = structNew() />
3<!-- Add our DSN name to the Settings struct -->
4<cfset application.settings.dsn = "myDSN" />
5<!-- If our bean factory doesn't exist then we create it. You could also check for a url.reinit var as well here -->
6<cfif NOT isDefined("application.beanFactory")>
7    <!-- Our struct to hold the variables we are going to pass to ColdSpring -->
8    <cfset properties = structNew() />
9    <!-- Our struct to hold the variables we are going to pass to ColdSpring -->
10    <cfset properties.dsn = "dsn_reference">
11    <!-- Create our bean object -->    
12    <cfset application.beanFactory = createObject("component","coldspring.beans.DefaultXmlBeanFactory").init(structNew(), properties)/>
13    <!-- Pass a fully qualified path to a bean definition xml file -->
14    <cfset application.beanFactory.loadBeansFromXmlFile(expandPath('/config/beans.xml'), true)/>
15</cfif>

In our Beans.xml we need to reference the properties structure by the key.

Posted: 06-Dec-2007

View: 5466

Permalink: here

Frameworks DTD files

I hope this doesn't come across as a moan as its meant to be more of a general question to the community. But with all the main frameworks out there running on XML config files, where are the official DTD's hosted for these? I know there are several around hosted in odd locations (no disrespect), but I was just looking to put together a definitive list of the locations.

I know you can get them via subversion etc but shouldn't/couldn't they be hosted on the respective sites??

Posted: 26-Feb-2007

View: 4022

Permalink: here

The Rough Guides

In case no one has noticed I am kind of starting a Rough Guide Series. These guides are made the way I like guides to be. They don't go in-depth and throw everything at you! They just do enough to get you up and walking and give you an understanding of the topic. For example the ColdSpring series were done with this in mind. I just wanted to help get the idea to finally click and see what it is good for. They seemed to of done well from looking at the views and they even got a mention in the CFWeekly(cheers guys, keep up the good work!). Along with this I will also offer links/resources to carry on where I leave off.

What will I be covering next.

Posted: 23-Jan-2007

View: 2886

Permalink: here

Multi-lingual site with Model-Glue and Coldspring

Now and then through my work I get asked to create a site with multi-lingual support. In the past I have usually just created a custom tag or UDF. This time, now that I am on A href="http://model-glue.com/">Model Glue: Unity I wanted something that was a little more integrated so I decided to use Ray Camden modified ResourceBundle.cfc. This cfc was actually created by Paul Hastings and you can find more information here.

There are two reasons I am posting this mini guide, first to share and the second is that knowing me I am probably doing something inefficient and by letting the community see it hopefully someone will point out any errors or an easier way to do things :o)

Posted: 08-Dec-2006

View: 5366

Permalink: here

Passing Properties to ColdSpring

Dan Vega has recently posted on his blog a small tutorial of how to pass properties to ColdSpring. Well worth a look to understand more benefits that dependecy injections brings to the table.

Posted: 27-Nov-2006

View: 4150

Permalink: here

ColdSpring and Dependency Injection for the beginner part 3: Setter Injection.

Onto part 3 of this rough beginners tutorial. By now you should of read part 1 and part 2 and this is the final part of me explaining Dependency Injection. This doesn't mean that come the end of this post you'll now know everything. But you'll know the basics, and be able to walk away and understand a little more of how and where to use ColdSpring.

To go back a little as since my first post there has been for my American readers a national holiday - Deep Fried Turkey day or Thanksgiving as it is better known (sorry I had to mention the deep fried [whole]turkey, I don't know if it because I'm British, but it just seems wrong!). Back to the code.....todays topic is is Setter Injection and to recap from the ColdSpring site;

<property name="propertyName" />
Similar in nature to constructor arg, however in this case ColdSpring will pass some value or object reference into your bean as an argument to a setter method, identified via the name attribute. Thus, your CFC must have a setter method name that matches the property tag's name attribute (for example if your property is named "foo" then your CFC needs a setFoo() method).

Posted: 27-Nov-2006

View: 6537

Permalink: here

ColdSpring and Dependency Injection for the beginner part 2: Constructor Injection.

Time to code! woohoo! I am going to carry on with the components from the last post which are userService and userDAO in a "model" directory on the root. For this post we'll assume that my DAO only has basic CRUD methods; Create, Read, Update, and Delete

I am going to demonstrate the Constructor Injection method of dependency injection which was summarised quickly in my last post. I think a recap is need here:

<constructor-arg name="argumentName"/>
This tag will cause Coldspring to supply your bean with a value or object reference when it is instantiated (during a CFC's init() method), passed as an argument named via the name attribute.

What the above statement means in basic terms is that the userService must have an init() method which accepts the userDAO object as an argument and sets it to a variable. e.g.

Posted: 24-Nov-2006

View: 5720

Permalink: here

More Entries