How to override Java class?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Established Member II

How to override 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.

1 Solution

Accepted Solutions
Highlighted
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

4 Replies
Highlighted
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. 

Highlighted
Established Member II

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?

Highlighted
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

Highlighted
Established Member II

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