Zheng,
It seems as though many of the log statements have become unprotected
in your last commit. Is there a reason? (See PortletContainerImpl).
My preference is that we always protect our log statements with checks
to ensure that logging for the specific level is enabled. Please
revert back these log statements if you don't mind.
For instance:
- if (LOG.isDebugEnabled()) {
- LOG.debug("Portlet Container [" + name +
- "]: Render request recieved.");
- }
-
+ debug("Render request received.");
Why the change? Why less detail? Why the removal of the if statement?
Thanks,
David
On 2/1/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Author: zheng
> Date: Wed Feb 1 08:50:04 2006
> New Revision: 374111
>
> URL: http://svn.apache.org/viewcvs?rev=374111&view=rev
> Log:
> Updated javadoc. Added checking initialization method for
> PortletContainerImpl.
>
> Added:
> portals/pluto/trunk/pluto-portal-driver/src/site/
> Modified:
> portals/pluto/trunk/ (props changed)
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainerServices.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalServices.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletResponseImpl.java
>
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/services/PortalCallbackService.java
>
> portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
> portals/pluto/trunk/pluto-site/src/site/site.xml
> portals/pluto/trunk/pom.xml
>
> Propchange: portals/pluto/trunk/
> ------------------------------------------------------------------------------
> --- svn:ignore (original)
> +++ svn:ignore Wed Feb 1 08:50:04 2006
> @@ -1,3 +1,5 @@
> -*.iws
> -*.iml
> -*.ipr
> +.project
> +.svnignore
> +portlet-api-1.0
> +.classpath
> +bin
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainer.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> 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
> Wed Feb 1 08:50:04 2006
> @@ -48,16 +48,16 @@
> public interface PortletContainer {
>
> /**
> - * Initializes the portlet container.
> - * @param context the servlet configuration
> - * @throws PortletContainerException if an error occurs while
> initializing
> - * the container
> + * Initializes the container for use within the given servlet context.
> + * @param servletContext the servlet context.
> + * @throws PortletContainerException if an error occurs.
> */
> - public void init(ServletContext context) throws
> PortletContainerException;
> + public void init(ServletContext servletContext)
> + throws PortletContainerException;
>
> /**
> - * Shuts down the portlet container. After calling this method it is no
> - * longer valid to call any method on the portlet container.
> + * Shuts down the container. After calling this method it is no longer
> valid
> + * to call any method on the portlet container.
> * @throws PortletContainerException if an error occurs while shutting
> down
> * the container
> */
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainerServices.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainerServices.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainerServices.java
> (original)
> +++
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletContainerServices.java
> Wed Feb 1 08:50:04 2006
> @@ -3,7 +3,6 @@
> import org.apache.pluto.services.PortalCallbackService;
>
> import javax.portlet.PortalContext;
> -import javax.servlet.http.HttpServletRequest;
>
> /**
> * Defines the services necessary for integration between the Pluto Container
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java
> (original)
> +++
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java
> Wed Feb 1 08:50:04 2006
> @@ -40,30 +40,30 @@
> * used to communicate back to the referencing portal.
> * @return unique id.
> */
> - ObjectID getId();
> + public ObjectID getId();
>
> /**
> * Retrieve the context path in which the Portlet resides.
> * @return context path
> */
> - String getContextPath();
> + public String getContextPath();
>
> /**
> * Retrieve the name of the portlet as configured in the
> * <code>portlet.xml</code>.
> * @return the name of the portlet.
> */
> - String getPortletName();
> + public String getPortletName();
>
> /**
> * Retrieve the current window state for this window.
> * @return the current window state.
> */
> - WindowState getWindowState();
> + public WindowState getWindowState();
>
> /**
> * Retrieve the current portlet mode for this window.
> * @return the current portlet mode.
> */
> - PortletMode getPortletMode();
> + public PortletMode getPortletMode();
> }
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalServices.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalServices.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalServices.java
> (original)
> +++
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalServices.java
> Wed Feb 1 08:50:04 2006
> @@ -37,9 +37,9 @@
> * @since Sep 18, 2004
> */
> public class DefaultOptionalServices implements
> OptionalPortletContainerServices {
> -
> - private static final Log LOG =
> - LogFactory.getLog(DefaultOptionalServices.class);
> +
> + /** Logger. */
> + private static final Log LOG =
> LogFactory.getLog(DefaultOptionalServices.class);
>
> private PortletPreferencesService preferenceService;
>
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> 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
> Wed Feb 1 08:50:04 2006
> @@ -36,54 +36,69 @@
> /**
> * Default Pluto Container implementation.
> *
> - * @author <a href="[EMAIL PROTECTED]">David H. DeWolf</a>
> + * @author <a href="mailto:[EMAIL PROTECTED]">David H. DeWolf</a>
> + * @author <a href="mailto:[EMAIL PROTECTED]">ZHENG Zhong</a>
> * @version 1.0
> * @since Sep 18, 2004
> */
> public class PortletContainerImpl implements PortletContainer {
>
> /** Internal logger. */
> - private static final Log LOG =
> - LogFactory.getLog(PortletContainerImpl.class);
> -
> + private static final Log LOG =
> LogFactory.getLog(PortletContainerImpl.class);
> +
> +
> + // Private Member Variables
> ------------------------------------------------
> +
> /** The portlet container name. */
> - private String name;
> -
> - /** The PortletContainerServices associated with this container. */
> - private PortletContainerServices containerServices;
> - private OptionalPortletContainerServices optionalContainerServices;
> -
> - /** The ServletContext associated with this container. */
> - private ServletContext context;
> + private String name = null;
> +
> + /** The required container services associated with this container. */
> + private PortletContainerServices containerServices = null;
> +
> + /** The optional container services associated with this container. */
> + private OptionalPortletContainerServices optionalContainerServices =
> null;
> +
> + /** The servlet context associated with this container. */
> + private ServletContext servletContext = null;
>
> /** Flag indicating whether or not we've been initialized. */
> - private boolean initialized;
> -
> + private boolean initialized = false;
> +
> +
> + // Constructor
> -------------------------------------------------------------
> +
> /** Default Constructor. Create a container implementation
> * whith the given name and given services.
> *
> - * @param name the name of the container.
> - * @param services the container services implementation.
> + * @param name the name of the container.
> + * @param requiredServices the required container services
> implementation.
> + * @param optionalServices the optional container services
> implementation.
> */
> public PortletContainerImpl(String name,
> - PortletContainerServices services,
> + PortletContainerServices requiredServices,
> OptionalPortletContainerServices
> optionalServices) {
> this.name = name;
> - this.containerServices = services;
> + this.containerServices = requiredServices;
> this.optionalContainerServices = optionalServices;
> }
> -
> +
> +
> + // PortletContainer Impl
> ---------------------------------------------------
> +
> /**
> * Initialize the container for use within the given configuration scope.
> - * @param context
> + * @param servletContext the servlet context of the portal webapp.
> */
> - public void init(ServletContext context) {
> - this.context = context;
> - initialized = true;
> - if (LOG.isInfoEnabled()) {
> - LOG.debug("Portlet Container [" + name +
> - "] successfully initialized.");
> - }
> + public void init(ServletContext servletContext)
> + throws PortletContainerException {
> + if (servletContext == null) {
> + throw new PortletContainerException(
> + "Unable to initialize portlet container [" +
> name + "]: "
> + + "servlet context is null.");
> + }
> + this.servletContext = servletContext;
> + this.initialized = true;
> + info("Container initialized successfully.");
> }
>
> /**
> @@ -98,169 +113,150 @@
> * Destroy this container.
> */
> public void destroy() {
> - this.context = null;
> - initialized = false;
> + this.servletContext = null;
> + this.initialized = false;
> + info("Container destroyed.");
> }
>
>
> /**
> - * Render the portlet associated with the specified window.
> - * @param pWindow
> - * @param request
> - * @param response
> + * Renders the portlet associated with the specified portlet window.
> + * @param portletWindow the portlet window.
> + * @param request the servlet request.
> + * @param response the servlet response.
> + * @throws IllegalStateException if the container is not initialized.
> * @throws PortletException
> * @throws IOException
> * @throws PortletContainerException
> + *
> + * @see javax.portlet.Portlet#render(RenderRequest, RenderResponse)
> */
> - public void doRender(PortletWindow pWindow,
> + public void doRender(PortletWindow portletWindow,
> HttpServletRequest request,
> HttpServletResponse response)
> - throws PortletException, IOException, PortletContainerException {
> -
> - InternalPortletWindow window = new InternalPortletWindow(context,
> pWindow);
> -
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name +
> - "]: Render request recieved.");
> - }
> -
> - RenderRequestImpl req =
> - new RenderRequestImpl(this, window, request);
> -
> - RenderResponseImpl res =
> - new RenderResponseImpl(this, window, request, response);
> -
> - PortletInvoker invoker = new PortletInvoker(window);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "]: Invoker Created.");
> - }
> -
> - invoker.render(req, res);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "]: Portlet rendered.");
> - }
> + throws PortletException, IOException, PortletContainerException {
> +
> + ensureInitialized();
> +
> + InternalPortletWindow internalPortletWindow =
> + new InternalPortletWindow(servletContext,
> portletWindow);
> + debug("Render request received.");
> +
> + RenderRequestImpl renderRequest = new RenderRequestImpl(
> + this, internalPortletWindow, request);
> + RenderResponseImpl renderResponse = new RenderResponseImpl(
> + this, internalPortletWindow, request, response);
> +
> + PortletInvoker invoker = new PortletInvoker(internalPortletWindow);
> + invoker.render(renderRequest, renderResponse);
> + debug("Portlet rendered.");
> }
>
> /**
> - * Process the action for the portlet associated with the given action.
> - * @param pWindow
> - * @param request
> - * @param response
> + * Process action for the portlet associated with the given portlet
> window.
> + * @param portletWindow the portlet window.
> + * @param request the servlet request.
> + * @param response the servlet response.
> * @throws PortletException
> * @throws IOException
> * @throws PortletContainerException
> + *
> + * @see javax.portlet.Portlet#processAction(ActionRequest,
> ActionResponse)
> */
> - public void doAction(PortletWindow pWindow,
> + public void doAction(PortletWindow portletWindow,
> HttpServletRequest request,
> HttpServletResponse response)
> - throws PortletException, IOException, PortletContainerException {
> -
> - InternalPortletWindow window =
> - new InternalPortletWindow(context, pWindow);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "] Action request
> recieved");
> - }
> -
> - ActionRequestImpl req =
> - new ActionRequestImpl(this, window, request);
> -
> - ActionResponseImpl res =
> - new ActionResponseImpl(this, window, request, response);
> -
> - PortletInvoker invoker = new PortletInvoker(window);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "]: Invoker Created.");
> - }
> - invoker.action(req, res);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug(
> - "Portlet Container [" + name + "]: Portlet Action
> performed.");
> - }
> -
> - String location = res.getRedirectLocation();
> + throws PortletException, IOException, PortletContainerException {
> +
> + ensureInitialized();
> +
> + InternalPortletWindow internalPortletWindow =
> + new InternalPortletWindow(servletContext, portletWindow);
> + debug("Action request received.");
> +
> + ActionRequestImpl actionRequest = new ActionRequestImpl(
> + this, internalPortletWindow, request);
> + ActionResponseImpl actionResponse = new ActionResponseImpl(
> + this, internalPortletWindow, request, response);
> +
> + PortletInvoker invoker = new PortletInvoker(internalPortletWindow);
> + invoker.action(actionRequest, actionResponse);
> + debug("Portlet action processed.");
> +
> + // After processing action, send a redirect URL for rendering.
> + String location = actionResponse.getRedirectLocation();
>
> if (location == null) {
> - if (LOG.isDebugEnabled()) {
> - LOG.debug(
> - "Portlet Container [" + name +
> - "]: No redirect location specified.");
> +
> + // Create portlet URL provider to encode redirect URL.
> + debug("No redirect location specified.");
> + PortletURLProvider redirectURL = containerServices
> + .getPortalCallbackService()
> + .getPortletURLProvider(request,
> internalPortletWindow);
> +
> + // Encode portlet mode if it is changed.
> + if (actionResponse.getChangedPortletMode() != null) {
> + redirectURL.setPortletMode(
> + actionResponse.getChangedPortletMode());
> }
> -
> - PortletURLProvider redirectURL =
> - containerServices.getPortalCallbackService()
> - .getPortletURLProvider(request, window);
> -
> - if (res.getChangedPortletMode() != null) {
> - redirectURL.setPortletMode(res.getChangedPortletMode());
> - }
> -
> - if (res.getChangedWindowState() != null) {
> - redirectURL.setWindowState(res.getChangedWindowState());
> +
> + // Encode window state if it is changed.
> + if (actionResponse.getChangedWindowState() != null) {
> + redirectURL.setWindowState(
> + actionResponse.getChangedWindowState());
> }
> -
> - Map renderParameters = res.getRenderParameters();
> +
> + // Encode render parameters retrieved from action response.
> + Map renderParameters = actionResponse.getRenderParameters();
> redirectURL.clearParameters();
> redirectURL.setParameters(renderParameters);
> +
> + // Encode redirect URL as a render URL.
> redirectURL.setAction(false);
> -
> - if (req.isSecure()) {
> +
> + // Set secure of the redirect URL if necessary.
> + if (actionRequest.isSecure()) {
> redirectURL.setSecure();
> }
> - location = res.encodeRedirectURL(redirectURL.toString());
> +
> + // Encode the redirect URL to a string.
> + location =
> actionResponse.encodeRedirectURL(redirectURL.toString());
> }
>
> // Here we intentionally use the original response
> // instead of the wrapped internal response.
> response.sendRedirect(location);
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "]: Redirect sent.");
> - }
> -
> + debug("Redirect URL sent.");
> }
>
> /**
> - * Load the portlet associated with the specified window.
> - * @param pWindow
> - * @param request
> - * @param response
> + * Loads the portlet associated with the specified portlet window.
> + * @param portletWindow the portlet window.
> + * @param request the servlet request.
> + * @param response the servlet response.
> * @throws PortletException
> + * @throws IOException
> * @throws PortletContainerException
> */
> - public void doLoad(PortletWindow pWindow,
> + public void doLoad(PortletWindow portletWindow,
> HttpServletRequest request,
> HttpServletResponse response)
> - throws PortletException, IOException, PortletContainerException {
> -
> - InternalPortletWindow window = new InternalPortletWindow(context,
> pWindow);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "]: Load request
> recieved.");
> - }
> -
> - RenderRequestImpl req =
> - new RenderRequestImpl(this, window, request);
> -
> - RenderResponseImpl res =
> - new RenderResponseImpl(this, window, request, response);
> -
> - PortletInvoker invoker = new PortletInvoker(window);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "]: Invoker Created.");
> - }
> -
> - invoker.load(req, res);
> -
> - if (LOG.isDebugEnabled()) {
> - LOG.debug("Portlet Container [" + name + "]: Portlet loaded.");
> - }
> -
> + throws PortletException, IOException, PortletContainerException {
> +
> + ensureInitialized();
> +
> + InternalPortletWindow internalPortletWindow =
> + new InternalPortletWindow(servletContext,
> portletWindow);
> + debug("Load request received.");
> +
> + RenderRequestImpl renderRequest = new RenderRequestImpl(
> + this, internalPortletWindow, request);
> + RenderResponseImpl renderResponse = new RenderResponseImpl(
> + this, internalPortletWindow, request, response);
> +
> + PortletInvoker invoker = new PortletInvoker(internalPortletWindow);
> + invoker.load(renderRequest, renderResponse);
> + debug("Portlet loaded.");
> }
>
> public String getName() {
> @@ -274,5 +270,40 @@
> public OptionalPortletContainerServices getOptionalContainerServices() {
> return optionalContainerServices;
> }
> +
> +
> + // Private Methods
> ---------------------------------------------------------
> +
> + /**
> + * Ensures that the portlet container is initialized.
> + * @throws IllegalStateException if the container is not initialized.
> + */
> + private void ensureInitialized() throws IllegalStateException {
> + if (!isInitialized()) {
> + throw new IllegalStateException(
> + "Portlet container [" + name + "] is not
> initialized.");
> + }
> + }
> +
> + /**
> + * Prints a message at DEBUG level with the container name prefix.
> + * @param message log message.
> + */
> + private void debug(String message) {
> + if (LOG.isDebugEnabled()) {
> + LOG.debug("Portlet Container [" + name + "]: " + message);
> + }
> + }
> +
> + /**
> + * Prints a message at INFO level with the container name prefix.
> + * @param message log message.
> + */
> + private void info(String message) {
> + if (LOG.isInfoEnabled()) {
> + LOG.info("Portlet Container [" + name + "]: " + message);
> + }
> + }
> +
> }
>
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
> (original)
> +++
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
> Wed Feb 1 08:50:04 2006
> @@ -15,6 +15,7 @@
> */
> package org.apache.pluto.core;
>
> +import java.util.HashMap;
> import java.util.Map;
>
> import javax.portlet.PortletContext;
> @@ -28,51 +29,62 @@
> * Manager used to cache the portlet configurations which have
> * been previously parsed.
> *
> - * @author <a href="[EMAIL PROTECTED]">David H. DeWolf</a>
> + * @author <a href="mailto:[EMAIL PROTECTED]">David H. DeWolf</a>
> + * @author <a href="mailto:[EMAIL PROTECTED]">ZHENG Zhong</a>
> * @version 1.0
> * @since Sep 20, 2004
> */
> public class PortletContextManager {
>
> - /** Singleton instance. */
> - private static PortletContextManager manager;
> + /** The singleton manager instance. */
> + private static final PortletContextManager MANAGER = new
> PortletContextManager();
>
> + // Private Member Variables
> ------------------------------------------------
> +
> /**
> - * Singleton accessor method.
> - * @return the PortletContextManager implementation.
> + * The PortletContext cache map: key is servlet context, and value is the
> + * associated portlet context.
> + */
> + private Map portletContexts = new HashMap();
> +
> +
> + // Constructor
> -------------------------------------------------------------
> +
> + /**
> + * Private constructor that prevents external instantiation.
> */
> - public static PortletContextManager getManager() {
> - if (manager == null) {
> - manager = new PortletContextManager();
> - }
> - return manager;
> - }
> -
> - /** The PortletContext cache. */
> - private Map contexts;
> -
> - /** Singleton Constructor. */
> private PortletContextManager() {
> - contexts = new java.util.HashMap();
> + // Do nothing.
> }
>
> -
> + /**
> + * Returns the singleton manager instance.
> + * @return the singleton manager instance.
> + */
> + public static PortletContextManager getManager() {
> + return MANAGER;
> + }
> +
> +
> + // Public Methods
> ----------------------------------------------------------
>
> /**
> - * Retrieve the PortletContext associated with the given ServletContext.
> + * Retrieves the PortletContext associated with the given ServletContext.
> * If one does not exist, it is created.
> *
> - * @param context the servlet context
> - * @return the portlet context existing within the ServletContext.
> + * @param servletContext the servlet context.
> + * @return the InternalPortletContext associated with the ServletContext.
> * @throws PortletContainerException
> */
> - public InternalPortletContext getContext(ServletContext context)
> - throws PortletContainerException {
> - if (!contexts.containsKey(context)) {
> - PortletAppDD def =
> PortletDescriptorRegistry.getRegistry().getPortletAppDD(context);
> - PortletContext pc = new PortletContextImpl(context, def);
> - contexts.put(context, pc);
> + public InternalPortletContext getPortletContext(ServletContext
> servletContext)
> + throws PortletContainerException {
> + if (!portletContexts.containsKey(servletContext)) {
> + PortletAppDD portletAppDD =
> PortletDescriptorRegistry.getRegistry()
> + .getPortletAppDD(servletContext);
> + PortletContext portletContext = new PortletContextImpl(
> + servletContext, portletAppDD);
> + portletContexts.put(servletContext, portletContext);
> }
> - return (InternalPortletContext) contexts.get(context);
> + return (InternalPortletContext) portletContexts.get(servletContext);
> }
> }
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
> (original)
> +++
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
> Wed Feb 1 08:50:04 2006
> @@ -33,96 +33,117 @@
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import java.io.IOException;
> -import java.util.List;
> +import java.util.Iterator;
>
> /**
> * Portlet Invocation Servlet. This servlet recieves cross context requests
> from
> * the the container and services the portlet request for the specified
> method.
> + *
> * @author <a href="mailto:[EMAIL PROTECTED]">David H. DeWolf</a>
> * @version 1.1
> * @since 09/22/2004
> */
> public class PortletServlet extends HttpServlet {
> -
> - private String portletName;
> -
> - private Portlet portlet;
> - private InternalPortletContext portletContext;
> - private InternalPortletConfig portletConfig;
> -
> +
> + // Private Member Variables
> ------------------------------------------------
> +
> + /** The portlet name as defined in the portlet app descriptor. */
> + private String portletName = null;
> +
> + /** The portlet instance wrapped by this servlet. */
> + private Portlet portlet = null;
> +
> + /** The internal portlet context instance. */
> + private InternalPortletContext portletContext = null;
> +
> + /** The internal portlet config instance. */
> + private InternalPortletConfig portletConfig = null;
> +
> +
> + // HttpServlet Impl
> --------------------------------------------------------
> +
> public String getServletInfo() {
> return "Pluto PortletServlet [" + portletName + "]";
> }
> -
> +
> + /**
> + * Initialize the portlet invocation servlet.
> + * @throws ServletException if an error occurs while loading portlet.
> + */
> public void init() throws ServletException {
> -
> +
> + // Call the super initialization method.
> + super.init();
> +
> + // Retrieve portlet name as defined as an initialization parameter.
> portletName = getInitParameter("portlet-name");
> -
> - ServletContext context = getServletContext();
> -
> +
> + // Retrieve the associated internal portlet context.
> + ServletContext servletContext = getServletContext();
> try {
> - portletContext =
> - PortletContextManager.getManager().getContext(context);
> - } catch (PortletContainerException pce) {
> - throw new ServletException(pce);
> + portletContext = PortletContextManager.getManager()
> + .getPortletContext(servletContext);
> + } catch (PortletContainerException ex) {
> + throw new ServletException(ex);
> }
> -
> - PortletAppDD appDD =
> portletContext.getPortletApplicationDefinition();
> - List dds = appDD.getPortlets();
> -
> - PortletDD dd = null;
> - for (int i = 0; i < dds.size(); i++) {
> - PortletDD pd = (PortletDD)dds.get(i);
> - if (pd.getPortletName().equals(portletName)) {
> - dd = pd;
> - break;
> - }
> +
> + // Retrieve the portletDD and create portlet config.
> + PortletDD portletDD = null;
> + PortletAppDD portletAppDD =
> + portletContext.getPortletApplicationDefinition();
> + for (Iterator it = portletAppDD.getPortlets().iterator();
> + it.hasNext(); ) {
> + PortletDD currentDD = (PortletDD) it.next();
> + if (currentDD.getPortletName().equals(portletName)) {
> + portletDD = currentDD;
> + break;
> + }
> }
> -
> - if (dd == null) {
> - throw new ServletException(
> - "Unable to resolve portlet '" + portletName + "'");
> + if (portletDD == null) {
> + throw new ServletException("Unable to resolve portlet '"
> + + portletName + "'");
> }
> -
> portletConfig = new PortletConfigImpl(getServletConfig(),
> - portletContext, dd);
> -
> + portletContext,
> + portletDD);
> +
> + // Create and initialize the portlet wrapped in the servlet.
> try {
> ClassLoader loader =
> Thread.currentThread().getContextClassLoader();
> - Class pClass = loader.loadClass((dd.getPortletClass()));
> - portlet = (Portlet) pClass.newInstance();
> + Class clazz = loader.loadClass((portletDD.getPortletClass()));
> + portlet = (Portlet) clazz.newInstance();
> portlet.init(portletConfig);
> - } catch (ClassNotFoundException cne) {
> - cne.printStackTrace();
> - throw new ServletException(cne);
> - } catch (IllegalAccessException e) {
> - e.printStackTrace();
> - throw new ServletException(e);
> - } catch (InstantiationException e) {
> - e.printStackTrace();
> - throw new ServletException(e);
> - } catch (PortletException pe) {
> - pe.printStackTrace();
> - throw new ServletException(pe);
> + } catch (ClassNotFoundException ex) {
> + ex.printStackTrace();
> + throw new ServletException(ex);
> + } catch (IllegalAccessException ex) {
> + ex.printStackTrace();
> + throw new ServletException(ex);
> + } catch (InstantiationException ex) {
> + ex.printStackTrace();
> + throw new ServletException(ex);
> + } catch (PortletException ex) {
> + ex.printStackTrace();
> + throw new ServletException(ex);
> }
> }
>
> - protected void doGet(HttpServletRequest req,
> - HttpServletResponse resp)
> - throws ServletException, IOException {
> - dispatch(req, resp);
> - }
> -
> - protected void doPost(HttpServletRequest req,
> - HttpServletResponse resp)
> - throws ServletException, IOException {
> - dispatch(req, resp);
> - }
> -
> - protected void doPut(HttpServletRequest req,
> - HttpServletResponse resp)
> - throws ServletException, IOException {
> - dispatch(req, resp);
> + protected void doGet(HttpServletRequest request,
> + HttpServletResponse response)
> + throws ServletException, IOException {
> + dispatch(request, response);
> + }
> +
> + protected void doPost(HttpServletRequest request,
> + HttpServletResponse response)
> + throws ServletException, IOException {
> + dispatch(request, response);
> + }
> +
> + protected void doPut(HttpServletRequest request,
> + HttpServletResponse response)
> + throws ServletException, IOException {
> + dispatch(request, response);
> }
>
> public void destroy() {
> @@ -131,50 +152,70 @@
> }
> super.destroy();
> }
> -
> +
> +
> + // Private Methods
> ---------------------------------------------------------
> +
> + /**
> + * Dispatch the request to the appropriate portlet methods. This method
> + * assumes that the following attributes are set in the servlet request
> + * scope:
> + * <ul>
> + * <li>METHOD_ID: indicating which method to dispatch.</li>
> + * <li>PORTLET_REQUEST: the internal portlet request.</li>
> + * <li>PORTLET_RESPONSE: the internal portlet response.</li>
> + * </ul>
> + *
> + * @param request the servlet request.
> + * @param response the servlet response.
> + * @throws ServletException
> + * @throws IOException
> + */
> private void dispatch(HttpServletRequest request,
> HttpServletResponse response)
> - throws ServletException, IOException {
> - InternalPortletRequest pRequest = null;
> - InternalPortletResponse pResponse = null;
> + throws ServletException, IOException {
> + InternalPortletRequest portletRequest = null;
> + InternalPortletResponse portletResponse = null;
> try {
> - request.setAttribute(org.apache.pluto.Constants.PORTLET_CONFIG,
> - portletConfig);
> -
> - Integer method_id =
> - (Integer) request.getAttribute(
> - org.apache.pluto.Constants.METHOD_ID);
> -
> - pRequest = (InternalPortletRequest)
> - request.getAttribute(Constants.PORTLET_REQUEST);
> -
> - pResponse = (InternalPortletResponse)
> - request.getAttribute(Constants.PORTLET_RESPONSE);
> -
> - pRequest.init(portletContext, request);
> -
> - if (method_id == org.apache.pluto.Constants.METHOD_RENDER) {
> +
> + // Save portlet config into servlet request.
> + request.setAttribute(Constants.PORTLET_CONFIG, portletConfig);
> +
> + // Retrieve attributes from the servlet request.
> + Integer methodId = (Integer) request.getAttribute(
> + Constants.METHOD_ID);
> + portletRequest = (InternalPortletRequest) request.getAttribute(
> + Constants.PORTLET_REQUEST);
> + portletResponse = (InternalPortletResponse) request.getAttribute(
> + Constants.PORTLET_RESPONSE);
> + portletRequest.init(portletContext, request);
> +
> + // The requested method is RENDER: call Portlet.render(..)
> + if (methodId == Constants.METHOD_RENDER) {
> RenderRequestImpl renderRequest =
> - (RenderRequestImpl) pRequest;
> -
> + (RenderRequestImpl) portletRequest;
> RenderResponseImpl renderResponse =
> - (RenderResponseImpl) pResponse;
> -
> + (RenderResponseImpl) portletResponse;
> portlet.render(renderRequest, renderResponse);
> - } else if (method_id ==
> org.apache.pluto.Constants.METHOD_ACTION) {
> +
> + }
> +
> + // The requested method is ACTION: call Portlet.processAction(..)
> + else if (methodId == Constants.METHOD_ACTION) {
> ActionRequestImpl actionRequest =
> - (ActionRequestImpl) pRequest;
> -
> + (ActionRequestImpl) portletRequest;
> ActionResponseImpl actionResponse =
> - (ActionResponseImpl) pResponse;
> -
> + (ActionResponseImpl) portletResponse;
> portlet.processAction(actionRequest, actionResponse);
> - } else if (method_id == org.apache.pluto.Constants.METHOD_NOOP) {
> - //nothing to do
> + }
> +
> + // The requested method is NOOP: do nothing.
> + else if (methodId == Constants.METHOD_NOOP) {
> + // Do nothing.
> }
>
> - } catch (javax.portlet.UnavailableException e) {
> - e.printStackTrace();
> + } catch (javax.portlet.UnavailableException ex) {
> + ex.printStackTrace();
> /*
> if (e.isPermanent()) {
> throw new UnavailableException(e.getMessage());
> @@ -182,24 +223,25 @@
> throw new UnavailableException(e.getMessage(),
> e.getUnavailableSeconds());
> }*/
>
> - // destroy isn't called by Tomcat, so we have to fix it
> + // Portlet.destroy() isn't called by Tomcat, so we have to fix
> it.
> try {
> portlet.destroy();
> - } catch (Throwable t) {
> - // don't care for Exception
> + } catch (Throwable th) {
> + // Don't care for Exception
> }
> -
> - // handle everything as permanently for now
> - throw new javax.servlet.UnavailableException(e.getMessage());
> - } catch (PortletException e) {
> - e.printStackTrace();
> - throw new ServletException(e);
> +
> + // TODO: Handle everything as permanently for now.
> + throw new javax.servlet.UnavailableException(ex.getMessage());
> +
> + } catch (PortletException ex) {
> + ex.printStackTrace();
> + throw new ServletException(ex);
> +
> } finally {
> -
> request.removeAttribute(org.apache.pluto.Constants.PORTLET_CONFIG);
> -
> - if(pRequest != null)
> - pRequest.release();
> -
> + request.removeAttribute(Constants.PORTLET_CONFIG);
> + if (portletRequest != null) {
> + portletRequest.release();
> + }
> }
> }
> }
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletResponseImpl.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletResponseImpl.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletResponseImpl.java
> (original)
> +++
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletResponseImpl.java
> Wed Feb 1 08:50:04 2006
> @@ -27,6 +27,7 @@
> import javax.servlet.ServletOutputStream;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> +import javax.servlet.http.HttpServletResponseWrapper;
>
> import org.apache.pluto.PortletContainer;
> import org.apache.pluto.PortletContainerServices;
> @@ -35,9 +36,8 @@
> import org.apache.pluto.services.ResourceURLProvider;
> import org.apache.pluto.util.PrintWriterServletOutputStream;
>
> -public abstract class PortletResponseImpl
> - extends javax.servlet.http.HttpServletResponseWrapper
> - implements InternalPortletResponse, PortletResponse {
> +public abstract class PortletResponseImpl extends HttpServletResponseWrapper
> +implements InternalPortletResponse, PortletResponse {
>
> PortletContainer container;
>
>
> Modified:
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/services/PortalCallbackService.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/services/PortalCallbackService.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/services/PortalCallbackService.java
> (original)
> +++
> portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/services/PortalCallbackService.java
> Wed Feb 1 08:50:04 2006
> @@ -23,7 +23,9 @@
> import java.util.Map;
>
> /**
> - * @author <a href="[EMAIL PROTECTED]">David H. DeWolf</a>
> + * The callback service interface defining callback methods that will be
> invoked
> + * by the portlet container when necessary.
> + * @author <a href="mailto:[EMAIL PROTECTED]">David H. DeWolf</a>
> * @version 1.0
> * @since Sep 21, 2004
> */
> @@ -31,40 +33,44 @@
>
> /**
> * Set the title to be used for this portlet.
> - * @param request
> - * @param window
> - * @param title
> + * @param request the servlet request.
> + * @param portletWindow the portlet window.
> + * @param title the title to set.
> */
> public void setTitle(HttpServletRequest request,
> - PortletWindow window,
> + PortletWindow portletWindow,
> String title);
>
> /**
> - * Returns an URL pointing to the given portlet window
> - * @param portletWindow the portlet Window
> - * @return the URL to the given portlet
> + * Returns a URL provider used to constuct a URL to the given portlet.
> + * @param request the servlet request.
> + * @param portletWindow the portlet window.
> + * @return the URL provider used to construct a URL to the given portlet.
> */
> - public PortletURLProvider getPortletURLProvider(HttpServletRequest req,
> + public PortletURLProvider getPortletURLProvider(HttpServletRequest
> request,
> PortletWindow
> portletWindow);
>
> /**
> - * Returns the ResourceURLProvider to create URLs pointing to a resource
> in
> - * a web application.
> - * @param portletWindow the portlet Window
> - * @return the URL to a resource
> + * Returns a URL provider used to construct a URL to a resource in the
> web
> + * application.
> + * @param request the servlet request.
> + * @param portletWindow the portlet window.
> + * @return the URL provider used to construct a URL to a resource.
> */
> - public ResourceURLProvider getResourceURLProvider(HttpServletRequest req,
> + public ResourceURLProvider getResourceURLProvider(HttpServletRequest
> request,
> PortletWindow
> portletWindow);
>
> - public Map getRequestProperties(HttpServletRequest req,
> + public Map getRequestProperties(HttpServletRequest request,
> PortletWindow portletWindow);
>
> - public void setResponseProperty(HttpServletRequest req,
> - PortletWindow window,
> - String property, String value);
> -
> - public void addResponseProperty(HttpServletRequest req,
> - PortletWindow window,
> - String property, String value);
> + public void setResponseProperty(HttpServletRequest request,
> + PortletWindow portletWindow,
> + String property,
> + String value);
> +
> + public void addResponseProperty(HttpServletRequest request,
> + PortletWindow portletWindow,
> + String property,
> + String value);
>
> }
>
> Modified:
> portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> ---
> portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
> (original)
> +++
> portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
> Wed Feb 1 08:50:04 2006
> @@ -29,7 +29,7 @@
> import org.apache.pluto.om.ObjectID;
>
> /**
> - * Implementation of <code>javax.portlet.PortletWindow</code> interface.
> + * Implementation of <code>PortletWindow</code> interface.
> * @author <a href="mailto:[EMAIL PROTECTED]">ZHENG Zhong</a>
> * @author <a href="mailto:[EMAIL PROTECTED]">David H. DeWolf</a>
> */
>
> Modified: portals/pluto/trunk/pluto-site/src/site/site.xml
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-site/src/site/site.xml?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> --- portals/pluto/trunk/pluto-site/src/site/site.xml (original)
> +++ portals/pluto/trunk/pluto-site/src/site/site.xml Wed Feb 1 08:50:04 2006
> @@ -66,15 +66,15 @@
> <menu name="Subprojects" href="subprojects.html" collapsed="true">
> <item name="Portlet Container" href="/pluto-container/index.html"/>
> <item name="Portlet Tags" href="/pluto-taglib/index.html"/>
> - <item name="Portal Driver" href="/pluto-container/index.html"/>
> - <item name="Portal" href="/pluto-container/index.html"/>
> + <item name="Portal Driver" href="/pluto-portal-driver/index.html"/>
> + <item name="Portal" href="/pluto-portal/index.html"/>
> <item name="Testsuite" href="/pluto-testsuite/index.html"/>
> <item name="Descriptor API" href="/pluto-descriptor-api/index.html"/>
> <item name="Descriptor Impl"
> href="/pluto-descriptor-impl/index.html"/>
> <item name="Optional Services"
> href="/pluto-optional-services/index.html"/>
> <item name="Maven Plugin" href="/maven-pluto-plugin/index.html"/>
> <item name="Ant Tasks" href="/pluto-ant-tasks/index.html"/>
> - <item name="Util" href="/pluto-container/index.html"/>
> + <item name="Util" href="/pluto-util/index.html"/>
> </menu>
> </menu>
>
>
> Modified: portals/pluto/trunk/pom.xml
> URL:
> http://svn.apache.org/viewcvs/portals/pluto/trunk/pom.xml?rev=374111&r1=374110&r2=374111&view=diff
> ==============================================================================
> --- portals/pluto/trunk/pom.xml (original)
> +++ portals/pluto/trunk/pom.xml Wed Feb 1 08:50:04 2006
> @@ -1,3 +1,5 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> <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">
>
>
>