This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. Extending a portal service from a plugin
Table of Contents [-]
Introduction #
This article's goal is to add a new method that grants all plugins access to Util class from the portal.
More Info #
The example is done using JournalArticleUtil's method fetchByUUID_G, which is non-accessible as long as it's not included in JournalArticleLocalServiceImpl.java (Don't worry: this is going to be fixed for Liferay 6! - update: this has been fixed in this ticket).
Example #
Steps #
1. In a new plugin's service.xml file, add an empty entity with a reference to JournalArticle (the service we want to extend):
<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 5.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_5_2_0.dtd">
<service-builder package-path="com.ext.portlet.test">
<namespace>MyJournal</namespace>
<entity name="MyJournal" local-service="true" remote-service="true">
<reference package-path="com.liferay.portlet.journal" entity="JournalArticle" />
</entity>
</service-builder>2. Launch ant build-service task.
3. In MyJournalLocalServiceImpl.java (automaticaly generated by the service builder) add your desired method:
public class MyJournalLocalServiceImpl extends MyJournalLocalServiceBaseImpl {
public JournalArticle getArticleByUUID_G(String uuid, long groupId)
throws SystemException {
return JournalArticleUtil.fetchByUUID_G(uuid, groupId);
}
}4. Repeat step 2.
5. The 4th step has generated a .jar library in WEB-INF/lib which is necesary for the rest of the portlets to access our new method. It should look like something like "my-custom-portlet-service.jar".
This is the CLP inter-portlet communication (see this wiki article: CLP Communication).
6. Copy this .jar to the lib folder of your application service (in Tomcat /lib/ext) and the delete the original jar.
7. Restart the application server, and now you can access your method in other plugins.