JSPs in OSGi modules are customized using module fragments. The module fragment attaches to the host module to alter the JSPs. To the OSGi runtime, the fragment is part of the host module. Section 3.14 of the OSGi Alliance’s core specification document explains module fragments in detail. This tutorial shows you how to upgrade your app JSP hooks to Liferay Portal CE 7.0.

Liferay IDE’s Code Upgrade Tool’s Convert Custom JSP Hooks step generates module fragments from app JSP hook plugins. The tool creates module fragments in the same folder as your Plugins SDK root if your hook is in a Plugins SDK or in the [liferay_workspace]/modules folder if your hook is in a Liferay Workspace.

Module fragments follow this name convention: [plugin_name]-[app]-fragment. For example, if the plugin’s name is app-jsp-hook and it modifies a JSP in the Blogs app, the Code Upgrade Tool generates a module fragment named app-jsp-hook-blogs-fragment.

Here are the steps for upgrading app JSP hook plugins:

  1. Declare the Fragment Host
  2. Update the JSP

Declare the Fragment Host

The module fragment’s bnd.bnd file must specify an OSGi header Fragment-Host set to the host module name and version.

If the host module belongs to one of Liferay Portal’s app suites, the Code Upgrade Tool generates a bnd.bnd file that specifies an appropriate Fragment-Host header automatically.

For example, here’s a Fragment-Host that attaches a module fragment to the Blogs Web module.

Fragment-Host: com.liferay.blogs.web;bundle-version="1.1.9"

Updating the JSP is straightforward too.

Update the JSP

The Code Upgrade Tool creates a module fragment that contains an upgraded version of your custom app JSP.

The following table shows the old and new JSP paths.

Liferay Portal version JSP File Path
6.2 docroot/META-INF/custom_jsps/html/portlet/[jsp_file_path]
7.0 src/main/resources/META-INF/resources/[jsp_file_path]

For example, the Code Upgrade Tool generates a customized version of the Blogs app’s init-ext.jsp file here:

src/main/resources/META-INF/resources/blogs/init-ext.jsp

The tool’s Convert Custom JSP Hooks step lets you compare custom JSPs with originals:

  • Compare your custom 6.2 JSP with the original 6.2 JSP.
  • Compare your custom 7.0 JSP with your custom 6.2 JSP.

upgrading-app-jsp-hook-convert-custom-jsp-hook.png

Figure 1: The Code Upgrade Tools lets you compare custom JSPs with originals.

Make any additional needed changes in your 7.0 custom JSP. Then deploy your module fragment. This stops the host module momentarily, attaches the fragment to the host, and then restarts the host module. The console output reflects this process.

Here’s output from deploying a module fragment that attaches to the Blogs web module.

19:23:11,740 INFO  [Refresh Thread: Equinox Container: 00ce6547-2355-0017-1884-846599e789c4][BundleStartStopLogger:38] STOPPED com.liferay.blogs.web_1.1.9 [535]
19:23:12,910 INFO  [Refresh Thread: Equinox Container: 00ce6547-2355-0017-1884-846599e789c4][BundleStartStopLogger:35] STARTED com.liferay.blogs.web_1.1.9 [535]

Your custom JSP is live.

Related Topics

JSP Overrides Using OSGi Fragments

Upgrading Core JSP Hooks

Resolving a Plugin’s Dependencies

Upgrading the Liferay Maven Build

0 (0 Votes)
Upgrading Core JSP Hooks Previous