Modules and Model-Caching

I discovered another question.
When autowiring/caching a model in Modules, each model.CFC
has to be named unique, otherwise it is not cached separate.

I added a Modelmapping to each ModuleConfig:

Module 1
modelMappings = {
  "mod1Service@mod1" = {
    path = "AppService"
  }
};

Module 2
modelMappings = {
  "mod2Service@mod2" = {
    path = "AppService"
  }
};

The Cache Monitor shows the Object named as "appservice".

Shoudn't the key be named something like "model-cms.modules.mod1.appservice"
in the same syntax as modules handlers or "mod1Service@mod1" to keep
it unique? The property injection also refers to "mod1Service@mod1".

Regards,
Daniel

lists@platform.ch

Good point, I have made a ticket for this.

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 Luis

Thanks for the Update on the Beanfactory.cfc.
I repeated my tests today using the new Beanfactory.cfc.
ColdBox Cache now shows up 2 unique Objects:
model-service@mod1-cms.modules.mod2.model.service
model-service@mod2-cms.modules.mod2.model.service

But Module 1 still calls the ServiceObject of Module 2 instead
of Module 1, no matter what order the Module is loaded or
called the first time.

Am i missing something in my Configuration?
To me locateModel() seams to return the wrong modelClassPath (Beanfactory.cfc)
locateModel() looks up the instance.ModelsExternalLocation instead of explicit
looking at the modules model path. This way it just returns the first cfc that
matches its name.

Would locateModel() need to be extended with the modules-information, to
keep the Module-Models encapsulated?

Daniel

Details of my Module Configuration:

Modules Model-Objects get cached twice but still refer to the same
object.
Models have to be named unique inbetween multiple Modules to be
cached
separate, because locateModel() in Beanfactory.cfc doesn't locate the
Model-CFC in the modules-Models folder only.

ColdBox Cache now shows up 2 unique Objects, but refers to the same
CFC

Module 1 (modules/mod1/model/Service.cfc)
Cache > model-serv...@mod1-cms.modules.mod2.model.service

Module 2 (modules/mod2/model/Service.cfc)
Cache > model-serv...@mod2-cms.modules.mod2.model.service

Daniel

Interesting, I will look more into this.
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

I prepared a smal example based on your Advanced ApplicationTemplate
to show how
modules-models load and persist in CB's Cache:

http://coldbox3.platform.ch/pubtests/Advanced

Download:
http://coldbox3.platform.ch/pubtests/Advanced.tgz

In 1st and 2nd module the model-file is named Service.cfc
In 3rd and 4th they are named unique ...

Regards, Daniel

Thanks for the hint, Luis

Using the full path as recommended, solved my problem

modelMappings = {
    "Service@mod2" = {
      path="#variables.moduleMapping#.model.Service"
    }
  };

Regards,
Daniel