Lex, "what the heck is coldspring?"
Mex, "a framework that helps manage the model layer of your application"
Lex, "whats a model layer"
Mex, "the part of your programming that contains the bus. logic used in the program"
Lex, "how do i know if i have a model layer? and what is the bus. logic"
Mex, "does your application follow the MVC design pattern?"
Lex, "whats MVC?"
Mex, "a way of building your application so the view code is separated from the database and bus. logic code"
Lex, "i think we follow that, i have only really worked on the view side, thats coldfusion .cfm files, right?"
Mex, "yes, cfm files are usually a big part of the view layer, if your using ColdFusion. The model layer which contains your bus. logic are stored in coldFusion files called CFCs. The CFCs are the classes, like in Java."
Lex, "so what does ColdSpring do again?"
Mex, "Coldspring managers the model layer and helps with the relationships, or dependencies that exist between CFCs that collaborate in your model layer".
Lex, "You mean like a service or manager CFC that uses a DAO or Gateway CFC?"
Mex, "exactly like that. The service component or CFC is dependent on the DAO and Gateway to do its job. The way that is typically handled is when the service object is created, it has an init method or function that is called that creates the other objects it needs. In a larger application that has lots of services, this can become a big headache to keep track of."
Lex, "I think i heard some of the other programmers i work with complaining about this and how you have to open a bunch of files to track down what is being created and where."
Mex, "right, CS reduces that complexity by putting all that object create code into a single file or container. That file is responsible for defining all singleton objects in the application."
Lex, "instead of putting create object code in the init method of the service for the DAO and Gateway, you put it in a coldspring file? I could do that for all the services in the application in this one file?"
Mex, "yes and yes"
Lex, "Is the coldspring file magic?"
Mex, "sort of, seriously, its just a xml style file, its really not that complicated, once you understand what its doing"
Lex, "ok, im in, lets get down to some nitty gritty"
Mex, "i thought you would never ask"
Mex.....
CS is a framework, a black box, with a lot of code that you never touch, you simply use it. If you are using a framework like mach-ii, fusebox or model-glue, you have specific "plug ins or hooks" that connect CS to your model. Mach-ii has a plug-in architecture that connects CS to your application.
You write a little code upon application start that executes and creates an object pointer to the black box (CS). Then you use the CS object passing into it the file path to your bean definition file to load the definitions. Each of the beans (objects) is loaded in the application scope. This is really the only file that CS interacts with.
If the object that you are creating has no dependencies, its very simple to create the object with a xml style notation. If the object needs arguments passed in upon instantiation, use the arguments parameter to pass that data along. If the object has dependencies on other objects, use the
bean id="someService" class="somepath.someService"
property name="someGateway"
bean id="someGateway" class="somepath.someGateway"
/property
/bean
When someService is created, it is injected with the someGateway object. The someGateway object is only available to the someService object. Sometimes, the object needs a more global scope, so other objects can reference it as an injection.
If the object being injected is already defined, use this notation to inject:
bean id="someService" class="somepath.someService"
property name="someGateway"
ref bean="someGateway"/
/property
/bean
The difference is that you are not injecting a new object
property name="someGateway"
bean id="someGateway" class="somepath.someGateway"
/property
but are injecting an existing object
property name="someGateway"
ref bean="someGateway"/
/property
ya dig?
More to follow.
No comments:
Post a Comment