RE: [coldbox:15098] Re: - Singleton question

You know, now that I think about it, my pull request is specifically for component-level annotations to inherit but there aren’t any component-level annotations for init args. If your base object has an init method with arguments that can be injected, that should already be picked up by WireBox and processed. Of course, if your sub classes override the init method, they’ll need to specify the same init args and inject annotations if applicable.

Can you show us the code?

Thanks!

~Brad

brad@bradwood.com wrote:

Since the Binder config is programmatic, you could use a loop construct based on a directory listing of the contents of that folder and then dynamically do map(“foo”).to(“bar”).initArg() bit on each one. I’ve never done it and I’m not sure if it’s recommended, but it would work.

As far as the DI annotations not being inherited, I just so happen have a pull request for that committed to my ColdBox fork on Github that is currently waiting on Luis to review. That would allow you to put the annotations once in the base object. Maybe if Luis looks at my enhancement soon and it passes review, it will make it into 3.5.2. :slight_smile:
https://github.com/ColdBox/coldbox-platform/pull/89

Thanks!

~Brad

Sure, I simplified the code… (How the hell do I format code here ? )

The base Object:

Sample GTW Object:

...

And I have a factory object instantiated with the DSN string:

<cfreturn createObject(“component”,“app.model.db.#arguments.name#”).init(getDatasource())/>

I’m trying to move to wirebox and my initial approach was to mapDirectory(‘app.model.db’).initArg(…) and then replace the create object in the factory with wirebox.getInstance.

Thanks for your input,

Cristian

Bratt, don’t mind me. I guess I was tired. I can pass the DSN string in the getInstance call in the factory, so no need for chaining to work on mapDirectory, But you improvement can indeed be useful.

Cristian

Bratt? Sorry, but I lol’d :slight_smile: