Help Center

Products
Resources
Security
Support
Sign In
  1. Liferay
  2. Liferay Portal 6.1 Developer Tutorials
  3. Liferay APIs
  • Introduction to Liferay APIs
  • Finding Portal Services
  • Invoking the API Locally
  • Invoking the API Remotely
  • Service Security Layers
  • SOAP Web Services
  • JSON Web Services
  • Service Context
  • Using Message Bus
  • Device Detection
See more

Invoking the API Locally

Each service provides a local interface to clients running in the same JVM as Liferay Portal. There are two ways to invoke a service API’s methods:

  • Spring injection: If your application uses Spring and has access to the portal context.

  • -ServiceUtil classes: These classes mask the complexity of service implementations. This is a good option if you’re not familiar with Spring.

Let’s invoke a service using its -ServiceUtil class. The following JSP code snippet demonstrates how to get a list of the most recent bloggers from an organization.

<%@ page import="com.liferay.portlet.blogs.service.BlogsStatsUserLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.blogs.util.comparator.StatsUserLastPostDateComparator" %>
...
<%@
List statsUsers = BlogsStatsUserLocalServiceUtil.getOrganizationStatsUsers(
    organizationId, 0, max, new StatsUserLastPostDateComparator());
%>

This JSP code invokes the static method getOrganizationStatsUsers() from the -LocalServiceUtil class BlogsStatsUserLocalServiceUtil.

Note: Permission checks are not performed when you invoke services locally (i.e., from the same JVM that’s Liferay Portal runs on). To ensure permission checks are performed, use the remote variant of the API, even from a local context.

Next, find out how you can invoke Liferay’s service APIs remotely.

« Finding Portal Services Invoking the API Remotely »
Was this article helpful?
0 out of 0 found this helpful

Resources

  • Downloads
  • Documentation
  • Activation Keys
  • LESA

Subscription

  • Contact Us
  • Account Support
  • Support FAQs

Related Sites

  • Liferay.com
  • Marketplace
© 2019 Liferay Inc. All Rights Reserved
English (US) Español 日本語 Português 简体中文