Autowiring Reactor objects

I’m currently using the ReactorLoader interceptor to load Reactor in my ColdBox app. Is there any way to autowire Reactor objects? I know that you can do this:

Local.userRecord = Instance.reactor.createRecord(“user”);

But ideally I’d like ColdBox to automatically autowire the objects without the need for the second line above. Is there a way to do this that I’m not aware of? Or is this something that could be accomplished with a custom interceptor?

I would suggest creating a plugin that encapsulates access to reactor.
Athen when requested objects go via the plugin you wire them
automatically. Anotqher good idea is to create your own reactor
provider using wirebox. Or your own custom reactor dsl

Thanks for the suggestions, Luis.

If anyone’s interested, I have a solution that I feel works very well now. I basically extended the reactorFactory.cfc and changed the ReactorLoader interceptor settings in my ColdBox config to use my modified reactorFactory. My modified factory autowires the objects created by the factory before returning them.

Then you can just add the autowire=“true” attribute to your Reactor objects and they will be automatically autowired during creation. For example:

// This Reactor gateway will be autowired!!
Local.userGateway = Instance.reactor.createGateway(“user”);

I’ve posted my custom Reactor Factory at along with some code that needs added to your onAppInit method in order to make it all work.

Wh not add it to forgebox and contribute

Forge-what? I wasn’t aware of ForgeBox… thanks for cluing me in! I’ve submitted it as a under the ‘model objects’ category, but I’m not sure if that’s the best place for it or not. Let me know if you think it should be moved to a different category.