Creating a service without service-builder

No Comments »

Create your service-project:
1) Create new Liferay-Portlet project
2) clear porlet.xml.

<portlet-app version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">

</portlet-app>

2) create a service.xml file in docroot/WEB-INF



< ?xml version="1.0" encoding="UTF-8"? >
< !DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd" >
< service-builder package-path="test" >
 < author >test< /author >
 < namespace >test< /namespace >
 
 < exceptions >

 < /exceptions >
< /service-builder >




3) Right click on service.xml and choose „Liferay - build services“. Service-Builder will create a directory „service“
4)Open project-properties ans choose the „service“-directory as additional source directory
5) All your service-packages and classes should now be created in this directory. choose „Liferay à build services“ or run ant-task „build-service“ and you will get your service-jar in „EB-INF\lib

Deploy your Service:
Choose among three options:
A) Modify your Portlets liferay-plugin-package.properties and declare your service-project as required-deployment-context. When building your service-jar and afterwars building your portel, a copy of service-jar will be copied to your portlets WEB-INF/lib folder. In addition you have to deploy your service  to Liferay.

Advantages:
1.You can modify your service and rebuilt service and portlet without restarting your application server.
Disadvantages:
1. You also have to deploy vour service, otherweise your portlet will not be deployed because of a missing deployment-context
2.Each portlet using your your service will have a seperate service-instance

B) Copy your service.jar to tomcat-x.x.xx\lib\ext

Advantages:
1. All  portlets using your your service will share one service-instance
Disadvantages:
2. When modifying your service you have to copy a new service-jar to your application server and restart it

C) Copy your service.jar to tomcat-x.x.xx\webapps\ROOT\WEB-INF\lib and modify your liferay-plugin-package.properties by adding your service.jar as portal-dependency-jar

Disadvantages:
1.When modifying your service you have to copy a new service-jar to your application server and restart it
2. Each portlet using your your service will have a seperate service-instance

Download sample:
Mirror 0
Mirror 1
Mirror 2