portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r441381 - in /portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto: PortletContainer.java core/PortletContainerImpl.java
Date Fri, 08 Sep 2006 05:38:23 GMT
Author: esm
Date: Thu Sep  7 22:38:22 2006
New Revision: 441381

URL: http://svn.apache.org/viewvc?view=rev&rev=441381
Log:
[PLUTO-256]: added getPortletApplicationDescriptor(String) to the PortletContainer interface
and impl.

Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java?view=diff&rev=441381&r1=441380&r2=441381
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
Thu Sep  7 22:38:22 2006
@@ -15,11 +15,14 @@
  */
 package org.apache.pluto;
 
+import java.io.IOException;
+
 import javax.portlet.PortletException;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
 
 /**
  * The publicized entry point into Pluto. The base functionality of the portlet
@@ -43,6 +46,8 @@
  * <p/>
  * <TR><TD>{@link #destroy()}</TD> <TD>Destroy and remove container
from
  * service.</TD> <TD>Performed only once per container lifecylce</TD></TR>
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:esm@apache.org">Elliot Metsger</a>
  * @version $Id: PortletContainer.java 36010 2004-07-30 14:16:06Z ddewolf $
  */
 public interface PortletContainer {
@@ -134,4 +139,20 @@
      * @return the container services provided by either the portal or the defaults.
      */
     public OptionalContainerServices getOptionalContainerServices();
+    
+    /**
+     * Retrieve the {@link PortletAppDD} for the portlet
+     * located at the supplied context.
+     * 
+     * Must not return null.
+     * 
+     * @param context the context of the portlet
+     * @return the portlet application descriptor
+     * @throws PortletContainerException if the container has trouble obtaining
+     *                                   the context of the portlet, or retrieving
+     *                                   the <code>PortletAppDD</code>
+     */    
+    public PortletAppDD getPortletApplicationDescriptor(String context)
+        throws PortletContainerException;
+    
 }

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java?view=diff&rev=441381&r1=441380&r2=441381
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
Thu Sep  7 22:38:22 2006
@@ -26,7 +26,9 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
 import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.internal.PortletDescriptorRegistry;
 import org.apache.pluto.internal.impl.ActionRequestImpl;
 import org.apache.pluto.internal.impl.ActionResponseImpl;
 import org.apache.pluto.internal.impl.PortletWindowImpl;
@@ -44,6 +46,7 @@
  *
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @author <a href="mailto:esm@apache.org">Elliot Metsger</a>
  * @version 1.0
  * @since Sep 18, 2004
  */
@@ -282,6 +285,46 @@
         return optionalContainerServices;
     }
     
+    public PortletAppDD getPortletApplicationDescriptor(String context) 
+        throws PortletContainerException {
+        
+        // make sure the container has initialized
+        ensureInitialized();
+        
+        // sanity check
+        if (context == null || context.trim().equals("")) {
+            final String msg = "Context was null or the empty string.";
+            errorWithName(msg);
+            throw new PortletContainerException(msg);
+        }
+        
+        // obtain the context of the portlet
+        ServletContext portletCtx = servletContext.getContext(context);
+        if (portletCtx == null) {
+            final String msg = "Unable to obtain the servlet context for " +
+                "portlet context [" + context + "].  Ensure the portlet has " +
+                "been deployed and that cross context support is enabled.";
+            errorWithName(msg);
+            throw new PortletContainerException(msg);
+        }
+        
+        // obtain the portlet application descriptor for the portlet
+        // context.
+        PortletAppDD portletAppDD = PortletDescriptorRegistry
+                                        .getRegistry()
+                                        .getPortletAppDD(portletCtx);
+        
+        // we can't return null
+        if (portletAppDD == null) {
+            final String msg = "Obtained a null portlet application description for " +
+                "portlet context [" + context + "]";
+            errorWithName(msg);
+            throw new PortletContainerException(msg);
+        }
+        
+        return portletAppDD;        
+    }
+    
     
     // Private Methods ---------------------------------------------------------
     
@@ -314,6 +357,16 @@
     	if (LOG.isInfoEnabled()) {
     		LOG.info("Portlet Container [" + name + "]: " + message);
     	}
+    }
+    
+    /**
+     * Prints a message at ERROR level with the container name prefix.
+     * @param message  log message.
+     */
+    private void errorWithName(String message) {
+        if (LOG.isErrorEnabled()) {
+            LOG.info("Portlet Container [" + name + "]: " + message);
+        }
     }
     
 }



Mime
View raw message