Reputation: 14572
I would like know that what is the best way of knowing that existing or currently deployed portlet/application is being used at somewhere in portal.
Ex:
Apart from creating a LayoutListener or extending LayoutLocalService is there a way to listen to these events. What is the best way, if I want to keep track of those events?
I found this question in SO. But not a very usable answer.
Upvotes: 0
Views: 82
Reputation: 48067
Technically, Liferay has ModelListeners (e.g. LayoutListener) that get notified on changes to properties of a Layout. However, you should only use them for persistence-related operations, not for business-layer operations. Instead, use ServiceWrappers - e.g. for LayoutLocalService. Identify the API methods that you're interested in, wrap them and execute your custom code before or after the original implementation. You might need to wrap a few methods, but the code changes will be clean in these services.
As you give some examples, let me make some remarks
This is certainly relatively easy when you refer to a "Web Content Display Portlet" being added to a page. However, if a "Web Content Article" is now displayed on an AssetPublisher because it fits the criteria, this is not so easy.
If you're just interested in the addition of a portlet on a page, this is easier than if the configuration changes. For a "Web Content Display Portlet" this can mean that now a different article will be shown on the page, even though the portlet stayed the same.
(While I wrote the answer my internet connection broke - I couldn't check the actual APIs, but hope to keep this page open to submit later when I probably can't investigate any more)
Upvotes: 1