Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-91515

ServiceTrackerCustomizer doesn't honor service ranking

    Details

    • Fix Priority:
      2

      Description

      On Liferay core we have many XXXRegistryUtil (TrashHandlerRegistryUtil, AssetRenderFaxctoryRegistryUtil, ...) that use a ServiceTrackerCustomizer class to fill a Map<String, clazz> of available implementations.

      The ServiceTrackerCustomizer listen on components activation and deactivation and add or remove the referenced service to a Map.

      The problem arise when you have to customize the Component implementation.

       

      I will explain it with an example. In the attached module we have:

      • a gogo command with the action smc:listHandlers
      • a minimal customization of BlogsEntryTrashHandler

      The bundle is compatible with 7.2 alpha 1, but the same problem is demostrable in 7.1 and 7.0.

      Install the bundle and enter into the gogo shell.

      Use lb to identity bundle id (907 in my example), and src:list to show its content

        906|Active     |   10|westeros-bank-theme (3.0.0)|3.0.0
        907|Active     |   10|SMC Trash Handler Check (1.0.0)|1.0.0
      g! scr:list 907
      it.smc.tracker.check.internal.CheckCommand in bundle 907 (it.smc.tracker.check:1.0.0) enabled, 1 instance.
          Id: 4821, State:SATISFIED
      it.smc.tracker.check.internal.CustomBlogsEntryTrashHandler in bundle 907 (it.smc.tracker.check:1.0.0) disabled, 0 instances.
      

      CustomBlogsEntryTrashHandler is disabled.

       

      Use smc:listHandlers to have a list of known trash handlers.

      g! smc:listHandlers
      

      You will have two list. The first one by TrashHandlerRegistryUtil and the second one using a ServiceTrackerMap

      2019-03-04 14:26:56.149 INFO  [pipe-smc:listHandlers][CheckCommand:28] listHandlers from TrashHandlerRegistryUtil
      2019-03-04 14:26:56.153 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.blogs.model.BlogsEntry : [email protected]
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.bookmarks.model.BookmarksEntry : com.[email protected]5ed27556
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.bookmarks.model.BookmarksFolder : com.l[email protected]3480d6c
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.calendar.model.CalendarBooking : [email protected]2530c017
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFileEntry : com.[email protected]203f591b
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFileShortcut : com.lif[email protected]6d8ae08f
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFolder : c[email protected]2e6ab33f
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.exportimport.kernel.model.ExportImportConfiguration : com.liferay.export[email protected]d79fe9d
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.journal.model.JournalArticle : [email protected]5489a8
      2019-03-04 14:26:56.154 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.journal.model.JournalFolder : [email protected]08555
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBCategory : c[email protected]16e8308d
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBMessage : [email protected]54a7a9db
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBThread : [email protected]7cd632e
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.wiki.model.WikiNode : [email protected]f
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.wiki.model.WikiPage : [email protected]7
      
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:36] listHandlers from ServiceTrackerMap
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBCategory=c[email protected]16e8308d
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.wiki.model.Wi[email protected]19d53da7
      2019-03-04 14:26:56.155 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBThread[email protected]27cd632e
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFileEntry=com.[email protected]203f591b
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.bookmarks.model.BookmarksFolder=com.l[email protected]3480d6c
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.blogs.model.Blo[email protected]3ef76fad
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFolder=c[email protected]2e6ab33f
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.exportimport.kernel.model.ExportImportConfiguration=com.liferay.export[email protected]d79fe9d
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.journal.model.JournalArticl[email protected]575489a8
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.bookmarks.model.BookmarksEntry=com.[email protected]5ed27556
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFileShortcut=com.lif[email protected]6d8ae08f
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.journal.model.JournalFold[email protected]6d608555
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBMessage=[email protected]54a7a9db
      2019-03-04 14:26:56.156 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.wiki.model.Wi[email protected]4eee10af
      

       the second one is unsorted but you can easily identify BlogsEntryTrashHandler on both.

       

      Now we can enable our custom TrashHandler and investigate changes

      g! enable it.smc.tracker.check.internal.CustomBlogsEntryTrashHandler
      true
      g! smc:listHandlers

      the output is

      2019-03-04 14:27:58.182 INFO  [pipe-smc:listHandlers][CheckCommand:28] listHandlers from TrashHandlerRegistryUtil
      2019-03-04 14:27:58.182 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.blogs.model.BlogsEntry : [email protected]73a
      2019-03-04 14:27:58.182 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.bookmarks.model.BookmarksEntry : com.[email protected]5ed27556
      2019-03-04 14:27:58.182 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.bookmarks.model.BookmarksFolder : com.l[email protected]3480d6c
      2019-03-04 14:27:58.183 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.calendar.model.CalendarBooking : [email protected]2530c017
      2019-03-04 14:27:58.183 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFileEntry : com.[email protected]203f591b
      2019-03-04 14:27:58.183 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFileShortcut : com.lif[email protected]6d8ae08f
      2019-03-04 14:27:58.183 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFolder : c[email protected]2e6ab33f
      2019-03-04 14:27:58.183 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.exportimport.kernel.model.ExportImportConfiguration : com.liferay.export[email protected]d79fe9d
      2019-03-04 14:27:58.183 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.journal.model.JournalArticle : [email protected]5489a8
      2019-03-04 14:27:58.183 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.journal.model.JournalFolder : [email protected]08555
      2019-03-04 14:27:58.184 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBCategory : c[email protected]16e8308d
      2019-03-04 14:27:58.184 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBMessage : [email protected]54a7a9db
      2019-03-04 14:27:58.184 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBThread : [email protected]7cd632e
      2019-03-04 14:27:58.184 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.wiki.model.WikiNode : [email protected]f
      2019-03-04 14:27:58.184 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.wiki.model.WikiPage : [email protected]7
      
      2019-03-04 14:27:58.184 INFO  [pipe-smc:listHandlers][CheckCommand:36] listHandlers from ServiceTrackerMap
      2019-03-04 14:27:58.184 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBCategory=c[email protected]16e8308d
      2019-03-04 14:27:58.185 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.wiki.model.Wi[email protected]19d53da7
      2019-03-04 14:27:58.185 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBThread[email protected]27cd632e
      2019-03-04 14:27:58.185 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFileEntry=com.[email protected]203f591b
      2019-03-04 14:27:58.185 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.bookmarks.model.BookmarksFolder=com.l[email protected]3480d6c
      2019-03-04 14:27:58.185 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.blogs.model.BlogsE[email protected]6517e73a
      2019-03-04 14:27:58.185 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFolder=c[email protected]2e6ab33f
      2019-03-04 14:27:58.185 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.exportimport.kernel.model.ExportImportConfiguration=com.liferay.export[email protected]d79fe9d
      2019-03-04 14:27:58.186 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.journal.model.JournalArticl[email protected]575489a8
      2019-03-04 14:27:58.186 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.bookmarks.model.BookmarksEntry=com.[email protected]5ed27556
      2019-03-04 14:27:58.186 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFileShortcut=com.lif[email protected]6d8ae08f
      2019-03-04 14:27:58.186 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.journal.model.JournalFold[email protected]6d608555
      2019-03-04 14:27:58.186 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBMessage=[email protected]54a7a9db
      2019-03-04 14:27:58.186 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.wiki.model.Wi[email protected]4eee10af

      As expected our custom implementation is registered on both.

       

      Now we disable our custom implementation and take a look on result

      g! disable it.smc.tracker.check.internal.CustomBlogsEntryTrashHandler
      true
      g! smc:listHandlers

      the output is

      2019-03-04 14:29:02.895 INFO  [pipe-smc:listHandlers][CheckCommand:28] listHandlers from TrashHandlerRegistryUtil
      2019-03-04 14:29:02.896 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.bookmarks.model.BookmarksEntry : com.[email protected]5ed27556
      2019-03-04 14:29:02.897 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.bookmarks.model.BookmarksFolder : com.l[email protected]3480d6c
      2019-03-04 14:29:02.897 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.calendar.model.CalendarBooking : [email protected]2530c017
      2019-03-04 14:29:02.898 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFileEntry : com.[email protected]203f591b
      2019-03-04 14:29:02.898 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFileShortcut : com.lif[email protected]6d8ae08f
      2019-03-04 14:29:02.899 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.document.library.kernel.model.DLFolder : c[email protected]2e6ab33f
      2019-03-04 14:29:02.900 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.exportimport.kernel.model.ExportImportConfiguration : com.liferay.export[email protected]d79fe9d
      2019-03-04 14:29:02.900 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.journal.model.JournalArticle : [email protected]5489a8
      2019-03-04 14:29:02.901 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.journal.model.JournalFolder : [email protected]08555
      2019-03-04 14:29:02.901 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBCategory : c[email protected]16e8308d
      2019-03-04 14:29:02.902 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBMessage : [email protected]54a7a9db
      2019-03-04 14:29:02.902 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.message.boards.model.MBThread : [email protected]7cd632e
      2019-03-04 14:29:02.902 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.wiki.model.WikiNode : [email protected]f
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:33] com.liferay.wiki.model.WikiPage : [email protected]7
      
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:36] listHandlers from ServiceTrackerMap
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBCategory=c[email protected]16e8308d
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.wiki.model.Wi[email protected]19d53da7
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBThread[email protected]27cd632e
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFileEntry=com.[email protected]203f591b
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.bookmarks.model.BookmarksFolder=com.l[email protected]3480d6c
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.blogs.model.Blo[email protected]3ef76fad
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFolder=c[email protected]2e6ab33f
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.exportimport.kernel.model.ExportImportConfiguration=com.liferay.export[email protected]d79fe9d
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.journal.model.JournalArticl[email protected]575489a8
      2019-03-04 14:29:02.903 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.bookmarks.model.BookmarksEntry=com.[email protected]5ed27556
      2019-03-04 14:29:02.904 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.document.library.kernel.model.DLFileShortcut=com.lif[email protected]6d8ae08f
      2019-03-04 14:29:02.904 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.journal.model.JournalFold[email protected]6d608555
      2019-03-04 14:29:02.904 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.message.boards.model.MBMessage=[email protected]54a7a9db
      2019-03-04 14:29:02.904 INFO  [pipe-smc:listHandlers][CheckCommand:39] com.liferay.wiki.model.Wi[email protected]4eee10af

      Sadly TrashHandlerRegistryUtil has no more a BlogsEntry handler registered.

      Differently, using a ServiceTrackerMap, the original component comes back the current one.

       

        Attachments

          Activity

            People

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            maumar Mauro Mariuzzo
            Participants of an Issue:
            Recent user:
            Mauro Mariuzzo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              1 year, 35 weeks ago

                Packages

                Version Package