How to override ActivitiesFeed subsystem Java class?

cancel
Showing results for 
Search instead for 
Did you mean: 
upforsin
Senior Member

How to override ActivitiesFeed subsystem Java class?

Jump to solution

Hello,

I want to change a bit the FeedNotifier. To achieve it I have to add a few lines of code to FeedTaskProcessor.java.

How Can I override this file?

I'm using dockerized Alfresco 6.1.2 and I tried to create a "FeedTaskProcessor" class in  "org.alfresco.repo.activities.feed" package in the "src/main/java" path in the my-project-platform project. But it does not work.

howkymike
Alfresco Developer
2 Solutions

Accepted Solutions
narkuss
Established Member II

Re: How to override Java class?

Jump to solution

In first place I thought to override only the affected beans, no the entire context file, in your project's bootstrap-context.xml file.

But being a subsystem's bean, you have to override the route to the original context file (that is, my-project-platform/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/), as extensions directory does not work, although I think it should be the place to override existing subsystem context files. I just checked a project where we override ooo subsystem context files, and we did not use extensions directory.

I don't know exactly which is the best practice for overriding subsystem's beans, the big ones of this forum could help you more than me at this, and I would be interested in understanding that too.

View solution in original post

upforsin
Senior Member

Re: How to override Java class?

Jump to solution

Previous sollution does not seem to be working anymore...

However, when I create a

src/main/resources/alfresco/extension/subsystems/ActivitiesFeed/default/default/custom-activities-feed-context.xml

file, it works (is it a deprecated method?). There I can override only some beans, I do not have to override them all.

 

 

@resplin mentioned also 7years ago something about custom-activities-context.xml file but it does not have acess to the subsystem's beans.

I find it really sad that it is documented nowhere. 

 

 

 

howkymike
Alfresco Developer

View solution in original post

5 Replies
narkuss
Established Member II

Re: How to override Java class?

Jump to solution

There should be a spring bean which declares this class in the jar artifact. You should declare this bean in your project, and subsitute their class implementation with your own modified class. 

upforsin
Senior Member

Re: How to override Java class?

Jump to solution

Thank you. There is indeed a file called activities-feed-context.xml which includes this bean of my interest. But where should I put modified version of this file?

Originally it is in the "alfresco-repository/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/" path, should I put it in the "my-project-platform/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/" folder or maybe should I use the "extension" directory and put it in the "my-project-platform/src/main/resources/extension/alfresco/subsystems/ActivitiesFeed/default/" or maybe with other Spring beans in the "my-project-platform/src/main/resources/alfresco/module/my-project-platform/context" ?

Sorry for that trivial question but I'm really lost with those paths

 

 

EDIT. I tried to put it in the "my-project-platform/src/main/resources/alfresco/extension/subsystems/ActivitiesFeed/default/activities-feed-context.xml" but it does not work...

I created my own LocalFeedTaskProcessor, LocalFeedGenerator and FeedGenerator classes and I replaced their paths in the bean's class attribute inside the activities-feed-context.xml. Why it does not work?

howkymike
Alfresco Developer
narkuss
Established Member II

Re: How to override Java class?

Jump to solution

In first place I thought to override only the affected beans, no the entire context file, in your project's bootstrap-context.xml file.

But being a subsystem's bean, you have to override the route to the original context file (that is, my-project-platform/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/), as extensions directory does not work, although I think it should be the place to override existing subsystem context files. I just checked a project where we override ooo subsystem context files, and we did not use extensions directory.

I don't know exactly which is the best practice for overriding subsystem's beans, the big ones of this forum could help you more than me at this, and I would be interested in understanding that too.

upforsin
Senior Member

Re: How to override Java class?

Jump to solution

Thank you, it's working now <3

 


@narkuss wrote:

I don't know exactly which is the best practice for overriding subsystem's beans, the big ones of this forum could help you more than me at this, and I would be interested in understanding that too.


I would also really appreciate a short guide on this subject Smiley Very Happy

howkymike
Alfresco Developer
upforsin
Senior Member

Re: How to override Java class?

Jump to solution

Previous sollution does not seem to be working anymore...

However, when I create a

src/main/resources/alfresco/extension/subsystems/ActivitiesFeed/default/default/custom-activities-feed-context.xml

file, it works (is it a deprecated method?). There I can override only some beans, I do not have to override them all.

 

 

@resplin mentioned also 7years ago something about custom-activities-context.xml file but it does not have acess to the subsystem's beans.

I find it really sad that it is documented nowhere. 

 

 

 

howkymike
Alfresco Developer