On Mar 14, 2006, at 7:11 PM, Troy Simpson wrote:
The only purpose of the ColdspringPlugin.cfc is to initialize the ColdSpring framework and the plugin is not use afterwards. Typically a mach-ii plugin is called during the processing of an event with methods like postEvent, postProcess, postView, prevent, preprocess, preview, etc. But these methods are not defined by the ColdspringPlugin.cfc and not used.
Yes that is true, in this use the plugin is extending Mach-ii. By only defining a configure method (and private methods) we are insuring that this plugin will only be used when your application application starts up.
When an application object is need (like categoryService in the example application) within a listener, filter, or plugin, a reference to the bean factory is obtained by using the getProperty() method of the mach-ii framework component (like listener, filter, plugin). Then the bean factory's getBean() method is called to obtain a reference to an application component.
This is exactly correct, but it's the 'old school' way of working with ColdSpring and Mach-ii. If you set the 'resolveMachiiDependencies' parameter to true for the plugin, all of your listeners, fiters, and plugins will be search for properties that match beans managed by ColdSpring. So if you have a bean with the id of 'securityService', and a listener with a method setSecurityService, the listener will be automatically wired up with the service.
I noticed that the Coldspring examples create a mach-ii Listener Object which contains a Service Object. The Service Object contains a DataAccessObject and GatewayObject. What is the benefit of creating the extra Service Object layer?
What you are doing is taking all domain logic out of your listeners, which are really part of your controller layer, and placing it into components that make up your model. For the most part your listeners will be mainly dealing with retrieving data out of the event, such as url and form variables, and placing data back into the even to be used by views. Then your business logic becomes far more reusable. Listeners shouldn't really be calling other listeners, but services can and should be calling other services, if they need to.
