Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: How to customize DLAppServiceUtil?
Hello,
following the tutorial Creating a Custom OSGi Service I have been able to customize references to DlAppService. If a component asks for a reference to DlAppService it gets a reference to my customized class DlAppCustomServiceImpl.
I would like to do the same for ServiceUtil classes. But when a jsp calls any method of DlAppServiceUtil the internal method that obtains the service (GetService) returns a reference to the original DlAppServiceImpl instead of a reference to DlAppCustomServiceImpl and my customized code is not invoked. I think it is related to ServiceUtil classes using Spring instead of OSGI to locate the implementation service class but I can't see how to fix it.
What steps should I take so DlAppServiceUtil gets a reference to my DlAppCustomServiceImpl instead of DlAppServiceImpl?
Thanks
Antonio
Hi ,
You need to use Liferay Service Wrapper to override Liferay Services. You can refer to the link below:
Thanks for your answer, Mohammed.
But I think a service wrapper will not help me in my use case.
Imagine I want to filter what FileEntries are shown in the "Document and Media" portlet included with LifeRay. In addition to what Liferay does in the method DlAppServiceUtil.getFoldersAndFileEntriesAndFileShortcuts i want to add code that filters out FileEntries uploaded before the User was created.
My understanding is that I can create a service wrapper that does that but, since the "Document and Media" Portlet is using DlAppServiceUtil and DlAppService but not DlAppServiceWrapper, my new code would not be called by the portlet.
Regards,
Antonio
DLAppServiceWrapper will be called whenever DLAppServiceUtil or DLAppService is being called across the application.
Ex.DlAppServiceUtil.getFoldersAndFileEntriesAndFileShortcuts this method to override in Service Wrapper and add your filter in this. So, whenever DlAppServiceUtil.getFoldersAndFileEntriesAndFileShortcuts is called, it will execute your custom code.
Thanks a lot, Mohammed.
Using a wrapper I have been able to achieve what I wanted.
Regards,
Antonio
Powered by Liferay™