Re: [coldbox:15045] [wirebox 1.1.1] - Singleton question

104 views
Skip to first unread message

Brad Wood

unread,
Jun 1, 2012, 1:59:59 PM6/1/12
to col...@googlegroups.com
Do you have singleton reload turned on in your dev environment?


Sent from my Samsung Epic™ 4G Touch



-------- Original message --------
Subject: [coldbox:15045] [wirebox 1.1.1] - Singleton question
From: brett <bde...@gmail.com>
To: ColdBox Platform <col...@googlegroups.com>
CC:


Now that I'm able to see the debug information coming from wirebox,
I'm noticing that there seems to be an awful lot of instances being
rebuilt even though I have (or think I have) them marked as singletons
in my wirebox config.  This is really slowing down my development.

I have two directories under my model directory in my cbox app:

1) repositories
2) services

The repositories really just act like a data gateway for accessing my
database; and my services directory contains services for security,
biz logic, etc. that make use of the repositories via some cfproperty
injection.  My intent with these services and repositories is that
they are put into the singleton scope so they are just there all wired
up for whatever I need them for.  My wirebox config looks like this:

// Map Bindings below
map('appdsn').toValue(getProperty('datasources').appdsn.name);
mapDirectory('/model.repositories').asSingleton();
mapDirectory('/model.services').asSingleton();

What I'm seeing in my logbox files (see below) is that each time the
LookupRepository is referenced by another service or anything else, it
looks like its being completely rebuilt by wirebox when I would expect
it to just pull it out of the singleton scope and pass it to whoever's
calling it.  As an example the log sample below repeated 12 times
during the processing of one specific event when I would have only
expected to see it once.  Does that seem right?

Thanks in advance.
Brett



LOGOX DEBUGGING

"DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector","Instance
object built: LookupRepository:/model.repositories.LookupRepository"
"DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector","Instance
object built: appdsn:"
"DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector","Dependency:
{JAVACAST={null},NAME={appdsn},DSL={model},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}}
--> injected into LookupRepository"
"DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector","Dependency:
{JAVACAST={null},NAME={DataManipulationPlugin},DSL={coldbox:myPlugin:DataManipulation},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}}
--> injected into LookupRepository"
"DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector","Dependency:
{JAVACAST={null},NAME={logger},DSL={logbox:logger},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}}
--> injected into LookupRepository"
"DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector","Finalized
Autowire for: LookupRepository ExtraInfo:
{DICONSTRUCTORARGS={[]},DIPROPERTIES={[{JAVACAST={null},NAME={appdsn},DSL={model},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}},
{JAVACAST={null},NAME={DataManipulationPlugin},DSL={coldbox:myPlugin:DataManipulation},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}},
{JAVACAST={null},NAME={logger},DSL={logbox:logger},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}}]},PROVIDERMETHODS={[]},NAME={LookupRepository},DSL={},DISCOVERED={true},SCOPE={NoScope},AUTOASPECTBINDING={true},PATH={/
model.repositories.LookupRepository},AUTOINIT={true},EAGERINIT={false},DISETTERS={[]},ALIAS={[LookupRepository]},ONDICOMPLETE={[]},VALUE={},METADATA={{NAME={model.repositories.LookupRepository},FULLNAME={model.repositories.LookupRepository},PROPERTIES={[Ljava.lang.Object;@620205f2},PATH={C:
\ColdFusion9\wwwroot\MyApp\model\repositories
\LookupRepository.cfc},EXTENDS={{NAME={model.repositories._BaseRepository},FULLNAME={model.repositories._BaseRepository},PROPERTIES={[Ljava.lang.Object;@23fcc817},FUNCTIONS={[Ljava.lang.Object;@28b47076},PATH={C:
\ColdFusion9\wwwroot\MyApp\model\repositories
\_BaseRepository.cfc},EXTENDS={{PATH={C:\ColdFusion9\wwwroot\WEB-INF
\cftags\component.cfc},NAME={WEB-INF.cftags.component},FULLNAME={WEB-
INF.cftags.component},TYPE={component}}},TYPE={component}}},OUTPUT={no},TYPE={component}}},AUTOWIRE={true},CACHE={{KEY={},PROVIDER={default},LASTACCESSTIMEOUT={},TIMEOUT={}}},DIMETHODARGS={[]},METHOD={},CONSTRUCTOR={init},ASPECT={false},TYPE={cfc}}"
"DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector","Dependency:
{JAVACAST={null},NAME={LookupRepository},DSL={id:LookupRepository},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}}
--> injected into MyService"



--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

brett

unread,
Jun 1, 2012, 2:14:16 PM6/1/12
to ColdBox Platform
Hi Brad,

I checked and I didn't have anything explicit set in my wirebox
settings in the coldbox.cfc, so I changed it to this just to be on the
safe side and I'm getting the same results:

//WireBox Integration
wireBox = {
enabled = true,
singletonReload=false
};

Any other suggestions?

Thanks.
Brett
> {JAVACAST={null},NAME={appdsn},DSL={model},REQUIRED={false},SCOPE={variable s},VALUE={null},REF={null}}
> --> injected into LookupRepository"
> "DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector" ,"Dependency:
> {JAVACAST={null},NAME={DataManipulationPlugin},DSL={coldbox:myPlugin:DataMa nipulation},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}}
> --> injected into LookupRepository"
> "DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector" ,"Dependency:
> {JAVACAST={null},NAME={logger},DSL={logbox:logger},REQUIRED={false},SCOPE={ variables},VALUE={null},REF={null}}
> --> injected into LookupRepository"
> "DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector" ,"Finalized
> Autowire for: LookupRepository ExtraInfo:
> {DICONSTRUCTORARGS={[]},DIPROPERTIES={[{JAVACAST={null},NAME={appdsn},DSL={ model},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}},
> {JAVACAST={null},NAME={DataManipulationPlugin},DSL={coldbox:myPlugin:DataMa nipulation},REQUIRED={false},SCOPE={variables},VALUE={null},REF={null}},
> {JAVACAST={null},NAME={logger},DSL={logbox:logger},REQUIRED={false},SCOPE={ variables},VALUE={null},REF={null}}]},PROVIDERMETHODS={[]},NAME={LookupRepo sitory},DSL={},DISCOVERED={true},SCOPE={NoScope},AUTOASPECTBINDING={true},P ATH={/
> model.repositories.LookupRepository},AUTOINIT={true},EAGERINIT={false},DISE TTERS={[]},ALIAS={[LookupRepository]},ONDICOMPLETE={[]},VALUE={},METADATA={ {NAME={model.repositories.LookupRepository},FULLNAME={model.repositories.Lo okupRepository},PROPERTIES={[Ljava.lang.Object;@620205f2},PATH={C:
> \ColdFusion9\wwwroot\MyApp\model\repositories
> \LookupRepository.cfc},EXTENDS={{NAME={model.repositories._BaseRepository}, FULLNAME={model.repositories._BaseRepository},PROPERTIES={[Ljava.lang.Objec t;@23fcc817},FUNCTIONS={[Ljava.lang.Object;@28b47076},PATH={C:
> \ColdFusion9\wwwroot\MyApp\model\repositories
> \_BaseRepository.cfc},EXTENDS={{PATH={C:\ColdFusion9\wwwroot\WEB-INF
> \cftags\component.cfc},NAME={WEB-INF.cftags.component},FULLNAME={WEB-
> INF.cftags.component},TYPE={component}}},TYPE={component}}},OUTPUT={no},TYP E={component}}},AUTOWIRE={true},CACHE={{KEY={},PROVIDER={default},LASTACCES STIMEOUT={},TIMEOUT={}}},DIMETHODARGS={[]},METHOD={},CONSTRUCTOR={init},ASP ECT={false},TYPE={cfc}}"
> "DEBUG","COLDBOXFILE","06/01/2012","13:20:56","coldbox.system.ioc.Injector" ,"Dependency:
> {JAVACAST={null},NAME={LookupRepository},DSL={id:LookupRepository},REQUIRED ={false},SCOPE={variables},VALUE={null},REF={null}}

br...@bradwood.com

unread,
Jun 1, 2012, 3:44:38 PM6/1/12
to col...@googlegroups.com
I was looking at your post on my phone over lunch, but looking closer at it now, I see the following lines:

mapDirectory('/model.repositories').asSingleton();
mapDirectory('/model.services').asSingleton();

You shouldn't chain "asSingleton()" after "mapDirectory()".  asSingleton() will only apply to the last mapping which was processed, not all the mappings created from that directory.

I would recommend going the route of adding the singleton=true annotation in all your singleton CFCs.  Your only other option is to map them all explicitly by name.

On a side note, Luis, what do you think about enhancing the WireBox binder so that asSingleton() and other chainable methods would work with mapDirectory()?  If we changed currentMapping
 to be an array of mappings, then mapDirectory() could append each mapping it creates and methods like asSingletion(), asEagerInit() could apply themselves to each mapping in the array.  Just a thought.

Thanks!

~Brad

brett

unread,
Jun 1, 2012, 4:20:54 PM6/1/12
to ColdBox Platform
Brad,

Thanks, I will go down the road of adding the singleton attribute to
my CFCs and let you know how it goes.

Brett
> > To post to this group, send email toco...@googlegroups.com
> > To unsubscribe from this group, send email tocoldbox-...@googlegroups.com
> > For more options, visit this group athttp://groups-beta.google.com/group/coldbox
> > For News, visithttp://blog.coldbox.org
> > For Documentation, visithttp://wiki.coldbox.org
> --
> You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
> To post to this group, send email toco...@googlegroups.com
> To unsubscribe from this group, send email tocoldbox-...@googlegroups.com

brett

unread,
Jun 1, 2012, 5:16:17 PM6/1/12
to ColdBox Platform
Brad,

Just updated the CFC's in my services and repositories directory to
include the singleton attribute and it worked beautifully. Thanks so
much for your help. My pages are loading at least ten times faster.

Brett

Brad Wood

unread,
Jun 1, 2012, 5:43:46 PM6/1/12
to col...@googlegroups.com
Most excellent news!

Thanks!

~Brad
Reply all
Reply to author
Forward
0 new messages