I have talked about the one I made on this list before, but you can grab
the code here:
https://github.com/HotelDelta/FW1-Miscellany/blob/master/servicefactory.cfc
Using that I can do this in my Application.cfc file:
setBeanFactory(createObject("component","model/servicefactory").init());
I then use my "registerService" method to stick references to my
services into my beanFactory. From there you can do what FW/1 expects,
including using getBeanFactory() yourself.
I take a shortcut by doing this in the init() method of a baseController
that all my controllers extend:
variables.fw = arguments.fw;
variables.services = variables.fw.getBeanFactory().getRegisteredServices();
Then in my controller methods I can just say:
rc.foo = services.myService.someMethod();
You could make one that's even simpler than the one I did that JUST
implements the FW1 methods.
> --
> FW/1 on RIAForge: http://fw1.riaforge.org/
>
> FW/1 on github: http://github.com/seancorfield/fw1
>
> FW/1 on Google Groups: http://groups.google.com/group/framework-one
You are better off creating a very lightweight bean factory that implements the couple of methods that FW/1 needs
My point was simply that FW/1 already provides an easy way to do that
while doing things within the framework conventions -- and doing that
might pay off down the road idiomatically and for readability.
DI/1 and ColdSpring do something very different - they manage
dependencies between elements of the model.
Once you move away from service queuing, you will find the interim
period before you _need_ that dependency management is very short.
That's why getService() is not public - it's use should not be
encouraged because auto wiring via a DI / bean factory is a much
better solution and you'll need it anyway.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
Yup. It was a failed experiment. The intent was to avoid boilerplate
controllers that simply delegated to service calls - which I'd seen a
lot in MVC code 2-3 years ago. Nowadays people don't make that mistake
so much (they structure their controllers and services differently) so
it's not a feature that's needed so much.
The queuing mechanism was intended for simple service usage - you've
already hit its limitations. In the simple world, DI is also not
needed. As I said, by the time you hit the limitations with the simple
queuing convention, you're only a short distance from also needing DI.
That's the only connection. In other words, you run into both
limitations around the same time in the grand scale of things.
> Is it perhaps that the whole queuing of services is not that great? First
> they happened automatically, now by default implicit services are off, maybe
> in the next version we just get rid of queuing services and service
> management all together? Mapping service functions to controller functions
> isn't that great a practice imho.
Yup.