Every service provides a local interface to clients running in the same JVM as
Liferay Portal. These are called by use of the -ServiceUtil
classes. These
classes mask the complexity of service implementations. The core Liferay
services that are provided as part of Liferay Portal were generated by the same
Service Builder tool that we used in our project. Let’s invoke a Liferay 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
.
In addition to the services you create using Service Builder, your portlets can also access a variety of services built into Liferay. These include the following services:
UserService
- for accessing, adding, authenticating, deleting, and updating users.OrganizationService
- for accessing, adding, deleting, and updating organizations.GroupService
- for accessing, adding, deleting, and updating groups.CompanyService
- for accessing, adding, checking, and updating companies.ImageService
- for accessing images.LayoutService
- for accessing, adding, deleting, exporting, importing, and updating layouts.PermissionService
- for checking permissions.UserGroupService
- for accessing, adding, deleting, and updating user groups.RoleService
- for accessing, adding, unassigning, checking, deleting, and updating roles.
For more information on these services, see the Liferay Portal CE Javadocs at
http://docs.liferay.com/portal/6.1/javadocs/
or the Liferay Portal EE Javadocs included in the Liferay Portal EE
Documentation .zip
file that you can download from the Customer Portal on
http://www.liferay.com.
Next, you’ll learn how to give Liferay portal instructions, or hints, for presenting your entity models in your portlet’s view.