Wednesday, December 10, 2014

Liferay Hook Plugin Development with Liferay IDE

Liferay hook Plugin is one of the Plugin type in liferay to customize liferay portal.
Hook have many capabilities so that we can customize liferay portal and its hot deployable plugins. Liferay Plugins SDK have support to develop hook plugins.

Please follow the articles before start this development.



We have many choices to start liferay development




In this article we are going to see hook development with Liferay IDE. Before start development we need to be ready with development environment that is using Liferay IDE.

Please follow the below articles to setup Liferay Development Environment with Liferay IDE



Liferay Hook Plugin Project Creation

Start your eclipse

go to File-->New-->Liferay Plugin Project

Once we click on new project it will open New Liferay Project Plugin Dialog window

Provides the Information as follows

Project Name: Sample

Project Display Name: Sample Hook

Check the Use Default Location Check box.

Build Type: ANT

Plugins SDK: Select your Plugins SDK( you already configured this when you setup development environment)

Liferay Runtime: Select your run time ( you already configured this when you setup development environment)

Plugin Type: Hook

The following screen shows the New Liferay Project Dialog



Once you fill the all the above information then click on Finish button then your Sample-hook project will be created.

The following screen shows Sample-hook project in the project explorer


Note:

Project Name always appended with Plugin type when we create any liferay project. In our case we just given Sample but finally project will be created with name Sample-hook. Now we just created Liferay Hook project and its just have project skeleton.

Deployment of Hook Plugin

As soon as we created hook project then respective build file will be appeared in the Eclipse ANT view. There we can see many ANT targets. Simply we have to double click on deploy target or we can simply double click on Project Name in the ANT view then it will execute deploy target then hook Plugin will be deployed into server. deploy is the default ant target for hook Plugin.

The following screen shows sample-hook ant targets in the Eclipse ANT view


Once we deploy the hook Plugin then we can see following message in server log view. When we see below message then hook is successfully deployed.

10:11:20,647 INFO [localhost-startStop-2][HookHotDeployListener:687] Registering hook for Sample-hook
10:11:20,651 INFO [localhost-startStop-2][HookHotDeployListener:814] Hook for Sample-hook is available for use

Note:

In General ant deploy is target for deploy the hook project.

Each liferay hook Plugin project have it own project ANT build file called build.xml in the root directory of project there all build process will be defined.

Anatomy of the Liferay Hook Project

When we created hook plugin through Liferay IDE it will create hook project with all required configuration files and its folder sturcture from here we can start our development as for our needs.

The following is general liferay hook plugin files and its structure.

Sample-hook/
   docroot/WEB-INF/src/
   docroot/
      META-INF/
        MANIFEST.MF
     WEB-INF/
       lib/
       liferay-hook.xml
       liferay-plugin-package.properties
       web.xml
build.xml

The following is Liferay Hook Project In the Liferay IDE project explorer


docroot/WEB-INF/src/ :

consist all Java source files and related resource files such as language properties and portal properties.

lib/ :

consist required libraries for project.

liferay-hook.xml :

This is hook configuration file and its consist all predefined configuration tags and it will be available in liferay-hook_6_x_x.dtd file. Here we will define what we should customize in the portal.

A sample “liferay-hook.xml ” with some configuration


liferay-plugin-package.properties :

its common to all liferay plugins projects and here we will defined all properties related to project such as build number, version ant many which we can find from liferay-plugin-package_6_2_0.dtd file.

Example “liferay-plugin-package.properties” file


web.xml :

Its general deployment description for liferay hook project.

buil.xml:

This is ant build file to defined project build process its internally called another build files from plugins SDK to provide different ANT targets.

Example build.xml file as Follows



Liferay Hook Project Development with ANT+Plugins SDK

In the above we have created liferay hook project using Liferay IDE now we will create same project with ANT command line interface.

Liferay Plugins SDK provides ANT command line interface to create liferay Plugin projects.

Before start this we need to be ready with Liferay Plugins SDK+ANT development environment.


Once you ready with Plugins SDK+ANT environment then open command prompt or Linux terminal based on your Operating System.

From command prompt/terminal navigate to hooks directory( /liferay-plugins-sdk-6.2/hooks )

Now issue the following command

Linux and Mac OS X

./create.sh Sample "Sample"

In Windows

create.bat Sample "Sample"

A BUILD SUCCESSFUL message from ANT tells you there’s a new folder named Sample-hook inside the Plugins SDK’s hooks folder.

Project Name always appended with Plugin type when create any liferay project. In our case we just given Sample but finally project will be created with name Sample-hook

Once project is created then navigate to project root directory(/liferay-plugins-sdk-6.2/hooks/Sample-hook) then issue following ANT target then project will be deployed in the server.

ant deploy

Once we deploy the hook then we can see following message ,then hook is successfully deployed.

Hook for Sample-hook is available for use

Note:

well we have successfully created liferay hook Plugin project and here still we did not customize anything of portal. We will see how to customize liferay portal with this hook project in future articles. We simply do some configuration in liferay-hook.xml then it will change the portal behavior as for our need.

Follow the below articles to know more about Different Liferay Hook Plugins


Author

2 comments :

  1. buy tik tok followers Increase your exposure on social media! Check out our deals and buy Instagram Followers, Buy Youtube Subscribers, and more! Fast, cheap, and 24/7 Support.

    ReplyDelete
  2. Developer will become happy to read your article. It is beneficial for them. Now, I am here with the Termite Inspection Services in San Diego and providing you reliable service.

    ReplyDelete

Recent Posts

Recent Posts Widget

Popular Posts