How many service types are there in liferay,How to use them?

Jamie Sammons, modified 7 Years ago. Junior Member Posts: 56 Join Date: 1/17/11 Recent Posts

In liferay 7.1, there are many service types in component. How many service types are there in liferay. which major classes are included. How to use them?

 

For example : service = Portlet.class, MVCRenderCommand.class, PortletDataHandler.class, PanelApp.class and so on. What are the effects of these classes? Where can I find detailed instructions except the source code?

@Component(
    immediate = true,
    service = Portlet.class
)

 

@Component(
    property = {
        "javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY,
        "javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY_ADMIN,
        "mvc.command.name=/", "mvc.command.name=/document_library/view",
        "mvc.command.name=/document_library/view_folder"
    },
    service = MVCRenderCommand.class
)

 

@Component(
    property = {
        "javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY,
        "javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY_ADMIN,
        "javax.portlet.name=" + DLWebKeys.PRODUCTS_DATA_DISPLAY
    },
    service = PortletDataHandler.class
)

 

@Component(
    immediate = true,
    property = {
        "panel.app.order:Integer=400",
        "panel.category.key=" + PanelCategoryKeys.SITE_ADMINISTRATION_CONTENT
    },
    service = PanelApp.class
)

 

if i create a new module, When do I create a similar class interface?

thumbnail
David H Nebinger, modified 7 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

Okay, the "service" moniker in OSGi does not necessarily mean "service".  It basically binds a common, well, let's say "trackable category" to classes that are exposed as OSGi components.

The portlet for example, is not a portlet service like a web service or a database access service.

But Liferay does use OSGi Service Trackers so the code that knows how to make portlets available, knows how to delegate incoming requests, etc can find all of the installed and active Portlet components in the system.

When you create a module, you add the "service" class so that OSGi will include it in the "trackable category" where it belongs.  Portlets are portlets, PanelApps are control panel entries, PortletDataHandlers will be invoked to handle portlet data export/import, yada yada yada.  These are all special Liferay classes that will include your component into appropriate places in the Liferay echosystem.

You might define a new "service" when you are building out a pluggable system that would be resolvable at runtime.  For example, you might create your very own audit "service" and then implement different varieties that might persist in a database, in the filesystem, into an Elastic index, etc.