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?
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...
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>
Hi Faust, which is it the bean of the "dynamic model loading" on Alfresco 5/6 ?
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).
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
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.