autowiring transient beans (not services)

122 views
Skip to first unread message

Brian FitzGerald

unread,
Apr 3, 2014, 6:09:08 PM4/3/14
to framew...@googlegroups.com
Hey guys,

I'm super impressed by FW/1 and DI/1. Though I'm still getting used to both of them, I'm really enjoying them so far.

Currently, autowiring is working great for me in Controllers and also working for me in my Services (within my model/services directory). However, for some reason I can't get autowiring to work for me in my beans (model/beans). Is this by design or am I just doing something wrong? This is how my bean of interest (Product) looks:

component accessors="true" {

property udfs;
public Product function init(){

return this;

}

public string function getPrice(){

// variables.udfs not available here

}

}

The bean is being instantiated within my /model/services/ProductService with the cfml "new" statement:

myProduct = new model.beans.Product();

Any insight is much appreciated.

Brian

Sean Corfield

unread,
Apr 3, 2014, 10:12:00 PM4/3/14
to framew...@googlegroups.com
On Apr 3, 2014, at 3:09 PM, Brian FitzGerald <bmfitz...@gmail.com> wrote:
However, for some reason I can't get autowiring to work for me in my beans (model/beans). 
...

The bean is being instantiated within my /model/services/ProductService with the cfml "new" statement:

myProduct = new model.beans.Product();

How can it get autowired if you are creating it yourself? DI/1 won't know anything about it!

Instead do:

myProduct = variables.beanFactory.getBean( "Product" ); // or "productBean"

You'll need the bean factory autowired into your service so add:

property beanFactory;

and DI/1 should autowire itself into your product service.

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



signature.asc

Brian FitzGerald

unread,
Apr 3, 2014, 11:16:18 PM4/3/14
to framew...@googlegroups.com
Doh! :bangs head against wall:

Thanks a lot Sean. That makes total sense! Thanks also for these awesome (lightweight) frameworks. I was up and running in minutes and am really loving both FW/1 and DI/1.

Brian

Sean Corfield

unread,
Apr 4, 2014, 1:25:36 AM4/4/14
to framew...@googlegroups.com
It's always nice to hear praise from happy users - thank you! :)

On Thu, Apr 3, 2014 at 8:16 PM, Brian FitzGerald
> --
> --
> FW/1 on RIAForge: http://fw1.riaforge.org/
>
> FW/1 on github: http://github.com/framework-one/fw1
>
> FW/1 on Google Groups: http://groups.google.com/group/framework-one
> ---
> You received this message because you are subscribed to the Google Groups
> "framework-one" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to framework-on...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Reply all
Reply to author
Forward
0 new messages