05-10-2017 04:33 AM
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
05-16-2017 11:02 AM
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.
05-15-2017 06:25 AM
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.
05-16-2017 10:46 AM
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
05-16-2017 11:02 AM
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.
04-13-2019 01:07 AM
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
04-13-2019 06:49 PM
Sorry, my fault...it is working and my class is loaded and running the way it is explained. Thank you Axel
03-26-2023 08:18 AM
I am trying same approach for other service but not working.
05-19-2017 04:25 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.