No, I havn't tried that Peter.  I'll give it a shot.  If anything it may give more insight as to where the issue comes from.  As an alternative, atleast for this project, does anyone have any solutions to solve this problem?  The two that first come to mind include:

1. Simply using a singleton TimedCache (added some extra logic to deal with this)
2. Creating a singlton factory, which will be responsible for enforcing the create object method.  I've done this before with entity objects, and it seemed to work rather well.

Let me know what you all think.

- Andrew


From: "Peter J. Farrell" <[EMAIL PROTECTED]>
Sent: Saturday, October 07, 2006 5:14 PM
To: [email protected]
Subject: [coldspring-dev] non-singleton doesn't seem to be working as i expected


[EMAIL PROTECTED] said the following on 10/7/2006 12:33 AM:
Hey guys, i'm having a little trouble with a singleton I'm trying to use.  I may not understand how this is intended to work, so I wanted to see if anyone had any input.

Here is what I'm trying to do:
ColdspringConfig.xml

<beans>
    <bean id="ArticleService" class="model.services.ArticleService
">
       
<property name="ArticleGateway"><ref bean="ArticleGateway" /></property>
        <property name="LocationGateway"><ref bean="LocationGateway" /></property>
    </beans>
    <bean id="LocationService" class="model.services.LocationService">
        <property name="LocationGateway"><ref bean="LocationGateway" /></property>
    </beans>

    <bean id="LocationGateway" class="model.gateways.LocationGateway">
       <property name="TimedCache"><ref bean="TimedCache" /></property>
    </beans>
    <bean id="ArticleGateway" class="model.gateways.ArticleGateway">
       <property name="
TimedCache"><ref bean="TimedCache" /></property>
    </beans>


    <!-- this is based on the mg:u timed cache -->
    <bean id="TimedCache" class="model.utils.TimedCache" singleton="false" />
</beans>


So this is what I'm trying to accomplish.  I would like to inject an instance of the TimedCache cfc into each of these gateways.  When I do this, it seems as though there is only one instance of the TimedCache, which they both seem to be sharing.
  The TimedCache is stored in the variables scope of each gateway.  Originally I intended for each gateway to get its own instance, but I can't seem to get this to work.  This only seems to happen if I include both gateways in a single service.  Again, each is stored in the variables scope.  If I remove the references to say the locationgateway from the article service, each TimedCache seems to work as intended.  Am I misunderstand how this should work?  Or do I have a programming error?

Thanks for your input!
Andrew
haven't tried this or many I'm not understanding how the bug works exactly...

<beans>
    <bean id="ArticleService" class="model.services.ArticleService
">
       
<property name="ArticleGateway"><ref bean="ArticleGateway" /></property>
        <property name="LocationGateway"><ref bean="LocationGateway" /></property>
    </beans>
    <bean id="LocationService" class="model.services.LocationService">
        <property name="LocationGateway"><ref bean="LocationGateway" /></property>
    </beans>

    <bean id="LocationGateway" class="model.gateways.LocationGateway">
       <property name="TimedCache"><bean id="TimedCacheForLocationGateway" class="model.utils.TimedCache" /></property>
    </beans>
    <bean id="ArticleGateway" class="model.gateways.ArticleGateway">
       <property name="
TimedCache"><bean id="TimedCacheForArticleGateway" class="model.utils.TimedCache" /></property>
    </beans>

</beans>

-- Peter J. Farrell - Maestro Publishing http://blog.maestropublishing.com -- Co-Host of the ColdFusion Weekly Podcast http://www.coldfusionweekly.com 



Reply via email to