portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Sean Taylor <d.tay...@onehippo.com>
Subject Re: login portlet extension
Date Wed, 03 Feb 2010 23:03:37 GMT
On Wed, Feb 3, 2010 at 7:44 AM, Dahl, Sandra <SDahl@dvsanalytics.com> wrote:

> Thanks for the information, David. In general, what is the best practice
> for extending an existing Jetspeed portlet so future Jetspeed updates can be
> easily implemented?
>
> I think there are two approaches you can take:

1. write your own administrative portlet application, and manage all code
yourself
2. overlay the j2-admin.war artifact from maven

The first solution doesn't work well for re-use, as much j2-admin's
functionality is hidden down in JSP files. Additionally, we do not
distribute j2-admin as a jar file to reuse java classes. With that in mind,
lets look at how you can approach the second solution.

Many people prefer Ant for this kind of processing. In fairness to Ant, lets
look at how you could do that. I didn't have an example with the j2-admin
war, but here is an similar example using the jetspeed layouts war.

<target name='overlay-layouts'>
<mkdir dir='${installer.target}/unpack/'/>
<unjar
src="${installer.target}/portal/webapps/dash/WEB-INF/deploy/local/jetspeed-layouts.war"
   dest="${installer.target}/unpack/jetspeed-layouts/"/>
<copy overwrite='true'
todir='${installer.target}/unpack/jetspeed-layouts/WEB-INF/'
      file="./src/layouts/portlet.xml"/>
<jar
destfile='${installer.target}/portal/webapps/dash/WEB-INF/deploy/local/jetspeed-layouts.war'
basedir="${installer.target}/unpack/jetspeed-layouts/" update='true'/>
</target>

In the target above, the Ant target overlays my customized portlet.xml on
top of the jetspeed-layouts war, and then create the new merged war file.
The downside to this approach, we don't take the jetspeed-layouts.war file
out of a Maven repository.

As a hybrid solution, if you prefer Ant but are required to use Maven, you
can embed ant commands into Maven at the generate-resources phase. There are
examples of this in the jetspeed-installer and enterprise sub-projects

Here is a pure Maven solution, which I would consider a best practice for
Maven builds. In this example I use the Maven War Plugin's overlay feature:

http://maven.apache.org/plugins/maven-war-plugin/overlays.html

Here is a complete pom.xml example:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.apache.portals.jetspeed-2</groupId>
  <artifactId>extended-j2admin</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>extended-j2admin Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.apache.portals.jetspeed-2</groupId>
    <artifactId>j2-admin</artifactId>
    <type>war</type>
    <version>2.2.1-SNAPSHOT</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>extended-j2admin</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <overlays>
            <overlay>
              <id>j2-admin</id>
      <groupId>org.apache.portals.jetspeed-2</groupId>
      <artifactId>j2-admin</artifactId>
            </overlay>
           <overlay>
              <!-- empty groupId/artifactId is detected as the current build
-->
            </overlay>
          </overlays>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

I have zipped up the entire project for you to play around with and put it
on my retired server here:

http://www.bluesunrise.com/jetspeed-2/2.2/extended-j2admin.zip

There are two files in the overlay project's webapp source:

1. the web.xml, to show an example of replacing an existing file, where I
simply changed the display-name and description as an example:

  <display-name>Sandra's Jetspeed-2 Portal Administration
Portlets</display-name>
  <description>Sandra's Administration Portlets for the Jetspeed-2
Enterprise Portal</description>

2. the index.jsp, to show an example of adding a new file

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message