Message Boards

Override core class

Daniel G, modified 3 Years ago.

Override core class

Regular Member Posts: 141 Join Date: 3/14/17 Recent Posts
Hi.
I am working with Liferay 7.1. I want to override one core class: HtmlBBCodeTranslatorImpl
https://github.com/liferay/liferay-portal/blob/7.1.x/modules/apps/message-boards/message-boards-parser-bbcode/src/main/java/com/liferay/message/boards/parser/bbcode/internal/HtmlBBCodeTranslatorImpl.java

is there any option of doing it without override the entire module and place it in override? Any help you can give me would be very appreciated
Thanks in advance
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Override core class

Liferay Legend Posts: 6396 Join Date: 9/23/08 Recent Posts
Daniel G:

Hi.
I am working with Liferay 7.1. I want to override one core class: HtmlBBCodeTranslatorImpl
https://github.com/liferay/liferay-portal/blob/7.1.x/modules/apps/message-boards/message-boards-parser-bbcode/src/main/java/com/liferay/message/boards/parser/bbcode/internal/HtmlBBCodeTranslatorImpl.java

is there any option of doing it without override the entire module and place it in override? Any help you can give me would be very appreciated

There might be, but you'll need to stop thinking in terms of "overriding". Looking at the code you link, it's a proper declarative service, and while the "internal" package and the "Impl" class name suggest that it's well locked away, nothing keeps you from implementing another service that does what you need.
I haven't tried it for this particular service, but this and the following chapters in OSGi Basics (free registration / sign in required) might help you to provide such an alternative implementation. Of course, Liferay's implementation might use quite a bit of more internal code that you won't have access to, but that would be the next problem.
Sometimes, module overrides aren't the best maintainable option, sometimes they are. Try both, then judge which solution you expect to be the best maintainable one under the circumstances (code dependencies) that you find.