Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why
« Back to Development

Development Strategies

Alternative Languages: 日本語

Introduction #

Liferay portal is extensible at least at three levels: Plugins SDK environment, extension environment and Liferay portal source code. In general, each level of extensibility offers a different compromise of flexibility with different migration requirements to future version. This document will discuss development strategies.

Extension Environment #

The Extension environment provides capability to customize Liferay portal completely. Since it is an environment which extend Liferay portal development environment, it have a name “Extension”, or called “Ext”. By the Ext, we could modify internal portlets, or called the out-of-the-box portlets. Moreover, we could override the JSP files of portal and out-of-the-box portlets. This kind of customizations is kept separate from the Liferay portal source code. That is, Liferay portal source code does not have to be modified, and a clear upgrade path is available in the Ext.

As shown in following figure, custom code will override Liferay portal source code in the Ext only. In deployment process, custom code is merged with Liferay portal source code in the Ext. That is, developers override Liferay portal source code. Moreover, custom code and Liferay portal source code will constructed as customized Liferay portal in the Ext first, and then the customized Liferay portal will be deployed from the Ext to the application server.

Abstracted from the book:Liferay-Portal-5-2-Systems-Development

During customization, we could use the Service Builder to generate models and services. In general, the Service Builder is a code generator, using an XML descriptor. For a given xml file service.xml, it will generate SQL for creating tables, Java Beans, Hibernate configuration, spring configuration, Axis Web Service and JSON JavaScript Interface, etc.

JSP files of the portal and the out-of-the-box portlets can be overridden with custom versions in the Ext. Note that, the Ext is used for customizing Liferay portal only, since portlets written in the Ext are not hot deployable, and moreover, the Ext is a monolithic environment.

Plugins SDK Environment #

The Plugins SDK is a simple environment for the development of Liferay plugins, including themes, layout templates, portlets, hooks and webs (that is, web applications). It provides capability to create hot-deployable portlets, themes, layout templates, hooks and webs.

How does it work? As shown in following figure, the Plugins SDK provides environment for developers to build themes, layout templates, portlets, hooks or webs first. Afterwards, it uses the Ant target Deploy to form WAR and copy it to the Auto Deploy directory. Then, Liferay portal together with application server will detect any WAR files in the auto hot-deploy folder, and automatically extracts the WAR files into the application server deployment folder.

Abstracted from the book:Liferay-Portal-5-2-Systems-Development

For more details, portlets go in the folder /portlets; themes go in the folder /themes; layout templates go in the folder /layouttpl; web applications go in the folder /webs; and hooks go to the folder /hooks. By the way, Ant scripts are used to build and deploy plugins to a local application server.

Especially, portlets developed in the Plugins SDK may only import classes from the portal API (Portal-Kernel and Portal-Service) and other JAR files contained in the specific portlet folder /WEB-INF/lib. This forces portlets to rely completely on the Portal API and not to depend on implementation classes defined in the Portal-Impl.

As you can see, portlets can make use of any application framework that Liferay supports, Model-View-Controller (MVC) frameworks. Here is a list of application frameworks, but not limited, Struts, Spring, Tapestry, JSF, Wicket, etc.

In addition, as mentioned above, Liferay portal can also integrate with certain web applications as webs, for instance, solr-web - search engine integration plugin; jbpm-web – workflow engine integration plugin; mule-web and servicemix-web - Enterprise Service Bus (ESB) integration plugins.

Development Strategies #

As mentioned earlier, there are at least two development environments: the Ext and Plugins SDK. Thus, which kind development environment is suitable for our requirements you may ask? When should we use the Ext and when should we use Plugins SDK or even Liferay portal source code? Let’s have a deep look on the development strategies.

As shown in following figure, Liferay Portal is extensible at least at three levels, e.g. Plugins SDK environment (Level I), Extension environment (Level II) and Liferay Portal Source Code (Level III). As you can see, each level of extensibility offers a different compromise of flexibility with different migration requirements to future version. Thus, we need to choose the appropriate level for the requirements at hand which allows for easier future maintainability.

Abstracted from the book: Liferay-Portal-5-2-Systems-Development

In the Level I, we can develop portlets, themes, layout templates, hooks and webs as independent software components, and moreover, these plugins could be distributed and deployed as WAR files and could be organized in plugin repositories. Liferay portal provides the Plugins SDK to help us with development of these plugins.

In addition, portlets developed in the Plugins SDK can only import classes from the portal API (Portal-Kernel and Portal-Service), not the Portal-Impl. That is, portlets development in Plugins SDK does not even touch portal properties, language properties and JSP files related to the Portal-Impl. Fortunately, Hooks provides capability to hook up portal properties, language properties and JSP files related to the Portal-Impl.

In the Level II, we can manage configuration files, custom source code, custom JSP files, and modified JSP files, related to the Portal-Impl. That is, the Ext provides different sub-levels (e.g., configuration files, custom source code, custom JSP files, and modified JSP files) of extensibility.

For configuration files, portal-ext.properties is main configuration options: layouts, deployment, themes, Hibernate, cache, instance settings, users, groups, language, session, auth, integration, events, etc. Meanwhile, system-ext.properties is convenient way to provide and extend the Java System properties used by Liferay portal. We can also create custom classes for the most common extensibility which needs configurable through portal.properties, e.g. authentication chain, upgrade and verification processes, deployment processes, database access and caching, user fields generation and validation, session events, permissions, model listeners, etc.

For custom source code, we can use Spring based dependency injection mechanisms - configured in ext-spring.xml; add the Servlet - extended in web.xml; add the Struts action - extended in struts-config.xml; and moreover, create portlets – accessing to the Portal-Impl or event extending models and services in the Portal-Impl.

For custom JSP files and modified JSP files, we can customize any of the JSP files used by the out-of-the-box portlets and management tools. This is a very flexible extension mechanism.

Without a doubt, it is easier to develop portlets in the Ext. Using the Ext, you can get easily to all Liferay Portal API, taglib, JSP files and almost everything. And this is not the case in the Plugins SDK at the time of writing.

In the Level III, we can modify the Liferay portal source code. This approach can only be used for sponsored development. That is, we develop specific features for specific projects first and then contribute back to Liferay portal source code.

In brief, if your requirements are related to customize and / or extend the Portal-Impl (e.g. UI changing, LDAP import algorithms, Document Library lock mechanism, forms for user registration or organization creation, integration, modifying the out-of-the-box portlets, etc.), you should use the Ext. Otherwise, it is better to use Plugins SDK. Note that with Hooks you can hook up portal properties, language properties and JSP files related to the Portal-Impl.

0 Attachments
49238 Views
Average (2 Votes)
The average rating is 5.0 stars out of 5.
Comments
Threaded Replies Author Date
That's a brilliant compilation :) I have used... Parul Seth May 27, 2009 1:08 AM
Very informative article. I have also used SDK... Ziggy © August 10, 2009 11:07 AM
Hi Can u mention steps to create the ext... Sudhir Verma September 9, 2009 10:16 PM
Follow these below steps: (for Windows only,... Ma Kiet September 17, 2009 3:53 AM
I have problem for opening project in netbeans... vijay pandey September 28, 2010 4:35 AM
when i am doing steps 17 which u have mention... vijay pandey September 29, 2010 1:54 AM
can u specify how what type of things we have... vijay pandey September 28, 2010 4:07 AM
when i am doing steps 17 which u have mention... vijay pandey September 29, 2010 3:46 AM
Liferay has a very flexible development &... Seshendra Nalla August 16, 2010 9:26 AM
Can anyone provide me details on ... Archi Madhu October 22, 2009 3:57 AM
I am working liferay portal 5.2.3. Cam anyone... ritesh k gurjar November 10, 2009 2:17 AM

That's a brilliant compilation emoticon
I have used both SDK and ext. I'd say SDK has a cleaner approach, but in some cases ext is inevitable emoticon
So its really important to know when to use what emoticon.
Posted on 5/27/09 1:08 AM.
Very informative article.
I have also used SDK but im now playing with the EXT.
Posted on 8/10/09 11:07 AM in reply to Parul Seth.
Hi
Can u mention steps to create the ext environment as well as how to work with ext environment using netbeans only
Posted on 9/9/09 10:16 PM in reply to Parul Seth.
Follow these below steps: (for Windows only, same as Linux)
1. Download the newest JDK from java.sun.com, create an environment varriable JAVA_HOME point to JDK folder (default: C:\Program Files\Java\JDK1.6
2. Download OracleXE from www.oracle.com then install
3. Create user lportal, password lportal, grant all on lportal
4. Download the newest Oracle JDBC Driver from www.oracle.com
5. Download Liferay source code from http://sourceforge.net/projects/lportal/files/ (5.2.3 recommended)
6. Extract source code zip file to anywhere you want, change the extracted folder name to "portal", assign an environment varriable LIFERAY_PORTAL for parent directory of "portal" folder
7. Download the newest Tomcat from tomcat.apache.org, extract to %LIFERAY_PORTAL% then change extracted folder name to tomcat
8. Assign an environment varriable CATALINA_HOME for %LIFERAY_PORTAL%\tomcat folder
9. Update %CATALINA_HOME%\conf\catalina.properties file as below:
common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar, ${catalina.home}/lib/ext/*.jar
10. Update %CATALINA_HOME%\conf\server.xml, change the port 8080 in connector tag to anything, such as 8880 to avoid conflict port
11. Create setenv.bat in %CATALINA_HOME%\bin, add the following string to the file
set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx1024m -XX:MaxPermSize=128m
12. Create 5 folder "temp", "deploy", "data", "ext", "workspace" under %LIFERAY_PORTAL"
13. Run NetBean, File->Open project, open %LIFERAY_PORTAL%\portal
14. Update app.server.properties file:
app.server.type=tomcat
app.server.parent.dir=${project.dir}/..
app.server.­tomcat.dir=${app.server.parent.dir}/tomcat
Add this row: app.server.tomcat.support.dir=${app.server.tomcat.dir}/lib/ext
right below the row: app.server.tomcat.lib.support.dir=${app.server.tomcat.dir}/lib/ext
15. Update release.properties file:
lp.ext.dir=${project.dir}/../ext
16. Update build.properties file:
ant.build.javac.source=1.6
ant.build.javac.target=1.6
Replace 1.6 with your java version (go to command line, type: java -version)
17. Right click on build.xml in portal folder, run these target in order: clean, start, build-ext
After that, in your %LIFERAY_PORTAL%\ext will have many file and subfolders
18. Unfortunately, NetBean can't recognize ext as a project. You will need help from Eclipse. Download Eclipse Classic from eclipse.org, run it, choose %LIFERAY_PORTAL%\workspace as default workspace
19. In eclipse, choose File->New Project->Create project from existing source, point to %LIFERAY_PORTAL%\ext then open. After finish opening, close eclipse
20. In NetBean, choose File->Import Porject->Eclipse project, in Import Projects from Workspace, point to %LIFERAY_PORTAL%\workspace, choose ext then open.
21. Update app.server.properties and build.properties in ext project as you did in Liferay portal project
22. Copy Oracle JDBC Driver to %LIFERAY_PORTAL%\ext\lib\development (see step 4)
23. Right click on build.xml in ext folder, run these following target in order: clean, deploy
24. In NetBean, choose Windows->Service, right click on Server->Add Server, choose Liferay Portal Server (You will only have this option if you already installed portal pack for NetBean)
25. Next, choose Tomcat 6.x (or right version) in Server Type, assign Cataline home to %CATALINA_HOME%, next and finish
26. Open Liferay portal\portal-impl\source\portal.properties, copy this script:
#
# Oracle
#
jdbc.default.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.default.­url=jdbc:oracle:thin:@localhost:1521:xe
jdbc.default.username=lportal
jdbc.default­.password=lportal

paste to ext\ext-impl\source\portal-ext.properties
27. Start OracleXE
28. Right click on Liferay Server, choose Start

Congratulation, you did it.

If you want to change database, choose the right jdbc driver and script in portal.properties.

If you face some problem, please let me know.

Have fun.
Posted on 9/17/09 3:53 AM in reply to Sudhir Verma.
Can anyone provide me details on

http://www.liferay.com/web/guest/community/forums/-/message_boards/message/325­9779

Thanks,
Archi
Posted on 10/22/09 3:57 AM.
I am working liferay portal 5.2.3. Cam anyone please tell me that does liferay supports UTF-16 encoding.
Posted on 11/10/09 2:17 AM in reply to Archi Madhu.
Liferay has a very flexible development & deployment strategies. I'm very much fascinated with it's Plugin's SDK environment and the EXT concept.

I have few questions on how many portlets a plug-in should typically hold (as a recommendation).

1. We currently have a Spring portlet MVC container with 25 JSR 168 portlets wired into one portlet.xml in one war module running in Vignette 7.
2. Can this whole war module be a plug-in for Liferay? or is it advisable to slice the war into multiple wars, one each for a portlet?
3. There is another application which is having one vignette car file per portlet-bean portlet, which I think would be easy to create a war file per JSR 168/286 portlet in Spring Portlet MVC and use each of them as plugins. Would that make sense?
4. With "Hot deployment", does it mean that I can deploy and redeploy a portlet without bouncing my Application server (assuming it's WebSphere 7.0)?
Posted on 8/16/10 9:26 AM in reply to Parul Seth.
can u specify how what type of things we have ,when we follows these steps
Posted on 9/28/10 4:07 AM in reply to Sudhir Verma.
I have problem for opening project in netbeans Please guide to us when steps =>13. Run NetBean, File->Open project, open %LIFERAY_PORTAL%\portal.

Please help to us
Thanks
Posted on 9/28/10 4:35 AM in reply to nguyen thanh binh.
when i am doing steps 17 which u have mention that run three clean ,start and build-ext but in netbeans 6.x version no build-ext . By this I think our ext folder is empty .No any files

so Please help to us

Thanks in advance
Posted on 9/29/10 1:54 AM in reply to nguyen thanh binh.
when i am doing steps 17 which u have mention that run three clean ,start and build-ext but in netbeans 6.x version no build-ext . By this I think our ext folder is empty .No any files

so Please help to us

Thanks in advance
Posted on 9/29/10 3:46 AM in reply to Sudhir Verma.