« Back

Liferay Wrapper Plugins

Company Blogs February 9, 2010 By Juan Fernández Staff

 Hi guys:

this week I have been working in the Asset Importer, a portlet that reads a file (odt for the moment) and converts it into a web content so that you can publish your documents an your website.
We will use this to publish Liferay documentation in Liferay.com very soon
Developing this portlet I had to use for the first time a wrapper plugin. This is a variation of the hook plugin that allows you to extend core functionallity by creating a wrapper for a concrete core class... and there's no documentation at all, so that's why I'm writing this! :)
In my case I needed to do a few things everytime the user deletes a journal article, so here you have how I did it:
How to use Liferay's Wrapper Plugins
Note: I'll use a example that extends JournalArticle deletion to be more illustrative.
The steps to do to use this functionallity are the following:
Create a file called liferay-hook.xml with the following content and place it docroot/WEB-INF:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 5.2.5//EN" "http://www.liferay.com/dtd/liferay-hook_5_2_0.dtd">
The first class is the service you want to extend
The second class is the one that implements the modifications
Create a class that extends the wrapper you want to use and add the basic constructor (in my case it is JournalArticleLocalServiceWrapper):
public class JournalArticleLocalServiceWrapperImpl extends JournalArticleLocalServiceWrapper {
public JournalArticleLocalServiceWrapperImpl(JournalArticleLocalService journalArticleLocalService) {
Add the methods you want to overwrite in that class:
public void deleteArticle(long groupId, java.lang.String articleId, double version,
java.lang.String articleURL, com.liferay.portal.service.ServiceContext serviceContext)
 throws com.liferay.portal.PortalException, com.liferay.portal.SystemException { 
[... all my custom code here...]
And that's all: you deploy your portlet/plugin and you'll see it in action!
By the way, you have a great example by Brian Chan in the test-hook-portlet
Juan Fernández
ps: I have created a wiki page with this entry in the development section


Threaded Replies Author Date
Good feature. Thank you, Juan. Jonas Yuan February 9, 2010 11:35 AM
Hi Juan, Do you have a plan to make Asset... Jonas Yuan February 9, 2010 12:06 PM
Hi Jonas: for the moment it is going to be used... Juan Fernández February 10, 2010 1:12 AM
Do you have any plans to expand the... tim tian February 10, 2010 5:41 PM
Do you plan on shipping the Asset Importer... André Aronsen November 15, 2010 1:53 AM
Hi André: for the moment we have put it into... Juan Fernández November 15, 2010 2:17 AM
Which of the core functionality can be expanded... Matthew O Smith September 22, 2011 11:24 AM

Good feature. Thank you, Juan.
Posted on 2/9/10 11:35 AM.
Hi Juan,

Do you have a plan to make Asset Importer working in 6.0?

It seems that current Asset Importer is working for EE 5.2.5 (or EE 5.2 SP2 or SP3) only.
Posted on 2/9/10 12:06 PM.
Hi Jonas:
for the moment it is going to be used in Liferay.com, which is build in EE SP3 version, but we'll surely migrate it to CE 6.0 as soon as possible.
I'll update this post when I have more information about this

Thanks for the comments emoticon
Posted on 2/10/10 1:12 AM in reply to Jonas Yuan.
Do you have any plans to expand the JournalArticleFinder and JournalArticlePersistence ?
When will CE 6.0 be released ?
Posted on 2/10/10 5:41 PM.
Do you plan on shipping the Asset Importer plugin with the Liferay 6 bundle?
Posted on 11/15/10 1:53 AM.
Hi André:
for the moment we have put it into production in Liferay.com (we've generated liferay.com/documentation with it), but it's true that we need to upgrade it.

For now it's only available for the 5.2 enterprise edition, but we don't have any update dates.

I'll talk with the team to see if I can invest some time in upgrading this and I'll get to you as soon as I know something.

Regards and thanks for you interest
Posted on 11/15/10 2:17 AM in reply to André Aronsen.
Which of the core functionality can be expanded using wrappers?
Posted on 9/22/11 11:24 AM.