Sunday, January 4, 2015

Liferay Service Hook to override Liferay Existing Service

Today we will see how to write service wrapper in Liferay 6.2. We override User service getUserCount().Here we create a class that extend the particular wrapper class and just provide the entries of our custom class in liferay-hook.xml so that liferay use our services instead of Original.

Step 1:-Create a liferay Plug project
Right Click in Project Explorer and Click New -> Liferay plugin project. Now give the Project name and select hook in plugin type:-

Step 2:-Create a hook in the project
Right Click on Project ->New->Liferay Hook Configuration->Select Services

Click Next--->Click Add-->Select Service Type(UserLocalService)

For Impl Class

Click New-->Give Package Name and your Impl Class Name

Then Click Finish

This step automatically Create the entry in  liferay-hook.xml. 


Step 3:-Override the getUserCount()
Open MyUserLocalService and override getUserCount()

Step 4:-Deploy the Hook
Deploy the hook and call getUsersCount() from your portlet .

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!