Re: [getxindi] FW/1 and DI/1 use in Xindi

107 views
Skip to first unread message

John Whish

unread,
Sep 19, 2012, 9:52:14 AM9/19/12
to getx...@googlegroups.com
Hi Matthew,

Yes, DI/1 is used to wire up the controllers and the "model". For FW/1
to know about DI/1 you need to use the setBeanFactory method:

Application.cfc

// setup bean factory
var beanfactory = new frameworks.org.corfield.ioc( "/model", {
singletonPattern = "(Service|Gateway)$" } );
setBeanFactory( beanfactory );

Then, when you want something from the model injected into your
controller, just do:

property name="ContentService";

You will need to component accessors="true" enabled on the controller :)

As DI/1 serves the ContentService, it is also able to handle the
ContentService's dependency on ContentGateway etc.

ContentService.cfc

component accessors="true"{
property name="ContentGateway" getter="false";
....
}

Does that help?

Cheers,

John

On 19 September 2012 14:43, Matthew <dduc...@gmail.com> wrote:
> I was looking at Xindi and its use of DI/1. I am trying to see where Xindi
> injects its Gateways etc into its services. Is DI/1 doing that? Trying to
> learn DI/1 and I have a simple app I built in FW/1. I have a dao and gateway
> cfcs set as properties of a service. Can I inject the two cfcs automatically
> with DI/1? Just trying to find some real world examples of DI/1 and FW/1
> use.
>
> Thank you,
> Matthew
>
> --
> You received this message because you are subscribed to the Google Groups
> "Xindi CMS" group.
> To post to this group, send an email to getx...@googlegroups.com.
> To unsubscribe from this group, send email to
> getxindi+u...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/getxindi/-/2DgpfUO_LlUJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Matthew

unread,
Sep 19, 2012, 10:44:01 AM9/19/12
to getx...@googlegroups.com, john....@googlemail.com
It makes sense.  Ill have to do more playing with it, but this does help. 

Matthew

unread,
Sep 19, 2012, 12:31:30 PM9/19/12
to getx...@googlegroups.com, john....@googlemail.com
Okay here is what i setup..

  • /model
    • /beans
      • Announcement.cfc
    • /gateways
      • AnnouncementGateway.cfc
    • /services
      • AnnouncementService.cfc
In my AnnouncementService.cfc i have this.

component accessors="true"
{

property name="gateway" displayname="Announcement Gateway" getter="false";
}


Application.cfc -  setupRequest()

var beanfactory = new org.corfield.ioc( "/model", { singletonPattern = "(Service|Gateway)$" } );
//test getBeanFactory()
rc.test = getBeanFactory().getBean("AnnouncementService");

rc.test shows it storing my AnnouncementService.cfc object, but inside my AnnouncementService.cfc if I try to reference variables.gateway it says it is undefined.

What am i missing?  

This was just my start in playing with this.   Does it have to do with the singletonPattern key by chance in the ioc init()?

-Matthew

Simon Bingham

unread,
Sep 20, 2012, 3:52:33 AM9/20/12
to getx...@googlegroups.com, john....@googlemail.com
Try changing 

property name="gateway" displayname="Announcement Gateway" getter="false"; 

to

property name="AnnouncementGateway" displayname="Announcement Gateway" getter="false";

The property name should match the name of your CFC.

Matthew

unread,
Sep 20, 2012, 1:35:36 PM9/20/12
to getx...@googlegroups.com, john....@googlemail.com
That worked Simon.  I had had sort of a eureka (oh duh) moment at lunch today and thought that I should name the properties the same name as the cfcs like you are stating.

I do have an AnnouncementDAO.cfc that it doesnt look like it is picking it up.  I keep getting an error that says is coming from my gateway, but it works when i just have the AnnouncementGateway property in there.

Thanks for your help!

-Matthew
Reply all
Reply to author
Forward
0 new messages