Maven Jetty Pluto Embedded

The documentation for this project has moved to and will be maintained at http://bekkopensource.lighthouseapp.com/projects/22517/home

Documentation

This artifact can be used together with the maven-jetty-plugin to run a maven portlet application with jetty, using the regular mvn jetty:run command.

Configuration

To use this extension, add the following to your pom.xml file:

pom.xml
<profiles>
  <profile>
    <id>pluto-embedded</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.mortbay.jetty</groupId>
          <version>6.1.14</version>
          <artifactId>maven-jetty-plugin</artifactId>
          <configuration>
            <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
            <webAppConfig>
              <contextPath>/${project.artifactId}</contextPath>
              <defaultsDescriptor>/WEB-INF/jetty-pluto-web-default.xml</defaultsDescriptor>
            </webAppConfig>
            <systemProperties>
              <systemProperty>
                <name>org.apache.pluto.embedded.portletIds</name>
                <value>MyPortletAsDefinedInPortletXml,MyOtherPortletInTheSameApp</value>
              </systemProperty>
            </systemProperties>
          </configuration>
        </plugin>
      </plugins>
    </build>
    <dependencies>
      <dependency>
        <groupId>com.bekk.boss</groupId>
        <artifactId>maven-jetty-pluto-embedded</artifactId>
        <version>1.0.1</version>
      </dependency>
    </dependencies>
  </profile>
</profiles>

Substitute MyPortletAsDefinedInPortletXml and (optionally, if you want to run multiple portlets) MyOtherPortletInTheSameApp with the actual id of your portlet, as defined in portlet.xml

Now you should be able to run mvn jetty:run -P pluto-embedded to run the portlet. Open a browser and go to http://localhost:8080/artifactId/pluto/index.jsp (subistute artifactId with the artifact id of your maven project) to view the portlet.

Portlet 2.0 Support

A snapshot version of embedding pluto 2.0 which has Portlet 2.0 (JSR286) support is available. Add this in the repositories section of your pom.xml to try it out:

pom.xml
<repository>
  <id>BOSS inhouse private</id>
  <url>http://boss.bekk.no/proximity/repository/private</url>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
  <releases>
    <enabled>false</enabled>
  </releases>
</repository>

The url has changed a bit in this version. The url to view the portlet is http://localhost:8080/artifactId/portal

And also in the pom.xml file, change the version of the dependency from 1.0 to 2.0-SNAPSHOT

pom.xml
<dependency>
  <groupId>com.bekk.boss</groupId>
  <artifactId>maven-jetty-pluto-embedded</artifactId>
  <version>2.0-SNAPSHOT</version>
</dependency>

Comments

Anonymous says:

This will only work if the following code is also placed in your pom:

<plugin>
        <groupId>org.apache.pluto</groupId>
        <artifactId>maven-pluto-plugin</artifactId>
        <version>1.1.3</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>assemble</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

Nils-Helge Garli says:

Yes, that's missing from the example. Thanks for pointing that out.

Anonymous says:

Hello,

 You can found here a patch against  the maven-jetty-pluto-embedded 1.0.1-SNAPSHOT (trunk 2635) which adds support for more than one portlet.

From the user's point of view, using this version change the property name used : org.apache.pluto.embedded.portletId become org.apache.pluto.embedded.portletsIds. Separates each portletId with a comma ","

                            <systemProperties>
                                <systemProperty>
                                    <name>org.apache.pluto.embedded.portletsIds</name>
                                    <value>portlet1,portlet2</value>
                                </systemProperty>
                            </systemProperties>

Pierre-Alain RIVIERE (pariviere ATNOSPAMTOREPLACE ippon.fr)

Ippon Technologies : http://www.ippon.fr

http://anothergeekwebsite.com

Index: src/main/resources/pluto/index.jsp
===================================================================
--- src/main/resources/pluto/index.jsp    (revision 3337)
+++ src/main/resources/pluto/index.jsp    (working copy)
@@ -53,7 +53,7 @@
      
     <!-- Content block: portlets are divided into two columns/groups -->
     <div id="content">
-                <c:set var="portlet" value="${org_apache_pluto_embedded_portletId}" scope="request"/>
+                <c:set var="portlets" value="${org_apache_pluto_embedded_portletsIds}" scope="request"/>
                 <jsp:include page="/WEB-INF/themes/portlet-skin.jsp"/>
 
     </div>
Index: src/main/resources/WEB-INF/themes/portlet-skin.jsp
===================================================================
--- src/main/resources/WEB-INF/themes/portlet-skin.jsp    (revision 3337)
+++ src/main/resources/WEB-INF/themes/portlet-skin.jsp    (working copy)
@@ -16,32 +16,37 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 --%>
+<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
 <%@ taglib uri="http://portals.apache.org/pluto" prefix="pluto" %>
 
-<!-- Use pluto portlet tag to render the portlet -->
-<pluto:portlet portletId="${portlet}">
 
-  <!-- Assemble the rendering result -->
-  <div class="portlet" id='<c:out value="${portlet}"/>'>
-    <div class="header">
-      <!-- Portlet Mode Controls -->
-      <pluto:modeAnchor portletMode="view"/>
-      <pluto:modeAnchor portletMode="edit"/>
-      <pluto:modeAnchor portletMode="help"/>
-      <!-- Window State Controls -->
-      <pluto:windowStateAnchor windowState="minimized"/>
-      <pluto:windowStateAnchor windowState="maximized"/>
-      <pluto:windowStateAnchor windowState="normal"/>
-      <a href="<pluto:url windowState="minimized"/>"><span class="min"></span></a>
-      <a href="<pluto:url windowState="maximized"/>"><span class="max"></span></a>
-      <a href="<pluto:url windowState="normal"/>"><span class="norm"></span></a>
-      <!-- Portlet Title -->
-      <h2 class="title"><pluto:title/></h2>
-    </div>
-    <div class="body">
-      <pluto:render/>
-    </div>
-  </div>
+<c:forEach var="portlet" items="${portlets}" >  
 
-</pluto:portlet>
+    <!-- Use pluto portlet tag to render the portlet -->
+    <pluto:portlet portletId="${portlet}">
+    
+      <!-- Assemble the rendering result -->
+      <div class="portlet" id='<c:out value="${portlet}"/>'>
+        <div class="header">
+          <!-- Portlet Mode Controls -->
+          <pluto:modeAnchor portletMode="view"/>
+          <pluto:modeAnchor portletMode="edit"/>
+          <pluto:modeAnchor portletMode="help"/>
+          <!-- Window State Controls -->
+          <pluto:windowStateAnchor windowState="minimized"/>
+          <pluto:windowStateAnchor windowState="maximized"/>
+          <pluto:windowStateAnchor windowState="normal"/>
+          <a href="<pluto:url windowState="minimized"/>"><span class="min"></span></a>
+          <a href="<pluto:url windowState="maximized"/>"><span class="max"></span></a>
+          <a href="<pluto:url windowState="normal"/>"><span class="norm"></span></a>
+          <!-- Portlet Title -->
+          <h2 class="title"><pluto:title/></h2>
+        </div>
+        <div class="body">
+          <pluto:render/>
+        </div>
+      </div>
+    
+    </pluto:portlet>
+</c:forEach>
 
Index: src/main/java/com/bekk/boss/pluto/embedded/util/PlutoPortalDriverFilter.java
===================================================================
--- src/main/java/com/bekk/boss/pluto/embedded/util/PlutoPortalDriverFilter.java    (revision 3337)
+++ src/main/java/com/bekk/boss/pluto/embedded/util/PlutoPortalDriverFilter.java    (working copy)
@@ -31,7 +31,7 @@
 public class PlutoPortalDriverFilter implements Filter {
 
     private PortalDriverFilter portalDriver;
-    private String portletId;
+    private String[] portletsIds;
     private String[] styles = new String[0];
     
     public PlutoPortalDriverFilter() {
@@ -43,28 +43,41 @@
     }
 
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
-        request.setAttribute("org_apache_pluto_embedded_portletId", portletId);
+        request.setAttribute("org_apache_pluto_embedded_portletsIds", portletsIds);
         request.setAttribute("org_apache_pluto_embedded_extraStyles", styles);
         portalDriver.doFilter(request, response, chain);
     }
 
     public void init(FilterConfig filterConfig) throws ServletException {
         portalDriver.init(filterConfig);
-        portletId = System.getProperty("org.apache.pluto.embedded.portletId");
+        
         String extraStyles = System.getProperty("org.apache.pluto.embedded.extraStyles");
         if(extraStyles != null) {
             styles = extraStyles.split(",");
         }
-        if(portletId == null || "".equals(portletId.trim())) {
-            throw new ServletException("No portlet id specified. Please set the system property \"org.apache.pluto.embedded.portletId\"");
+        
+        String portletsIdsProp = System.getProperty("org.apache.pluto.embedded.portletsIds");
+        if (portletsIdsProp != null) {
+            portletsIds = portletsIdsProp.split(",");
+            
+            for (int index = 0 ; index < portletsIds.length ; index ++) {
+                String portletId = portletsIds[index];
+                
+                if(portletId == null || "".equals(portletId.trim())) {
+                    throw new ServletException("No portlet id specified. Please set the system property \"org.apache.pluto.embedded.portletId\"");
+                }
+                String contextPath = filterConfig.getServletContext().getContextPath();
+                StringBuffer tempId = new StringBuffer();
+                if(!contextPath.startsWith("/")) {
+                    tempId.append("/");
+                }
+                tempId.append(contextPath).append(".").append(portletId).append("!");
+                portletId = tempId.toString();
+                
+                portletsIds[index] = portletId;
+            }            
+        } else {
+            throw new ServletException("No portlet id specified. Please set the system property \"org.apache.pluto.embedded.portletsIds\"");
         }
-        String contextPath = filterConfig.getServletContext().getContextPath();
-        StringBuffer tempId = new StringBuffer();
-        if(!contextPath.startsWith("/")) {
-            tempId.append("/");
-        }
-        tempId.append(contextPath).append(".").append(portletId).append("!");
-        portletId = tempId.toString();
     }
-
 }

Nils-Helge Garli says:

Hi!

Thanks for the patch! I have already implemented this but not committed it yet. I'll try to get it in the next 1.1 and 2.0 snapshots.

Nils-H

Anonymous says:

Thanks to this search engine on torrent files http://www.picktorrent.com , from which I downloaded all the necessary entries, I was able to diagnose that only my spring context is being loaded, and not pluto's. Since I want to keep my web.xml as the production one, and only add in pluto stuff for testing, I need to figure out how to override the context parameter which lists what spring files to load when running in jetty. More soon.


Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Activity
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content

- Add Comment