Hi,
I'm doing the update from Alfresco version 5.0.2 to 5.1.2.
I overwrote the bean peopleScript with my own class ch.elesta.userprofile.repo.jscript.PeopleElesta in a file elesta-people-model-context.xml localized in src/main/amp/config/alfresco/extension in my repo project. I can garantee that the deploy to the war is done correctly.
It could overwrite the class org.alfresco.repo.jscript.People.java in the version 5.0.2 without any problem. Now it's not overwriting anymore. The class org.alfresco.repo.jscript.People keeps beeing used when I search a person in the people-finder page.
I cannot understand why thsi overwrite is not done.
I attached the file with my overwrite.
Thanks,
Francisco
Solved! Go to Solution.
One important thing to keep in mind is that a post processor will run after ALL the XML has been read, so by that point the Enterprise bean definition has already overriden the original one, so the originalClassName will no longer be present.
An additional aspect to consider is that you may be disabling / breaking an Enterprise-specific feature by overriding the Enterprise bean class. In your case it might be preferable to have your custom class extend from the Enterprise class instead of the base class.
Your running on Alfresco Enterprise. Enterprise edition includes a specific override for the peopleScript bean itself so you may simply have a conflict there in that the Enterprise-edition extension files are loaded after yours.
Spring bean XML overrides are always prone to breaking in such a way since any XML file may be loaded after yours and disrupt your customisation. I always recommend using Spring post processors to modify/enhance beans at runtime. This has been showcased in one of my Gists and I have included this in my Acosix utility module.
Hi Axel,
Thank you for your answer, for this information about Enterprise edition and for the links.
It's also good to know that the Spring post processors should always be used. I will do it from now on if any bean must be overridden.
But I tried to use a bean with a class ImplementionClassReplacingBeanFactoryPostProcessor using org.alfresco.repo.jscript.People as originalClassName and ch.elesta.example.PeopleElesta as replacementClassName.
I could see that the beanDefinition was correctly set with the new class and I was thinking that this post processor could also avoid that the Enterprise edition overrides the peopleScript bean, but it keeps overriding.
I will keep trying to avoid the override for bean peopleScript by Enterprise Edition.
Thanks,
Francisco
One important thing to keep in mind is that a post processor will run after ALL the XML has been read, so by that point the Enterprise bean definition has already overriden the original one, so the originalClassName will no longer be present.
An additional aspect to consider is that you may be disabling / breaking an Enterprise-specific feature by overriding the Enterprise bean class. In your case it might be preferable to have your custom class extend from the Enterprise class instead of the base class.
Yes, for the Enteprise Edition I used the post processor with the bean enterprisePeopleScript as targetBeanName and org.alfresco.enterprise.repo.jscript.EnterprisePeople as originalClassName.
My custom class used in replacementClassName extends now the EnterprisePeople class.
The people search is now working using my custom class.
Thank you Axel,
Francisco
Hi Axel,
I am trying to do the following using your class but I am still having the default class loaded and running. Any idea?
<bean class="de.axelfaust.examples.beans.ImplementationClassReplacingBeanFactoryPostProcessor">
<property name="targetBeanName" value="invitationService" />
<property name="originalClassName" value="org.alfresco.repo.invitation.InvitationServiceImpl" />
<property name="replacementClassName" value="org.alfresco.repo.invitation.MyInvitationServiceImpl" />
<property name="enabled" value="true" />
</bean>
Thank you
Jamil
Sorry, my fault...it is working and my class is loaded and running the way it is explained. Thank you Axel
I am trying same approach for other service but not working.
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.