Skip to main content

Digital Transformation

WebSphere Portal and Maven (Part 3)

The deployment of a portlet to a portal server is accomplished using xmlaccess (also called the XML configuration interface). At this point I need to point out that the deploy goal of maven is a separate concept from a portlet deployment. The maven deploy goal is intended to move your packaged maven artifact to the maven repository server. A portlet deployment means that you are moving and installing your portlet onto a portal server where it can be placed onto a page and receive requests.

You actually perform your portlet deployment during the pre-integeration-test phase of the maven lifecycle. This is done here instead of the deploy phase because you would not want to share the code with other developers if your integration tests fail during the integration-test phase.

The input file of an xmlaccess request is an XML configuration file with specialized syntax to describe your intended operation. You want to modify the DeployPortlet.xml sample file included in your portal installation and replace it with parameters that match the portlet you wish to deploy.

I have created an XSLT file that can process the portlet.xml descriptor and produce a valid xml configuration file that you can send in an xmlaccess request. Readers should notice that this is a modified form of the DeployPortlet.xml sample file included with the portal. In a future post I will describe how and where this file gets executed during the build.

<?xml version="1.0"?>
<xsl:stylesheet
	version="2.0"
	exclude-result-prefixes='wps'
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:wps="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">	

<xsl:output method="xml" indent="yes"/>
<xsl:param name="WAR_URL"/>
<xsl:param name="DISPLAY_NAME"/>

<xsl:template match="/">
	<xsl:comment>Generated version: 1.0</xsl:comment>
	<request 
		type="update"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd">
		<portal action="locate">
			<xsl:apply-templates/>
		</portal>
	</request>
</xsl:template>

<xsl:template match="wps:portlet-app">
	<web-app action="update" active="true" uid="{@id}.webmod">
		<url><xsl:value-of select="$WAR_URL"/></url>
		<!-- Use the maven artifactId as the display name in the WAS console with a prefix to group together -->
		<display-name><xsl:value-of select="$DISPLAY_NAME"/></display-name>
		<servlet action="update" referenceid="{wps:portlet/wps:portlet-name}.servlet"/>
		<portlet-app action="update" uid="{@id}">
            <xsl:apply-templates select="wps:portlet"/>
        </portlet-app>
	</web-app>
</xsl:template>

<xsl:template match="wps:portlet">
	<portlet action="update" name="{wps:portlet-name}" />
</xsl:template>

</xsl:stylesheet>

Next up: WebSphere Portal and Maven (Part 4)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Kevin StClair

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram