You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by uk...@apache.org on 2007/06/17 23:16:14 UTC

svn commit: r548114 - in /portals/pluto/branches/1.1-286-COMPATIBILITY: ./ pluto-container/src/main/java/org/apache/pluto/internal/impl/ portlet2-api/ portlet2-api/src/main/java/javax/portlet/

Author: ukuester
Date: Sun Jun 17 14:16:13 2007
New Revision: 548114

URL: http://svn.apache.org/viewvc?view=rev&rev=548114
Log:
[Pluto-380:] Commit patch "rev16.patch"

The patch contains all changes for the new API. The only change for the container is the method in the RequestDispatcher which was already implemented and the getContainerRuntimeOptions method in PortletContextImpl.

Modified:
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/pom.xml
    portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/pom.xml
    portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/GenericPortlet.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletContext.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequest.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequestDispatcher.java

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java?view=diff&rev=548114&r1=548113&r2=548114
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java Sun Jun 17 14:16:13 2007
@@ -238,10 +238,16 @@
 
 	public Map getApplicationRuntimeOptions() {
 		// TODO Auto-generated method stub
-		return null;
+		throw new UnsupportedOperationException("This method needs to be implemented.");
 	}
 
 	public Map getPortletRuntimeOptions() {
+		// TODO Auto-generated method stub
+		throw new UnsupportedOperationException("This method needs to be implemented.");
+	}
+
+
+	public Map<String, String[]> getContainerRuntimeOptions() {
 		// TODO Auto-generated method stub
 		throw new UnsupportedOperationException("This method needs to be implemented.");
 	}

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pom.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pom.xml?view=diff&rev=548114&r1=548113&r2=548114
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pom.xml (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pom.xml Sun Jun 17 14:16:13 2007
@@ -237,7 +237,7 @@
 
     -->
   <properties>
-    <portlet-api.version>2.0-r15</portlet-api.version>
+    <portlet-api.version>2.0-r16</portlet-api.version>
     <servlet-api.version>2.4</servlet-api.version>
     <jsp-api.version>2.0</jsp-api.version>
     <jstl.version>1.1.2</jstl.version>

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/pom.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/pom.xml?view=diff&rev=548114&r1=548113&r2=548114
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/pom.xml (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/pom.xml Sun Jun 17 14:16:13 2007
@@ -33,7 +33,7 @@
   <groupId>javax.portlet</groupId>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>portlet-api</artifactId>
-  <version>2.0-r15</version>
+  <version>2.0-r16</version>
   <packaging>jar</packaging>
   <name>Portlet 2.0 API</name> 
   <description>The Java Portlet API version 2.0 developed by the Java Community Process JSR-286 Expert Group.</description>

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/GenericPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/GenericPortlet.java?view=diff&rev=548114&r1=548113&r2=548114
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/GenericPortlet.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/GenericPortlet.java Sun Jun 17 14:16:13 2007
@@ -70,6 +70,8 @@
 public abstract class GenericPortlet implements Portlet, PortletConfig,
 		EventPortlet, ResourceServingPortlet {
 
+
+
 	private transient PortletConfig config;
 
 	private transient Map<String, Method> processActionHandlingMethodsMap = new HashMap<String, Method>();
@@ -121,16 +123,16 @@
 		for (Method method : methods) {			
 			Annotation[] annotations = method.getAnnotations();
 			for (Annotation annotation : annotations) {
-				if (annotation.equals(ProcessAction.class)) {
+				if (annotation.annotationType().equals(ProcessAction.class)) {
 					processActionHandlingMethodsMap.put(((ProcessAction)annotation).name(), method);					
-				} else if (annotation.equals(ProcessEvent.class)) {
+				} else if (annotation.annotationType().equals(ProcessEvent.class)) {
 					if (((ProcessEvent)annotation).qname() != null)
 						processEventHandlingMethodsMap.put(((ProcessEvent)annotation).qname(), method);
 					else {
 						QName qn = new QName(config.getDefaultEventNamespace(), ((ProcessEvent)annotation).name());
 						processEventHandlingMethodsMap.put(qn.toString(), method);
 					}									
-				} else if (annotation.equals(RenderMode.class)) {
+				} else if (annotation.annotationType().equals(RenderMode.class)) {
 					renderModeHandlingMethodsMap.put(((RenderMode)annotation).name().toLowerCase(), method);
 				}
 			}
@@ -186,20 +188,26 @@
 	public void processAction(ActionRequest request, ActionResponse response)
 			throws PortletException, java.io.IOException {		
 		String action = request.getParameter(ActionRequest.ACTION_NAME);
+		boolean actionProcessed = false;
+		
 		try {
 			// check if action is cached in init
-			if ( processActionHandlingMethodsMap.containsKey(action) )
+			if ( processActionHandlingMethodsMap.containsKey(action) ) {
 				processActionHandlingMethodsMap.get(action).invoke(this, request, response);
-			// check if action is present as annotation
-			invokeProcessActionAnnotatedMethod(request, response, action);
+				actionProcessed = true;				
+			} else { 
+				// check if action is present as annotation
+				actionProcessed = invokeProcessActionAnnotatedMethod(request, response, action);
+			}
 		} catch (Exception e) {
 			throw new PortletException(e);
 		}
-
-		// if no action processing method was found throw exc
-		throw new PortletException("processAction method not implemented");
+		if ( ! actionProcessed )
+			// if no action processing method was found throw exc
+			throw new PortletException("processAction method not implemented");
 	}
 
+	
 	/**
      * The default implementation of this method sets the headers using the
      * <code>doHeaders</code> method, sets the title using the 
@@ -322,29 +330,36 @@
 	protected void doDispatch(RenderRequest request, RenderResponse response)
 			throws PortletException, java.io.IOException {
 		WindowState state = request.getWindowState();
-
+		boolean dispatchPerformed = false;
+		
 		if (!state.equals(WindowState.MINIMIZED)) {
 			PortletMode mode = request.getPortletMode();
 			// first look if there are methods annotated for
 			// handling the rendering of this mode
 			try {
 				// check if mode is cached in init
-				if ( renderModeHandlingMethodsMap.containsKey(mode) )
+				if ( renderModeHandlingMethodsMap.containsKey(mode) ) {
 					renderModeHandlingMethodsMap.get(mode).invoke(this, request, response);
-				// check if mode is present as annotation
-				invokeRenderModeAnnotatedMethod(request, response, mode);
+					dispatchPerformed = true;
+				}
+				else {
+					// check if mode is present as annotation
+					dispatchPerformed = invokeRenderModeAnnotatedMethod(request, response, mode);
+				}
 			} catch (Exception e) {
 				throw new PortletException(e);
 			}
-			// if not, try the default doXYZ methods
-			if (mode.equals(PortletMode.VIEW)) {
-				doView(request, response);
-			} else if (mode.equals(PortletMode.EDIT)) {
-				doEdit(request, response);
-			} else if (mode.equals(PortletMode.HELP)) {
-				doHelp(request, response);
-			} else {
-				throw new PortletException("unknown portlet mode: " + mode);
+			if ( ! dispatchPerformed ) {
+				// if not, try the default doXYZ methods
+				if (mode.equals(PortletMode.VIEW)) {
+					doView(request, response);
+				} else if (mode.equals(PortletMode.EDIT)) {
+					doEdit(request, response);
+				} else if (mode.equals(PortletMode.HELP)) {
+					doHelp(request, response);
+				} else {
+					throw new PortletException("unknown portlet mode: " + mode);
+				}
 			}
 		}
 
@@ -539,7 +554,8 @@
 		if ( request.getResourceID() != null ) {
 			PortletRequestDispatcher rd = getPortletConfig().getPortletContext()
 										.getRequestDispatcher(request.getResourceID());
-			rd.forward(request, response);
+			if ( rd != null )
+				rd.forward(request, response);
 		}
 	}
 
@@ -557,18 +573,25 @@
 	public void processEvent(EventRequest request, EventResponse response)
 			throws PortletException, IOException {
 		QName eventName = request.getEvent().getQName();
+		boolean eventProcessed = false;
+		
 		try {
 			// check if event is cached in init
-			if ( processEventHandlingMethodsMap.containsKey(eventName) )
+			if ( processEventHandlingMethodsMap.containsKey(eventName) ) {
 				processEventHandlingMethodsMap.get(eventName).invoke(this, request, response);
-			// check if event is present as annotation			
-			invokeProcessEventAnnotatedMethod(request, response, eventName.toString());
+				eventProcessed = true;
+			} else {
+				// check if event is present as annotation			
+				eventProcessed = invokeProcessEventAnnotatedMethod(request, response, eventName.toString());
+			}
 		} catch (Exception e) {
 			throw new PortletException(e);
 		}
-
-		// if no event processing method was found just keep render params
-		response.setRenderParameters(request);
+		
+		if ( ! eventProcessed ) {
+			// if no event processing method was found just keep render params
+			response.setRenderParameters(request);
+		}
 	}
 
 	/**
@@ -617,16 +640,29 @@
 	public Enumeration<String> getPublicRenderParameterNames() {
 		return config.getPublicRenderParameterNames();
 	}
-	
-	/**
-	 * Will be added in the next draft of the spec.
-	 * Torsten Dettborn
-	 */
+
+	 /**
+	   * Returns the default event namespace.
+	   * This namespace is defined in the portlet deployment descriptor
+	   * with the <code>default-event-namespace</code> element.
+	   * <p>
+	   * If no default namespace is defined in the portlet deployment
+	   * descriptor this methods returns the XML default namespace 
+	   * <code>XMLConstants.NULL_NS_URI</code>.
+	   * 
+	   * @return the default event namespace defined in the portlet deployment
+	   *         descriptor, or <code>XMLConstants.NULL_NS_URI</code> is non is
+	   *         defined.
+	   *         
+	   * @javax.portlet.PortletConfig#getDefaultEventNamespace()
+	   */
 	public String getDefaultEventNamespace() {
-		return null;
+		return config.getDefaultEventNamespace();
 	}
 
-	private void invokeProcessActionAnnotatedMethod(ActionRequest request, ActionResponse response, String action)
+	
+	
+	private boolean invokeProcessActionAnnotatedMethod(ActionRequest request, ActionResponse response, String action)
 	throws PortletException
 	{
 		Method[] methods = this.getClass().getMethods();
@@ -638,7 +674,7 @@
 						processActionHandlingMethodsMap.put(((ProcessAction)annotation).name(), method);					
 						try {
 							method.invoke(this, request, response);
-							return;
+							return true;
 						} catch (Exception e) {
 							throw new PortletException(e);
 						}
@@ -646,9 +682,9 @@
 				}
 			}
 		}
-	
+		return false;
 	}
-	private void invokeProcessEventAnnotatedMethod(EventRequest request, EventResponse response, String event)
+	private boolean invokeProcessEventAnnotatedMethod(EventRequest request, EventResponse response, String event)
 	throws PortletException
 	{
 		Method[] methods = this.getClass().getMethods();
@@ -661,7 +697,7 @@
 							processEventHandlingMethodsMap.put(((ProcessEvent)annotation).qname(), method);
 							try {
 								method.invoke(this, request, response);
-								return;
+								return true;
 							} catch (Exception e) {
 								throw new PortletException(e);
 							}
@@ -672,7 +708,7 @@
 							processEventHandlingMethodsMap.put(qn.toString(), method);
 							try {
 								method.invoke(this, request, response);
-								return;
+								return true;
 							} catch (Exception e) {
 								throw new PortletException(e);
 							}
@@ -681,11 +717,11 @@
 				}
 			}
 		}
-
+		return false;
 	}
 
 
-	private void invokeRenderModeAnnotatedMethod(RenderRequest request, RenderResponse response, PortletMode mode)
+	private boolean invokeRenderModeAnnotatedMethod(RenderRequest request, RenderResponse response, PortletMode mode)
 		throws PortletException
 	{
 		Method[] methods = this.getClass().getMethods();
@@ -697,7 +733,7 @@
 						renderModeHandlingMethodsMap.put(((RenderMode)annotation).name().toLowerCase(), method);
 						try {
 							method.invoke(this, request, response);
-							return;
+							return true;
 						} catch (Exception e) {
 							throw new PortletException(e);
 						}
@@ -705,6 +741,6 @@
 				}
 			}
 		}
-
+		return false;
 	}
 }

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletContext.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletContext.java?view=diff&rev=548114&r1=548113&r2=548114
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletContext.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletContext.java Sun Jun 17 14:16:13 2007
@@ -463,40 +463,13 @@
 
   
   /**
-   * Returns the portlet application level container runtime options
-   * and values supported by this portlet container.
-   * <p>
-   * The portlet can set portlet application level container runtime
-   * options in the <code>portlet.xml</code> via the
-   * <code>container-runtime-option</code> element with a name and a
-   * value on the portlet application level.
-   * The map returned from this method will provide the subset the
-   * portlet container supports of the options the portlet has specified 
-   * in the <code>portlet.xml</code>.
-   * <p>
-   * The map will contain name of the runtime option as key of type String
-   * and the runtime options as values of type String array (<code>String[]</code>).
-   * 
-   * @since 2.0
-   *  
-   * @return  an immutable <code>Map</code> containing portlet application
-   *          level container runtime options names as keys and the 
-   *          container runtime values as map values, or an empty <code>Map</code>
-   *          if no portlet application level container runtime options are set
-   *          in the <code>portlet.xml</code> or supported by this portlet container. 
-   *          The keys in the map are of type String. The values in the map are of type
-   *          String array (<code>String[]</code>).
-   */
-  public java.util.Map<String, String[]> getApplicationRuntimeOptions();
-
-  /**
-   * Returns the portlet level container runtime options
+   * Returns the container container runtime options
    * and values supported by this portlet container.
    * <p>
    * The portlet can set portlet level container runtime
    * options in the <code>portlet.xml</code> via the
    * <code>container-runtime-option</code> element with a name and a
-   * value on the portlet level.
+   * value on the application and portlet level.<br>
    * The map returned from this method will provide the subset the
    * portlet container supports of the options the portlet has specified 
    * in the <code>portlet.xml</code>.
@@ -507,12 +480,12 @@
    * @since 2.0
    *  
    * @return  an immutable <code>Map</code> containing portlet
-   *          level container runtime options names as keys and the 
+   *          container runtime options names as keys and the 
    *          container runtime values as map values, or an empty <code>Map</code>
-   *          if no portlet level container runtime options are set
+   *          if no portlet container runtime options are set
    *          in the <code>portlet.xml</code> or supported by this portlet container. 
    *          The keys in the map are of type String. The values in the map are of type
    *          String array (<code>String[]</code>).
    */
-  public java.util.Map<String, String[]> getPortletRuntimeOptions();
+  public java.util.Map<String, String[]> getContainerRuntimeOptions();
 }

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequest.java?view=diff&rev=548114&r1=548113&r2=548114
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequest.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequest.java Sun Jun 17 14:16:13 2007
@@ -771,16 +771,19 @@
   /**
    * Returns the portal preferred content type for the response.
    * <p>
-   * The content type only includes the MIME type, not the
+   * For <code>ActionRequest, EventRequest</code>, and
+   * <code>RenderRequest</code> the following restrictions apply:
+   * <ul>
+   * <li>The content type only includes the MIME type, not the
    * character set. The character set of the response
-   * can be retrieved via the {@link RenderResponse#getCharacterEncoding}.
-   * <p>
-   * Only content types that the portlet has defined in its
+   * can be retrieved via the {@link RenderResponse#getCharacterEncoding}.</li>
+   * <li>Only content types that the portlet has defined in its
    * deployment descriptor are valid return values for
    * this method call. If the portlet has defined
    * <code>'*'</code> or <code>'* / *'</code> as supported content
-   * types, these may also be valid return values.
-   *
+   * types, these may also be valid return values.</li>
+   * </ul>
+   * 
    * @return preferred MIME type of the response
    */
 
@@ -791,14 +794,17 @@
    * Gets a list of content types which the portal accepts for the response.
    * This list is ordered with the most preferable types listed first.
    * <p>
-   * The content type only includes the MIME type, not the
-   * character set.
-   * <p>
-   * Only content types that the portlet has defined in its
+   * For <code>ActionRequest, EventRequest</code>, and
+   * <code>RenderRequest</code> the following restrictions apply:
+   * <ul>
+   * <li>The content type only includes the MIME type, not the
+   * character set.</li>
+   * <li>Only content types that the portlet has defined in its
    * deployment descriptor are valid return values for
    * this method call. If the portlet has defined
    * <code>'*'</code> or <code>'* / *'</code> as supported content
-   * types, these may also be valid return values.
+   * types, these may also be valid return values.</li>
+   * </ul>
    *
    * @return ordered list of MIME types for the response
    */

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequestDispatcher.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequestDispatcher.java?view=diff&rev=548114&r1=548113&r2=548114
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequestDispatcher.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/portlet2-api/src/main/java/javax/portlet/PortletRequestDispatcher.java Sun Jun 17 14:16:13 2007
@@ -30,8 +30,6 @@
 
 package javax.portlet;
 
-import java.io.IOException;
-
 /**
  * The <code>PortletRequestDispatcher</code> interface defines an object that
  * receives requests from the client and sends them to the specified resources
@@ -55,6 +53,41 @@
      * 
      * 
      * @param request
+     *            a {@link RenderRequest} object that contains the client
+     *            request. Must be either the render request passed to the
+     *            portlet in <code>render</code> or a wrapped version of this
+     *            render request.
+     * 
+     * @param response
+     *            a {@link RenderResponse} object that contains the render
+     *            response. Must be either the render response passed to the
+     *            portlet in <code>render</code> or a wrapped version of this
+     *            render response.
+     * 
+     * @exception PortletException
+     *                if the included resource throws a ServletException, or
+     *                other exceptions that are not Runtime- or IOExceptions.
+     * 
+     * @exception java.io.IOException
+     *                if the included resource throws this exception
+     * 
+     * @deprecated since 2.0, use {@link #include(PortletRequest, PortletResponse)} instead 
+     */
+
+    public void include(RenderRequest request, RenderResponse response)
+            throws PortletException, java.io.IOException;
+
+    /**
+     * 
+     * Includes the content of a resource (servlet, JSP page, HTML file) in the
+     * response. In essence, this method enables programmatic server-side
+     * includes.
+     * <p>
+     * The included servlet cannot set or change the response status code or set
+     * headers; any attempt to make a change is ignored.
+     * 
+     * 
+     * @param request
      *            a {@link PortletRequest} object that contains the portlet
      *            request. Must be either the original request passed to the
      *            portlet or a wrapped version of this request.
@@ -70,6 +103,8 @@
      * 
      * @exception java.io.IOException
      *                if the included resource throws this exception
+     *                
+     * @since 2.0
      */
 
     public void include(PortletRequest request, PortletResponse response)
@@ -105,7 +140,6 @@
     public void forward(PortletRequest request, PortletResponse response)
             throws PortletException, java.io.IOException, java.lang.IllegalStateException;
 
-    public void include(RenderRequest request, RenderResponse response)
-    throws PortletException, java.io.IOException;
+    
 
 }