10-17-2018 09:00 AM
I have deployed the custom model by the dynamic approach. I am trying to develop a behavior which will get triggered on Add aspect.
public void init() {
this.onAddAspect = new JavaBehaviour(this, "onAddAspect", NotificationFrequency.TRANSACTION_COMMIT);
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI,"onAddAspect"),QName.createQName("http://www.xyz.com/model/recruitment/1.0", "jobPostingEdit"), this.onAddAspect);
}
The jobPostingEdit Aspect belongs to model deployed dynamically.
While compiling it gives this issue.
Caused by: java.lang.IllegalArgumentException: Class {http://www.xyz.com/model/recruitment/1.0}jobPostingEdit has not been defined in the data dictionary
The Aspect is active and applied to documents and configured correctly.
Can we add behavior policy on Types or Aspect created dynamic approach or by the model manager?
10-18-2018 04:26 AM
You cannot define a behaviour against a model elements deployed dynamically using the common patterns documented for behaviours. This is due to the initiatlisation order of the behaviour and the model. Dynamic models are typically loaded on startup but after Spring singleton beans have been initialised. Since your behaviour is a Spring singleton bean and you are using an init-method to bind your behaviour, this binding happens before dynamic models had a chance to load. You may have to switch from using an init-method to using a Spring application event listener, and bind your behaviour once Alfresco has completed startup (including dynamic model loading).
Also be aware that dynamic models are loaded within the context of the tenant, so if you have enabled multi-tenancy, you are likely not able to bind a behaviour at all, since behaviours implemented via Spring beans are always global, and can't reference model elements from tenant contexts...
10-21-2018 11:53 PM
This seems like a good time to reiterate that devs really shouldn't be using the model manager to define content models.
<cynical_view>I think that feature is really just for demonstration purposes for decision makers. Once the deal is closed and the real work begins, it's time to switch to XML based content models deployed via an AMP.</cynical_view>
07-14-2021 03:34 AM
Hi Faust, which is it the bean of the "dynamic model loading" on Alfresco 5/6 ?
07-14-2021 03:42 AM
The bean responsible for loading any Repository-stored model (including those via Model Manager) is "dictionaryRepositoryBootstrap", though I don't really see how that information would help anyone deal with the underlying issue(s).
05-19-2022 05:58 AM
Hi Axel,
Could you please tell us to which Spring event to listen to in order to be sure that Alfresco has finished its startup ? More specifically that Alfresco has finished to load XML model ?
Thanks,
Vincent
Explore our Alfresco products with the links below. Use labels to filter content by product module.