Noob questions - Extermal Bean Factory

43 views
Skip to first unread message

Dave Shuck

unread,
Apr 17, 2013, 2:10:49 PM4/17/13
to taffy...@googlegroups.com
I am using Taffy for the first time today and am struggling with what I feel should be a simple concept.  I have an external ColdSpring beanfactory, and in the requestStartEvent() I have the following:

<cfset variables.framework.beanFactory = application.beanFactory />

If I go and short-circuit the onRequest() method in the api.cfc with the following...

<cfdump var="#application._taffy.EXTERNALBEANFACTORY.getBean("CityService")#" /><cfabort/>

... I see a dump of a service that I have defined in my ColdSpring instance. 

In the documentation, if I am interpreting it correctly I should then be able to put the following inside one of my resource classes:

<cffunction name="setCityService" output="false" returntype="void" access="public">
      <cfargument name="cityService" required="true" />
      <cfset StructAppend( variables, arguments ) />
 </cffunction>

If this exists, I should then have access to variables.cityService within that resource instance, right?  For some reason, it appears that this isn't working as I would expect.  The setCityService() method is never being invoked.  Am I misunderstanding the way that this works? 

Thanks in advance.

~d

Adam Tuttle

unread,
Apr 17, 2013, 2:18:48 PM4/17/13
to taffy...@googlegroups.com
Hi Dave,

Sounds like you're not too far off...

https://github.com/atuttle/Taffy/wiki/So-you-want-to:-Use-an-external-bean-factory-like-ColdSpring-to-resolve-dependencies-of-your-resources#create-your-bean-factory

In short, you should be using ApplicationStartEvent(), not onRequest(), because Taffy has to know about the available services during its bootstrapping phase in order to inject them into the resource CFCs. The above link should get you straightened out. :)

Welcome aboard!

Adam

Dave Shuck wrote:
--
You received this message because you are subscribed to the Google
Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dave Shuck

unread,
Apr 17, 2013, 2:20:49 PM4/17/13
to taffy...@googlegroups.com
I actually mistyped that.  This is my applicationStartEvent().  Sorry for the confusion!

    <cffunction name="applicationStartEvent" access="public" output="false" returntype="void"
        hint="this method is called by the Traffy framework as a pseudo application bootstrap">
           
        <cfset application.config = loadConfig() />
        <cfset application.beanFactory = initBeanFactory() />

        <cfset variables.framework.beanFactory = application.beanFactory />
    </cffunction>

--
You received this message because you are subscribed to a topic in the Google Groups "Taffy Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/taffy-users/UrkyvuM3GNk/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to taffy-users...@googlegroups.com.

Adam Tuttle

unread,
Apr 17, 2013, 2:48:00 PM4/17/13
to taffy...@googlegroups.com
Hmm, seems reasonable. I don't see anything wrong. Can you share more of your code, or are you available for a quick G+ hangout so I can watch over your shoulder?

Adam

Dave Shuck wrote:

    For more options, visit https://groups.google.com/groups/opt_out.


    --
    You received this message because you are subscribed to a topic in
    the Google Groups "Taffy Users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/taffy-users/UrkyvuM3GNk/unsubscribe?hl=en.
    To unsubscribe from this group and all its topics, send an email
    to taffy-users...@googlegroups.com

Dave Shuck

unread,
Apr 17, 2013, 3:03:55 PM4/17/13
to taffy...@googlegroups.com
Thanks for offering... I sent you a hangout invitation.

To unsubscribe from this group and all its topics, send an email to taffy-users...@googlegroups.com.

Adam Tuttle

unread,
Apr 17, 2013, 3:06:17 PM4/17/13
to taffy...@googlegroups.com
Weird, I haven't gotten anything. I'm inviting you to one as well...

April 17, 2013 3:03 PM
Thanks for offering... I sent you a hangout invitation.


--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
April 17, 2013 2:48 PM
Hmm, seems reasonable. I don't see anything wrong. Can you share more of your code, or are you available for a quick G+ hangout so I can watch over your shoulder?

Adam

Dave Shuck wrote:
April 17, 2013 2:20 PM
I actually mistyped that.  This is my applicationStartEvent().  Sorry for the confusion!

    <cffunction name="applicationStartEvent" access="public" output="false" returntype="void"
        hint="this method is called by the Traffy framework as a pseudo application bootstrap">
           
        <cfset application.config = loadConfig() />
        <cfset application.beanFactory = initBeanFactory() />
        <cfset variables.framework.beanFactory = application.beanFactory />
    </cffunction>

--
You received this message because you are subscribed to a topic in the Google Groups "Taffy Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/taffy-users/UrkyvuM3GNk/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
April 17, 2013 2:18 PM
Hi Dave,

Sounds like you're not too far off...

https://github.com/atuttle/Taffy/wiki/So-you-want-to:-Use-an-external-bean-factory-like-ColdSpring-to-resolve-dependencies-of-your-resources#create-your-bean-factory

In short, you should be using ApplicationStartEvent(), not onRequest(), because Taffy has to know about the available services during its bootstrapping phase in order to inject them into the resource CFCs. The above link should get you straightened out. :)

Welcome aboard!

Adam

Dave Shuck wrote:
April 17, 2013 2:10 PM
I am using Taffy for the first time today and am struggling with what I feel should be a simple concept.  I have an external ColdSpring beanfactory, and in the requestStartEvent() I have the following:

<cfset variables.framework.beanFactory = application.beanFactory />

If I go and short-circuit the onRequest() method in the api.cfc with the following...

<cfdump var="#application._taffy.EXTERNALBEANFACTORY.getBean("CityService")#" /><cfabort/>

... I see a dump of a service that I have defined in my ColdSpring instance. 

In the documentation, if I am interpreting it correctly I should then be able to put the following inside one of my resource classes:

<cffunction name="setCityService" output="false" returntype="void" access="public">
      <cfargument name="cityService" required="true" />
      <cfset StructAppend( variables, arguments ) />
 </cffunction>

If this exists, I should then have access to variables.cityService within that resource instance, right?  For some reason, it appears that this isn't working as I would expect.  The setCityService() method is never being invoked.  Am I misunderstanding the way that this works? 

Thanks in advance.

~d
--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.

Dave Shuck

unread,
Apr 17, 2013, 3:48:33 PM4/17/13
to taffy...@googlegroups.com
Adam, thanks for taking the time to look at the issue with me. In case anyone else runs across this issue, it was related to the lack of an explicit local scope on pre-CF9 during the dependency injection on bootstrap.  The bug fix can be seen here:

https://github.com/dshuck/Taffy/commit/4400cbcabcea98e8b36960ff1efc734a3569165a
postbox-contact.jpg
postbox-contact.jpg

Adam Tuttle

unread,
Apr 17, 2013, 4:21:16 PM4/17/13
to taffy...@googlegroups.com
Thanks for the pull request, Dave. I've accepted it. Anyone running CF8 and using an external bean factory (ColdSpring, etc) will need this, otherwise upgrading is not crucial.

It's available in the BER downloads, but hasn't been included in any tagged versions yet.

Adam

Dave Shuck wrote:

Adam, thanks for taking the time to look at the issue with me. In case
anyone else runs across this issue, it was related to the lack of an
explicit local scope on pre-CF9 during the dependency injection on
bootstrap.  The bug fix can be seen here:

https://github.com/dshuck/Taffy/commit/4400cbcabcea98e8b36960ff1efc734a3569165a



On Wed, Apr 17, 2013 at 2:06 PM, Adam Tuttle <ad...@fusiongrokker.com
<mailto:ad...@fusiongrokker.com>> wrote:

    Weird, I haven't gotten anything. I'm inviting you to one as well...


    Dave Shuck <mailto:dsh...@gmail.com>

    April 17, 2013 3:03 PM
    Thanks for offering... I sent you a hangout invitation.


    --
    You received this message because you are subscribed to the
    Google Groups "Taffy Users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to taffy-users...@googlegroups.com

    For more options, visit https://groups.google.com/groups/opt_out.


    Adam Tuttle <mailto:ad...@fusiongrokker.com>

    April 17, 2013 2:48 PM
    Hmm, seems reasonable. I don't see anything wrong. Can you share
    more of your code, or are you available for a quick G+ hangout so
    I can watch over your shoulder?

    Adam

    Dave Shuck wrote:
    Dave Shuck <mailto:dsh...@gmail.com>

    April 17, 2013 2:20 PM
    I actually mistyped that.  This is my applicationStartEvent().
    Sorry for the confusion!

        <cffunction name="applicationStartEvent" access="public"
        output="false" returntype="void"
                hint="this method is called by the Traffy framework
        as a pseudo application bootstrap">

        <cfset application.config = loadConfig() />
        <cfset application.beanFactory = initBeanFactory() />
        <cfset variables.framework.beanFactory =
        application.beanFactory />
        </cffunction>


    On Wed, Apr 17, 2013 at 1:18 PM, Adam Tuttle
        <mailto:taffy-users%2Bunsu...@googlegroups.com>.

        For more options, visit
        https://groups.google.com/groups/opt_out.


        --
        You received this message because you are subscribed to a
        topic in the Google Groups "Taffy Users" group.
        To unsubscribe from this topic, visit
        https://groups.google.com/d/topic/taffy-users/UrkyvuM3GNk/unsubscribe?hl=en.
        To unsubscribe from this group and all its topics, send an
        email to taffy-users...@googlegroups.com
        <mailto:taffy-users%2Bunsu...@googlegroups.com>.

        For more options, visit https://groups.google.com/groups/opt_out.



    --
    You received this message because you are subscribed to the
    Google Groups "Taffy Users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to taffy-users...@googlegroups.com

    For more options, visit https://groups.google.com/groups/opt_out.


    Adam Tuttle <mailto:ad...@fusiongrokker.com>

    April 17, 2013 2:18 PM
    Hi Dave,

    Sounds like you're not too far off...

    https://github.com/atuttle/Taffy/wiki/So-you-want-to:-Use-an-external-bean-factory-like-ColdSpring-to-resolve-dependencies-of-your-resources#create-your-bean-factory

    In short, you should be using ApplicationStartEvent(), not
    onRequest(), because Taffy has to know about the available
    services during its bootstrapping phase in order to inject them
    into the resource CFCs. The above link should get you
    straightened out. :)

    Welcome aboard!

    Adam

    Dave Shuck wrote:
    Dave Shuck <mailto:dsh...@gmail.com>

    For more options, visit https://groups.google.com/groups/opt_out.



    --
    You received this message because you are subscribed to a topic in
    the Google Groups "Taffy Users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/taffy-users/UrkyvuM3GNk/unsubscribe?hl=en.
    To unsubscribe from this group and all its topics, send an email
    to taffy-users...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages