Heya,
Yeah, I remember just then that the serviceManager is instantiated in the application scope, and upon every call (getServiceManager() it checks to see if it exists If not it creates it and either way returns a ref back.
The problem I'm trying to solve is that when I reference the DataLayerGatewayFactory Object (big word eh) it's only a once of creation vs. many
With Mach-II you have to tread carefully in that you need to keep Listeners application specific, while the rest fairly loose and not as dependent on Mach-II framework for information.
In that the model can be initialize in many ways by Mach-II aware data (i.e. Properties etc) but that's all done via the Listener in question.
The solution Spike and I just nutted out then was to create a config.cfc (forgive me spike if I loose this in translation. I do that at times) that all Listeners know about *(whether they create it every request or simply look in the application scope for its existence but that is logic inside the listener itself.. not a bad thing I guess as typically in most basic mach-ii apps I really only use one listener object).
They then pass in the config.CFC(configBO) into appService.cfc's (blogAppService, newsAppService etc).
Then inside the blogAppService, they would ask the configBO for stuff like
Class blogAppService {
blogAppService(configBO) {
instance.configBO = arguments.configBO;
}
createArticle(articleDTO) {
articleBean = new com.mypath.blogs.articleBean();
articleBean.setTitle(articleDTO.title);
etc..
instance.configBO.getDLGFactory('blog').createDAO('entry').create(articleBean);
instance.configBO.getMessagingService().notifyNewEntrySubscribers(articleBean);
}
}
The catch 22 is that, Listeners & appServices are now application specific in that today I can use them in Mach-II appBlah, tomorrow probably in another etc (appBlahCustom).. but if I go off the reservation (say with farCry) and need to use the "blog logic - ie blog DAO's, DataGateways, Beans etc" they need to have their own appService/Listener fa�ade in front of them, to tell them what to do so partial re-useability is there I guess? Not a bad thing?
Scott.
-----Original Message-----
From: Gary Menzel [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 8 December 2004 11:48 AM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Erm, DataLayer Factory Question.
Just a correction on how we do it here....
There is ONE instance of a "ServicesManager" class. We dont inherit from this (as such - well an application space can inherit from other ServicesManagers - but that's it).
Then there is a "Core" class from which things inherit (they dont have to - but there is a lot of value in doing so). This base class gets a reference to an "instance" of the single ServicesManager class automatically created. Then, classes that inherit from the base core class can access the ServicesManager through the local instance reference.
The "ServicesManager" - not the core object - is what manages things like singletons.
The specific ServicesManager class that is created is determined by a single entry point that specifies which "application" (not
<cfapplication>) you want the services manager for.
This is all done using package paths to dynamically configure the application from a single point.
However, I would have thought that MACH-II would already do most of the things you want.
Gary
