Matt -

I had the same idea awhile ago, I wanted to have CS use Reactor's createRecord() method as a factory-method, but this is really not what ColdSpring is meant for. Your service shouldn't "depend" on the bean that it's meant to create, but it should depend on a factory that can create the Person bean for it. So, assuming you aren't going to use a DAO, it's perfectly legitimate for your PersonService to use createObject to make a PersonBean. I would personally (ha) recommend using a DAO for this purpose, but it's up to you really. The important part is that any other part of your application that would need Person beans should be wired to the PersonService in CS.

- Ken

On 3/23/06, Matt Williams <[EMAIL PROTECTED]> wrote:
Not sure how to explain my issue...

My ColdSpring.xml file defines the PersonBean (basic getter/setter
bean). I have a PersonService.cfc that has a setPersonBean method. So CS
injects the PersonBean into the PersonService. In another method in the
PersonService, called 'getPerson', I want to create a new instance of
the PersonBean each time it is run.

How do I do this?

I thought setting singleton="true" on the PersonBean definition might do
it, but it doesn't. Probably because PersonService itself is a
singleton.

Okay, so I just tested this and I can set the PersonService to not be a
singleton, and I get what I want. But in my mind, the PersonService
should be a singleton, but the PersonBean should be created new each
time (I want a new instance as I am putting the PersonBean into an array
as they are created).

Maybe I'm going about it all wrong. I can also get it to work if I don't
use the injected bean, and simply do a createObject call in the
getPerson method.

But is there a better way? Thoughts?

Thanks, Matt Williams




--
Quidquid latine dictum sit, altum sonatur.
- Whatever is said in Latin sounds profound.

Reply via email to