ioc in handlers / caching

Hi y'all,

Im injecting this non-singleton in a handler, so it should never cache
this, but its doing that..

<cfproperty name="currentBrowser" type="ioc" scope="instance">

Is it possible to add something like cache=false in this cfproperty?

Btw, its like a half-singleton, ive overidden the coldfspring factory
to keep this bean in the session and create a new one if it does not
exist in the session.

greets,
klaas

Remember that the handler will be cached so once the property is
injected, it will be there for the duration of the event handler
(unless you reload that event handler on every request by specifying
that it is not cached).

Injecting transients into non-transients is a kinda dangerous business...

You might want to look at using getmodel( “transient” ) inside a handler action.

Exactly, this is always an issue if you are using transients or time persisted objects, as they will inherit the lifespan of the injected object, so as Sean says, be careful when messing with bean persistence.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Hi,
Yeah, u guys are right, this is a problem i havent run into before… actually i probably have a bug because of this in an older website i made… never thought about it…

I did some googling around, and there seems to be a good solution for this in spring:

http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory-method-injection

See: 3.3.7.1. Lookup method injection

Though, coldfspring does not have the lookup method injection implemented.

Basically an abstract method is created in cfc X, cfc X then uses this method to get the bean.
Spring overrides this method to get the bean from the ioc.

You guys are aware of such functionality being implemented in Mark mandell’s new version of coldspring?
Or does coldbox have any comparable functionality?

greets,
klaas

That doesn’t exist in ColdSpring currently, but if you don’t mind being tied to ColdSpring a little, you can get away with making the Bean BeanFactoryAware in ColdSpring.

I’ll write up some tickets to enable lookup-method and replace-method.

Pretty handy stuff!

Mark

Hi Mark,
Cool that your following this thread… thanks for setting up the tickets! where can i follow the tickets exactly?

Yeah, in that article i posted they suggest beanfactoryaware as an alternative…im doing that now…

ColdBox also already has that so it is bean factory aware and coldbox aware, in 3.0. You can just create those methods and the factory will be injected.

setBeanFactory()
setColdBox()

however, if you are in handlers I suggest using the getModel(). If you want this injected in your domain model then use the bean factory aware or coldbox aware functionality.

Lookup method injection ticketed also for WireBox 1.0!

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

http://coldbox.assembla.com/spaces/coldbox/tickets/1015-lookup-method-injection-for-getting-non-singleton-beans


Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

All the links to everything CS2.0 related are on the ColdSpring website:
http://www.coldspringframework.org/

Here are list of all the active tickets by milestone.
https://sourceforge.net/apps/trac/coldspring/report/3

Mark