portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r607448 [22/36] - in /portals/pluto/branches/pluto-1.1.x: ./ assembly/src/main/assembly/ assembly/src/main/resources/ maven-pluto-plugin/ maven-pluto-plugin/src/main/java/org/apache/pluto/maven/ pluto-ant-tasks/ pluto-ant-tasks/src/assemble...
Date Sat, 29 Dec 2007 17:20:42 GMT
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java Sat Dec 29 09:20:23 2007
@@ -1,187 +1,187 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver;
-
-import java.io.IOException;
-
-import javax.portlet.PortletException;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletContainerException;
-import org.apache.pluto.driver.config.DriverConfiguration;
-import org.apache.pluto.driver.core.PortalRequestContext;
-import org.apache.pluto.driver.core.PortletWindowImpl;
-import org.apache.pluto.driver.services.portal.PageConfig;
-import org.apache.pluto.driver.services.portal.PortletWindowConfig;
-import org.apache.pluto.driver.url.PortalURL;
-
-/**
- * The controller servlet used to drive the Portal Driver. All requests mapped
- * to this servlet will be processed as Portal Requests.
- *
- * @version 1.0
- * @since Sep 22, 2004
- */
-public class PortalDriverServlet extends HttpServlet {
-
-    /** Internal Logger. */
-    private static final Log LOG = LogFactory.getLog(PortalDriverServlet.class);
-
-    /** The Portal Driver sServlet Context */
-    private ServletContext servletContext;
-
-    public static final String DEFAULT_PAGE_URI =
-    		"/WEB-INF/themes/pluto-default-theme.jsp";
-
-    /** The portlet container to which we will forward all portlet requests. */
-    protected PortletContainer container;
-
-
-
-
-    // HttpServlet Impl --------------------------------------------------------
-
-    public String getServletInfo() {
-        return "Pluto Portal Driver Servlet";
-    }
-
-    /**
-     * Initialize the Portal Driver. This method retrieves the portlet container
-     * instance from the servlet context scope.
-     * @see PortletContainer
-     */
-    public void init() {
-        servletContext = getServletContext();
-        container = (PortletContainer) servletContext.getAttribute(
-        		AttributeKeys.PORTLET_CONTAINER);
-    }
-
-
-    /**
-     * Handle all requests. All POST requests are passed to this method.
-     * @param request  the incoming HttpServletRequest.
-     * @param response  the incoming HttpServletResponse.
-     * @throws ServletException  if an internal error occurs.
-     * @throws IOException  if an error occurs writing to the response.
-     */
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-    throws ServletException, IOException {
-
-        PortalRequestContext portalRequestContext =
-            new PortalRequestContext(getServletContext(), request, response);
-
-        PortalURL portalURL = portalRequestContext.getRequestedPortalURL();
-        String actionWindowId = portalURL.getActionWindow();
-
-        PortletWindowConfig actionWindowConfig =
-            actionWindowId == null
-                ? null
-                : PortletWindowConfig.fromId(actionWindowId);
-
-        // Action window config will only exist if there is an action request.
-        if (actionWindowConfig != null) {
-            PortletWindowImpl portletWindow = new PortletWindowImpl(
-            		actionWindowConfig, portalURL);
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Processing action request for window: "
-                		+ portletWindow.getId().getStringId());
-            }
-            try {
-                container.doAction(portletWindow, request, response);
-            } catch (PortletContainerException ex) {
-                throw new ServletException(ex);
-            } catch (PortletException ex) {
-                throw new ServletException(ex);
-            }
-            if (LOG.isDebugEnabled()) {
-            	LOG.debug("Action request processed.\n\n");
-            }
-        }
-
-        // Otherwise (actionWindowConfig == null), handle the render request.
-        else {
-        	if (LOG.isDebugEnabled()) {
-        		LOG.debug("Processing render request.");
-        	}
-            PageConfig pageConfig = getPageConfig(portalURL);
-            if (pageConfig == null)
-            {
-                // TODO Shouldn't we throw an exception here?
-                LOG.error("PageConfig for render path [" + portalURL.getRenderPath() + "] could not be found.");
-            }
-
-            request.setAttribute(AttributeKeys.CURRENT_PAGE, pageConfig);
-            String uri = (pageConfig.getUri() != null)
-            		? pageConfig.getUri() : DEFAULT_PAGE_URI;
-            if (LOG.isDebugEnabled()) {
-            	LOG.debug("Dispatching to: " + uri);
-            }
-            RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
-            dispatcher.forward(request, response);
-            if (LOG.isDebugEnabled()) {
-            	LOG.debug("Render request processed.\n\n");
-            }
-        }
-    }
-
-    /**
-     * Pass all POST requests to {@link #doGet(HttpServletRequest, HttpServletResponse)}.
-     * @param request  the incoming servlet request.
-     * @param response  the incoming servlet response.
-     * @throws ServletException if an exception occurs.
-     * @throws IOException if an exception occurs writing to the response.
-     */
-    public void doPost(HttpServletRequest request, HttpServletResponse response)
-    throws ServletException, IOException {
-        doGet(request, response);
-    }
-
-
-    // Private Methods ---------------------------------------------------------
-
-    /**
-     * Returns the config of the portal page to be rendered.
-     * @param currentURL  the current portal URL.
-     * @return the config of the portal page to be rendered.
-     */
-    private PageConfig getPageConfig(PortalURL currentURL) {
-        String requestedPageId = currentURL.getRenderPath();
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Rendering Portal: Requested Page: " + requestedPageId);
-        }
-        return getDriverConfiguration().getPageConfig(requestedPageId);
-    }
-
-    /**
-     * Returns the portal driver configuration object.
-     * @return the portal driver configuration object.
-     */
-    private DriverConfiguration getDriverConfiguration() {
-        return (DriverConfiguration) getServletContext().getAttribute(
-        		AttributeKeys.DRIVER_CONFIG);
-    }
-
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver;
+
+import java.io.IOException;
+
+import javax.portlet.PortletException;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.core.PortalRequestContext;
+import org.apache.pluto.driver.core.PortletWindowImpl;
+import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.services.portal.PortletWindowConfig;
+import org.apache.pluto.driver.url.PortalURL;
+
+/**
+ * The controller servlet used to drive the Portal Driver. All requests mapped
+ * to this servlet will be processed as Portal Requests.
+ *
+ * @version 1.0
+ * @since Sep 22, 2004
+ */
+public class PortalDriverServlet extends HttpServlet {
+
+    /** Internal Logger. */
+    private static final Log LOG = LogFactory.getLog(PortalDriverServlet.class);
+
+    /** The Portal Driver sServlet Context */
+    private ServletContext servletContext;
+
+    public static final String DEFAULT_PAGE_URI =
+    		"/WEB-INF/themes/pluto-default-theme.jsp";
+
+    /** The portlet container to which we will forward all portlet requests. */
+    protected PortletContainer container;
+
+
+
+
+    // HttpServlet Impl --------------------------------------------------------
+
+    public String getServletInfo() {
+        return "Pluto Portal Driver Servlet";
+    }
+
+    /**
+     * Initialize the Portal Driver. This method retrieves the portlet container
+     * instance from the servlet context scope.
+     * @see PortletContainer
+     */
+    public void init() {
+        servletContext = getServletContext();
+        container = (PortletContainer) servletContext.getAttribute(
+        		AttributeKeys.PORTLET_CONTAINER);
+    }
+
+
+    /**
+     * Handle all requests. All POST requests are passed to this method.
+     * @param request  the incoming HttpServletRequest.
+     * @param response  the incoming HttpServletResponse.
+     * @throws ServletException  if an internal error occurs.
+     * @throws IOException  if an error occurs writing to the response.
+     */
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+    throws ServletException, IOException {
+
+        PortalRequestContext portalRequestContext =
+            new PortalRequestContext(getServletContext(), request, response);
+
+        PortalURL portalURL = portalRequestContext.getRequestedPortalURL();
+        String actionWindowId = portalURL.getActionWindow();
+
+        PortletWindowConfig actionWindowConfig =
+            actionWindowId == null
+                ? null
+                : PortletWindowConfig.fromId(actionWindowId);
+
+        // Action window config will only exist if there is an action request.
+        if (actionWindowConfig != null) {
+            PortletWindowImpl portletWindow = new PortletWindowImpl(
+            		actionWindowConfig, portalURL);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Processing action request for window: "
+                		+ portletWindow.getId().getStringId());
+            }
+            try {
+                container.doAction(portletWindow, request, response);
+            } catch (PortletContainerException ex) {
+                throw new ServletException(ex);
+            } catch (PortletException ex) {
+                throw new ServletException(ex);
+            }
+            if (LOG.isDebugEnabled()) {
+            	LOG.debug("Action request processed.\n\n");
+            }
+        }
+
+        // Otherwise (actionWindowConfig == null), handle the render request.
+        else {
+        	if (LOG.isDebugEnabled()) {
+        		LOG.debug("Processing render request.");
+        	}
+            PageConfig pageConfig = getPageConfig(portalURL);
+            if (pageConfig == null)
+            {
+                // TODO Shouldn't we throw an exception here?
+                LOG.error("PageConfig for render path [" + portalURL.getRenderPath() + "] could not be found.");
+            }
+
+            request.setAttribute(AttributeKeys.CURRENT_PAGE, pageConfig);
+            String uri = (pageConfig.getUri() != null)
+            		? pageConfig.getUri() : DEFAULT_PAGE_URI;
+            if (LOG.isDebugEnabled()) {
+            	LOG.debug("Dispatching to: " + uri);
+            }
+            RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
+            dispatcher.forward(request, response);
+            if (LOG.isDebugEnabled()) {
+            	LOG.debug("Render request processed.\n\n");
+            }
+        }
+    }
+
+    /**
+     * Pass all POST requests to {@link #doGet(HttpServletRequest, HttpServletResponse)}.
+     * @param request  the incoming servlet request.
+     * @param response  the incoming servlet response.
+     * @throws ServletException if an exception occurs.
+     * @throws IOException if an exception occurs writing to the response.
+     */
+    public void doPost(HttpServletRequest request, HttpServletResponse response)
+    throws ServletException, IOException {
+        doGet(request, response);
+    }
+
+
+    // Private Methods ---------------------------------------------------------
+
+    /**
+     * Returns the config of the portal page to be rendered.
+     * @param currentURL  the current portal URL.
+     * @return the config of the portal page to be rendered.
+     */
+    private PageConfig getPageConfig(PortalURL currentURL) {
+        String requestedPageId = currentURL.getRenderPath();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Rendering Portal: Requested Page: " + requestedPageId);
+        }
+        return getDriverConfiguration().getPageConfig(requestedPageId);
+    }
+
+    /**
+     * Returns the portal driver configuration object.
+     * @return the portal driver configuration object.
+     */
+    private DriverConfiguration getDriverConfiguration() {
+        return (DriverConfiguration) getServletContext().getAttribute(
+        		AttributeKeys.DRIVER_CONFIG);
+    }
+
+}
+

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java Sat Dec 29 09:20:23 2007
@@ -1,274 +1,274 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.OptionalContainerServices;
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletContainerException;
-import org.apache.pluto.PortletContainerFactory;
-import org.apache.pluto.RequiredContainerServices;
-import org.apache.pluto.driver.config.AdminConfiguration;
-import org.apache.pluto.driver.config.DriverConfiguration;
-import org.apache.pluto.driver.config.DriverConfigurationException;
-import org.springframework.web.context.WebApplicationContext;
-
-/**
- * Listener used to start up / shut down the Pluto Portal Driver upon startup /
- * showdown of the servlet context in which it resides.
- * <p/>
- * Startup Includes:
- * <ol>
- * <li>Instantiation of the DriverConfiguration</li>
- * <li>Registration of the DriverConfiguration</li>
- * <li>Instantiation of the PortalContext</li>
- * <li>Registration of the PortalContext</li>
- * <li>Instantiation of the ContainerServices</li>
- * <li>Registration of the ContainerServices</li>
- * </ol>
- *
- * @version $Revision$ $Date$
- * @since Sep 22, 2004
- */
-public class PortalStartupListener implements ServletContextListener {
-
-    /**
-     * Internal logger.
-     */
-    private static final Log LOG = LogFactory.getLog(
-            PortalStartupListener.class);
-
-    /**
-     * The KEY with which the container is bound to the context.
-     */
-    private static final String CONTAINER_KEY = AttributeKeys.PORTLET_CONTAINER;
-
-    /**
-     * The KEY with which the driver configuration is bound to the context.
-     */
-    private static final String DRIVER_CONFIG_KEY = AttributeKeys.DRIVER_CONFIG;
-
-    /**
-     * The KEY with which the admin configuration is bound to the context.
-     */
-    private static final String ADMIN_CONFIG_KEY = AttributeKeys.DRIVER_ADMIN_CONFIG;
-
-    // ServletContextListener Impl ---------------------------------------------
-
-    /**
-     * Receives the startup notification and subsequently starts up the portal
-     * driver. The following are done in this order:
-     * <ol>
-     * <li>Retrieve the ResourceConfig File</li>
-     * <li>Parse the ResourceConfig File into ResourceConfig Objects</li>
-     * <li>Create a Portal Context</li>
-     * <li>Create the ContainerServices implementation</li>
-     * <li>Create the Portlet Container</li>
-     * <li>Initialize the Container</li>
-     * <li>Bind the configuration to the ServletContext</li>
-     * <li>Bind the container to the ServletContext</li>
-     * <ol>
-     *
-     * @param event the servlet context event.
-     */
-    public void contextInitialized(ServletContextEvent event) {
-        LOG.info("Starting up Pluto Portal Driver. . .");
-
-        ServletContext servletContext = event.getServletContext();
-
-        WebApplicationContext springContext = (WebApplicationContext)
-                servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
-
-        LOG.debug(" [1a] Loading DriverConfiguration. . . ");
-        DriverConfiguration driverConfiguration = (DriverConfiguration)
-                springContext.getBean("DriverConfiguration");
-
-        driverConfiguration.init(servletContext);
-
-        LOG.debug(" [1b] Registering DriverConfiguration. . .");
-        servletContext.setAttribute(DRIVER_CONFIG_KEY, driverConfiguration);
-
-
-        LOG.debug(" [2a] Loading Optional AdminConfiguration. . .");
-        AdminConfiguration adminConfiguration = (AdminConfiguration)
-                springContext.getBean("AdminConfiguration");
-
-        if (adminConfiguration != null) {
-            LOG.debug(" [2b] Registering Optional AdminConfiguration");
-            servletContext.setAttribute(ADMIN_CONFIG_KEY, adminConfiguration);
-        } else {
-            LOG.info("Optional AdminConfiguration not found. Ignoring.");
-        }
-
-        initContainer(servletContext);
-
-        LOG.info("********** Pluto Portal Driver Started **********\n\n");
-    }
-
-    /**
-     * Recieve notification that the context is being shut down and subsequently
-     * destroy the container.
-     *
-     * @param event the destrubtion event.
-     */
-    public void contextDestroyed(ServletContextEvent event) {
-        ServletContext servletContext = event.getServletContext();
-        if (LOG.isInfoEnabled()) {
-            LOG.info("Shutting down Pluto Portal Driver...");
-        }
-        destroyContainer(servletContext);
-        destroyAdminConfiguration(servletContext);
-        destroyDriverConfiguration(servletContext);
-        if (LOG.isInfoEnabled()) {
-            LOG.info("********** Pluto Portal Driver Shut Down **********\n\n");
-        }
-    }
-
-
-    /**
-     * Initializes the portlet container. This method constructs and initializes
-     * the portlet container, and saves it to the servlet context scope.
-     *
-     * @param servletContext the servlet context.
-     */
-    private void initContainer(ServletContext servletContext) {
-
-        WebApplicationContext springContext = (WebApplicationContext)
-                servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
-
-        // Retrieve the driver configuration from servlet context.
-        DriverConfiguration driverConfig = (DriverConfiguration)
-                servletContext.getAttribute(DRIVER_CONFIG_KEY);
-
-        try {
-            LOG.info("Initializing Portlet Container. . .");
-
-            LOG.debug(" [1] Loading RequiredContainerServices. . .");
-            RequiredContainerServices required =
-                    (RequiredContainerServices) springContext.getBean("RequiredContainerServices");
-
-            LOG.debug(" [2] Loading OptionalContainerServices. . .");
-            OptionalContainerServices optional =
-                    (OptionalContainerServices) springContext.getBean("OptionalContainerServices");
-
-
-            // Create portlet container.
-            LOG.debug(" [3] Creating portlet container...");
-            PortletContainerFactory factory =
-                    PortletContainerFactory.getInstance();
-            PortletContainer container = factory.createContainer(
-                driverConfig.getContainerName(), required, optional
-            );
-
-            // Initialize portlet container.
-            LOG.debug(" [4] Initializing portlet container...");
-            container.init(servletContext);
-
-            // Save portlet container to the servlet context scope.
-            servletContext.setAttribute(CONTAINER_KEY, container);
-            LOG.info("Pluto portlet container started.");
-
-        } catch (DriverConfigurationException ex) {
-            LOG.error("Unable to retrieve driver configuration "
-                    + "due to configuration error: " + ex.getMessage(), ex);
-        } catch (PortletContainerException ex) {
-            LOG.error("Unable to start up portlet container: "
-                    + ex.getMessage(), ex);
-        }
-    }
-
-    // Private Destruction Methods ---------------------------------------------
-
-    /**
-     * Destroyes the portlet container and removes it from servlet context.
-     *
-     * @param servletContext the servlet context.
-     */
-    private void destroyContainer(ServletContext servletContext) {
-        if (LOG.isInfoEnabled()) {
-            LOG.info("Shutting down Pluto Portal Driver...");
-        }
-        PortletContainer container = (PortletContainer)
-                servletContext.getAttribute(CONTAINER_KEY);
-        if (container != null) {
-            try {
-                container.destroy();
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Pluto Portal Driver shut down.");
-                }
-            } catch (PortletContainerException ex) {
-                LOG.error("Unable to shut down portlet container: "
-                        + ex.getMessage(), ex);
-            } finally {
-                servletContext.removeAttribute(CONTAINER_KEY);
-            }
-        }
-    }
-
-    /**
-     * Destroyes the portal driver config and removes it from servlet context.
-     *
-     * @param servletContext the servlet context.
-     */
-    private void destroyDriverConfiguration(ServletContext servletContext) {
-        DriverConfiguration driverConfig = (DriverConfiguration)
-                servletContext.getAttribute(DRIVER_CONFIG_KEY);
-        if (driverConfig != null) {
-            try {
-                driverConfig.destroy();
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Pluto Portal Driver Config destroyed.");
-                }
-            } catch (DriverConfigurationException ex) {
-                LOG.error("Unable to destroy portal driver config: "
-                        + ex.getMessage(), ex);
-            } finally {
-                servletContext.removeAttribute(DRIVER_CONFIG_KEY);
-            }
-        }
-    }
-
-    /**
-     * Destroyes the portal admin config and removes it from servlet context.
-     *
-     * @param servletContext the servlet context.
-     */
-    private void destroyAdminConfiguration(ServletContext servletContext) {
-        AdminConfiguration adminConfig = (AdminConfiguration)
-                servletContext.getAttribute(ADMIN_CONFIG_KEY);
-        if (adminConfig != null) {
-            try {
-                adminConfig.destroy();
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Pluto Portal Admin Config destroyed.");
-                }
-            } catch (DriverConfigurationException ex) {
-                LOG.error("Unable to destroy portal admin config: "
-                        + ex.getMessage(), ex);
-            } finally {
-                servletContext.removeAttribute(ADMIN_CONFIG_KEY);
-            }
-        }
-    }
-
-}
-
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.OptionalContainerServices;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.PortletContainerFactory;
+import org.apache.pluto.RequiredContainerServices;
+import org.apache.pluto.driver.config.AdminConfiguration;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.config.DriverConfigurationException;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Listener used to start up / shut down the Pluto Portal Driver upon startup /
+ * showdown of the servlet context in which it resides.
+ * <p/>
+ * Startup Includes:
+ * <ol>
+ * <li>Instantiation of the DriverConfiguration</li>
+ * <li>Registration of the DriverConfiguration</li>
+ * <li>Instantiation of the PortalContext</li>
+ * <li>Registration of the PortalContext</li>
+ * <li>Instantiation of the ContainerServices</li>
+ * <li>Registration of the ContainerServices</li>
+ * </ol>
+ *
+ * @version $Revision$ $Date$
+ * @since Sep 22, 2004
+ */
+public class PortalStartupListener implements ServletContextListener {
+
+    /**
+     * Internal logger.
+     */
+    private static final Log LOG = LogFactory.getLog(
+            PortalStartupListener.class);
+
+    /**
+     * The KEY with which the container is bound to the context.
+     */
+    private static final String CONTAINER_KEY = AttributeKeys.PORTLET_CONTAINER;
+
+    /**
+     * The KEY with which the driver configuration is bound to the context.
+     */
+    private static final String DRIVER_CONFIG_KEY = AttributeKeys.DRIVER_CONFIG;
+
+    /**
+     * The KEY with which the admin configuration is bound to the context.
+     */
+    private static final String ADMIN_CONFIG_KEY = AttributeKeys.DRIVER_ADMIN_CONFIG;
+
+    // ServletContextListener Impl ---------------------------------------------
+
+    /**
+     * Receives the startup notification and subsequently starts up the portal
+     * driver. The following are done in this order:
+     * <ol>
+     * <li>Retrieve the ResourceConfig File</li>
+     * <li>Parse the ResourceConfig File into ResourceConfig Objects</li>
+     * <li>Create a Portal Context</li>
+     * <li>Create the ContainerServices implementation</li>
+     * <li>Create the Portlet Container</li>
+     * <li>Initialize the Container</li>
+     * <li>Bind the configuration to the ServletContext</li>
+     * <li>Bind the container to the ServletContext</li>
+     * <ol>
+     *
+     * @param event the servlet context event.
+     */
+    public void contextInitialized(ServletContextEvent event) {
+        LOG.info("Starting up Pluto Portal Driver. . .");
+
+        ServletContext servletContext = event.getServletContext();
+
+        WebApplicationContext springContext = (WebApplicationContext)
+                servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
+
+        LOG.debug(" [1a] Loading DriverConfiguration. . . ");
+        DriverConfiguration driverConfiguration = (DriverConfiguration)
+                springContext.getBean("DriverConfiguration");
+
+        driverConfiguration.init(servletContext);
+
+        LOG.debug(" [1b] Registering DriverConfiguration. . .");
+        servletContext.setAttribute(DRIVER_CONFIG_KEY, driverConfiguration);
+
+
+        LOG.debug(" [2a] Loading Optional AdminConfiguration. . .");
+        AdminConfiguration adminConfiguration = (AdminConfiguration)
+                springContext.getBean("AdminConfiguration");
+
+        if (adminConfiguration != null) {
+            LOG.debug(" [2b] Registering Optional AdminConfiguration");
+            servletContext.setAttribute(ADMIN_CONFIG_KEY, adminConfiguration);
+        } else {
+            LOG.info("Optional AdminConfiguration not found. Ignoring.");
+        }
+
+        initContainer(servletContext);
+
+        LOG.info("********** Pluto Portal Driver Started **********\n\n");
+    }
+
+    /**
+     * Recieve notification that the context is being shut down and subsequently
+     * destroy the container.
+     *
+     * @param event the destrubtion event.
+     */
+    public void contextDestroyed(ServletContextEvent event) {
+        ServletContext servletContext = event.getServletContext();
+        if (LOG.isInfoEnabled()) {
+            LOG.info("Shutting down Pluto Portal Driver...");
+        }
+        destroyContainer(servletContext);
+        destroyAdminConfiguration(servletContext);
+        destroyDriverConfiguration(servletContext);
+        if (LOG.isInfoEnabled()) {
+            LOG.info("********** Pluto Portal Driver Shut Down **********\n\n");
+        }
+    }
+
+
+    /**
+     * Initializes the portlet container. This method constructs and initializes
+     * the portlet container, and saves it to the servlet context scope.
+     *
+     * @param servletContext the servlet context.
+     */
+    private void initContainer(ServletContext servletContext) {
+
+        WebApplicationContext springContext = (WebApplicationContext)
+                servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
+
+        // Retrieve the driver configuration from servlet context.
+        DriverConfiguration driverConfig = (DriverConfiguration)
+                servletContext.getAttribute(DRIVER_CONFIG_KEY);
+
+        try {
+            LOG.info("Initializing Portlet Container. . .");
+
+            LOG.debug(" [1] Loading RequiredContainerServices. . .");
+            RequiredContainerServices required =
+                    (RequiredContainerServices) springContext.getBean("RequiredContainerServices");
+
+            LOG.debug(" [2] Loading OptionalContainerServices. . .");
+            OptionalContainerServices optional =
+                    (OptionalContainerServices) springContext.getBean("OptionalContainerServices");
+
+
+            // Create portlet container.
+            LOG.debug(" [3] Creating portlet container...");
+            PortletContainerFactory factory =
+                    PortletContainerFactory.getInstance();
+            PortletContainer container = factory.createContainer(
+                driverConfig.getContainerName(), required, optional
+            );
+
+            // Initialize portlet container.
+            LOG.debug(" [4] Initializing portlet container...");
+            container.init(servletContext);
+
+            // Save portlet container to the servlet context scope.
+            servletContext.setAttribute(CONTAINER_KEY, container);
+            LOG.info("Pluto portlet container started.");
+
+        } catch (DriverConfigurationException ex) {
+            LOG.error("Unable to retrieve driver configuration "
+                    + "due to configuration error: " + ex.getMessage(), ex);
+        } catch (PortletContainerException ex) {
+            LOG.error("Unable to start up portlet container: "
+                    + ex.getMessage(), ex);
+        }
+    }
+
+    // Private Destruction Methods ---------------------------------------------
+
+    /**
+     * Destroyes the portlet container and removes it from servlet context.
+     *
+     * @param servletContext the servlet context.
+     */
+    private void destroyContainer(ServletContext servletContext) {
+        if (LOG.isInfoEnabled()) {
+            LOG.info("Shutting down Pluto Portal Driver...");
+        }
+        PortletContainer container = (PortletContainer)
+                servletContext.getAttribute(CONTAINER_KEY);
+        if (container != null) {
+            try {
+                container.destroy();
+                if (LOG.isInfoEnabled()) {
+                    LOG.info("Pluto Portal Driver shut down.");
+                }
+            } catch (PortletContainerException ex) {
+                LOG.error("Unable to shut down portlet container: "
+                        + ex.getMessage(), ex);
+            } finally {
+                servletContext.removeAttribute(CONTAINER_KEY);
+            }
+        }
+    }
+
+    /**
+     * Destroyes the portal driver config and removes it from servlet context.
+     *
+     * @param servletContext the servlet context.
+     */
+    private void destroyDriverConfiguration(ServletContext servletContext) {
+        DriverConfiguration driverConfig = (DriverConfiguration)
+                servletContext.getAttribute(DRIVER_CONFIG_KEY);
+        if (driverConfig != null) {
+            try {
+                driverConfig.destroy();
+                if (LOG.isInfoEnabled()) {
+                    LOG.info("Pluto Portal Driver Config destroyed.");
+                }
+            } catch (DriverConfigurationException ex) {
+                LOG.error("Unable to destroy portal driver config: "
+                        + ex.getMessage(), ex);
+            } finally {
+                servletContext.removeAttribute(DRIVER_CONFIG_KEY);
+            }
+        }
+    }
+
+    /**
+     * Destroyes the portal admin config and removes it from servlet context.
+     *
+     * @param servletContext the servlet context.
+     */
+    private void destroyAdminConfiguration(ServletContext servletContext) {
+        AdminConfiguration adminConfig = (AdminConfiguration)
+                servletContext.getAttribute(ADMIN_CONFIG_KEY);
+        if (adminConfig != null) {
+            try {
+                adminConfig.destroy();
+                if (LOG.isInfoEnabled()) {
+                    LOG.info("Pluto Portal Admin Config destroyed.");
+                }
+            } catch (DriverConfigurationException ex) {
+                LOG.error("Unable to destroy portal admin config: "
+                        + ex.getMessage(), ex);
+            } finally {
+                servletContext.removeAttribute(ADMIN_CONFIG_KEY);
+            }
+        }
+    }
+
+}
+

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PublishServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PublishServlet.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PublishServlet.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PublishServlet.java Sat Dec 29 09:20:23 2007
@@ -1,64 +1,64 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver;
-
-import org.apache.pluto.driver.services.portal.admin.DriverAdministrationException;
-import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
-import org.apache.pluto.driver.config.AdminConfiguration;
-
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
-import java.io.IOException;
-
-
-/**
- * Publishing administrative servlet.
- * Allows external clients to connect and notify the portal
- * of available portlet applications.
- *
- * @version 1.0
- * @since Nov 23, 2005
- */
-public class PublishServlet extends HttpServlet {
-
-    protected void doGet(HttpServletRequest req,
-                         HttpServletResponse res)
-    throws ServletException, IOException {
-
-        String context = req.getParameter("context");
-        try {
-            doPublish(context);
-        }
-        catch(Throwable t) {
-            StringBuffer sb = new StringBuffer();
-            sb.append("Unable to publish portlet application bound to context '"+context+"'.");
-            sb.append("Reason: ").append(t.getMessage());
-            res.getWriter().println(sb.toString());
-        }
-    }
-
-    private void doPublish(String context) throws DriverAdministrationException {
-        AdminConfiguration adminConfig = (AdminConfiguration)getServletContext()
-            .getAttribute(AttributeKeys.DRIVER_ADMIN_CONFIG);
-
-        PortletRegistryAdminService admin = adminConfig.getPortletRegistryAdminService();
-
-        admin.addPortletApplication(context);
-    }
-}
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver;
+
+import org.apache.pluto.driver.services.portal.admin.DriverAdministrationException;
+import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
+import org.apache.pluto.driver.config.AdminConfiguration;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+
+/**
+ * Publishing administrative servlet.
+ * Allows external clients to connect and notify the portal
+ * of available portlet applications.
+ *
+ * @version 1.0
+ * @since Nov 23, 2005
+ */
+public class PublishServlet extends HttpServlet {
+
+    protected void doGet(HttpServletRequest req,
+                         HttpServletResponse res)
+    throws ServletException, IOException {
+
+        String context = req.getParameter("context");
+        try {
+            doPublish(context);
+        }
+        catch(Throwable t) {
+            StringBuffer sb = new StringBuffer();
+            sb.append("Unable to publish portlet application bound to context '"+context+"'.");
+            sb.append("Reason: ").append(t.getMessage());
+            res.getWriter().println(sb.toString());
+        }
+    }
+
+    private void doPublish(String context) throws DriverAdministrationException {
+        AdminConfiguration adminConfig = (AdminConfiguration)getServletContext()
+            .getAttribute(AttributeKeys.DRIVER_ADMIN_CONFIG);
+
+        PortletRegistryAdminService admin = adminConfig.getPortletRegistryAdminService();
+
+        admin.addPortletApplication(context);
+    }
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PublishServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java Sat Dec 29 09:20:23 2007
@@ -1,145 +1,145 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver;
-
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.driver.services.portal.PageConfig;
-import org.apache.pluto.driver.config.AdminConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.text.DecimalFormat;
-
-/**
- * TCK Driver Servlet.
- *
- * @version 1.0
- * @since Dec 11, 2005
- */
-public class TCKDriverServlet extends PortalDriverServlet {
-
-	/** Logger. */
-    private static final Log LOG = LogFactory.getLog(TCKDriverServlet.class);
-
-    private int pageCounter = 0;
-
-    public String getServletInfo() {
-        return "Pluto TCK Driver Servlet";
-    }
-
-    public void init() {
-        super.init();
-        ServletContext servletContext = getServletContext();
-        container = (PortletContainer) servletContext.getAttribute(
-                AttributeKeys.PORTLET_CONTAINER);
-    }
-
-    /**
-     * Overwrites <code>super.doGet(..)</code>. If <code>portletName</code>
-     * (multiple occurrences) parameter is received, the driver is attempting
-     * to create a new page. This page must be setup and then redirected to the
-     * actual page. Otherwise, the driver calls <code>super.doGet(..)</code>
-     * to continue as normal.
-     * @param request  the incoming servlet request.
-     * @param response  the incoming servlet response.
-     * @throws IOException
-     * @throws ServletException
-     */
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-    throws IOException, ServletException {
-        String[] portletNames = request.getParameterValues("portletName");
-        if (portletNames != null && portletNames.length > 0) {
-        	debugWithName("Initializing new TCK page...");
-            doSetup(request, response);
-        } else {
-        	debugWithName("No portlet names specified. Continue as normal.");
-        	super.doGet(request, response);
-        }
-    }
-
-    public void doPost(HttpServletRequest req, HttpServletResponse response)
-    throws IOException, ServletException {
-        super.doGet(req, response);
-    }
-
-
-    // Private Methods ---------------------------------------------------------
-
-    private void doSetup(HttpServletRequest request,
-                         HttpServletResponse response)
-    throws IOException, ServletException {
-        String[] portletNames = request.getParameterValues("portletName");
-        String pageName = request.getParameter("pageName");
-        if (pageName != null) {
-        	debugWithName("Retrieved page name from request: " + pageName);
-        } else {
-        	debugWithName("Creating page name...");
-        	AdminConfiguration adminConfig = (AdminConfiguration)
-            		getServletContext()
-            		.getAttribute(AttributeKeys.DRIVER_ADMIN_CONFIG);
-            if (adminConfig == null) {
-                throw new ServletException("Invalid configuration: "
-                		+ "an AdminConfiguration must be specified "
-                		+ "to run the TCK.");
-            }
-
-            pageName = (new DecimalFormat("TCK00000")).format(pageCounter++);
-            PageConfig pageConfig = new PageConfig();
-            pageConfig.setName(pageName);
-            pageConfig.setUri(DEFAULT_PAGE_URI);
-            for (int i = 0; i < portletNames.length; i++) {
-            	debugWithName("Processing portlet name: " + portletNames[i]);
-                int index = portletNames[i].indexOf("/");
-                String contextPath = "/" + portletNames[i].substring(0, index);
-                String portletName = portletNames[i].substring(index + 1);
-                pageConfig.addPortlet(contextPath, portletName);
-                adminConfig.getPortletRegistryAdminService()
-                		.addPortletApplication(contextPath);
-            }
-
-            adminConfig.getRenderConfigAdminService().addPage(pageConfig);
-            debugWithName("Created TCK Page: " + pageName);
-        }
-
-        // The other possibility would be to redirect to the actual portal.
-        //   I'm not sure which is better at this point.
-        StringBuffer buffer = new StringBuffer();
-        buffer.append(request.getRequestURL().toString());
-        if (!request.getRequestURL().toString().endsWith("/")) {
-        	buffer.append("/");
-        }
-        buffer.append(pageName);
-        debugWithName("Sending redirect to: " + buffer.toString());
-        response.sendRedirect(buffer.toString());
-    }
-
-    /**
-     * Prints debug message with a <code>[Pluto TCK Driver]</code> prefix.
-     * @param message  message to debug.
-     */
-    private void debugWithName(String message) {
-    	if (LOG.isDebugEnabled()) {
-    		LOG.debug("[Pluto TCK Driver] " + message);
-    	}
-    }
-
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver;
+
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.config.AdminConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.text.DecimalFormat;
+
+/**
+ * TCK Driver Servlet.
+ *
+ * @version 1.0
+ * @since Dec 11, 2005
+ */
+public class TCKDriverServlet extends PortalDriverServlet {
+
+	/** Logger. */
+    private static final Log LOG = LogFactory.getLog(TCKDriverServlet.class);
+
+    private int pageCounter = 0;
+
+    public String getServletInfo() {
+        return "Pluto TCK Driver Servlet";
+    }
+
+    public void init() {
+        super.init();
+        ServletContext servletContext = getServletContext();
+        container = (PortletContainer) servletContext.getAttribute(
+                AttributeKeys.PORTLET_CONTAINER);
+    }
+
+    /**
+     * Overwrites <code>super.doGet(..)</code>. If <code>portletName</code>
+     * (multiple occurrences) parameter is received, the driver is attempting
+     * to create a new page. This page must be setup and then redirected to the
+     * actual page. Otherwise, the driver calls <code>super.doGet(..)</code>
+     * to continue as normal.
+     * @param request  the incoming servlet request.
+     * @param response  the incoming servlet response.
+     * @throws IOException
+     * @throws ServletException
+     */
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+    throws IOException, ServletException {
+        String[] portletNames = request.getParameterValues("portletName");
+        if (portletNames != null && portletNames.length > 0) {
+        	debugWithName("Initializing new TCK page...");
+            doSetup(request, response);
+        } else {
+        	debugWithName("No portlet names specified. Continue as normal.");
+        	super.doGet(request, response);
+        }
+    }
+
+    public void doPost(HttpServletRequest req, HttpServletResponse response)
+    throws IOException, ServletException {
+        super.doGet(req, response);
+    }
+
+
+    // Private Methods ---------------------------------------------------------
+
+    private void doSetup(HttpServletRequest request,
+                         HttpServletResponse response)
+    throws IOException, ServletException {
+        String[] portletNames = request.getParameterValues("portletName");
+        String pageName = request.getParameter("pageName");
+        if (pageName != null) {
+        	debugWithName("Retrieved page name from request: " + pageName);
+        } else {
+        	debugWithName("Creating page name...");
+        	AdminConfiguration adminConfig = (AdminConfiguration)
+            		getServletContext()
+            		.getAttribute(AttributeKeys.DRIVER_ADMIN_CONFIG);
+            if (adminConfig == null) {
+                throw new ServletException("Invalid configuration: "
+                		+ "an AdminConfiguration must be specified "
+                		+ "to run the TCK.");
+            }
+
+            pageName = (new DecimalFormat("TCK00000")).format(pageCounter++);
+            PageConfig pageConfig = new PageConfig();
+            pageConfig.setName(pageName);
+            pageConfig.setUri(DEFAULT_PAGE_URI);
+            for (int i = 0; i < portletNames.length; i++) {
+            	debugWithName("Processing portlet name: " + portletNames[i]);
+                int index = portletNames[i].indexOf("/");
+                String contextPath = "/" + portletNames[i].substring(0, index);
+                String portletName = portletNames[i].substring(index + 1);
+                pageConfig.addPortlet(contextPath, portletName);
+                adminConfig.getPortletRegistryAdminService()
+                		.addPortletApplication(contextPath);
+            }
+
+            adminConfig.getRenderConfigAdminService().addPage(pageConfig);
+            debugWithName("Created TCK Page: " + pageName);
+        }
+
+        // The other possibility would be to redirect to the actual portal.
+        //   I'm not sure which is better at this point.
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(request.getRequestURL().toString());
+        if (!request.getRequestURL().toString().endsWith("/")) {
+        	buffer.append("/");
+        }
+        buffer.append(pageName);
+        debugWithName("Sending redirect to: " + buffer.toString());
+        response.sendRedirect(buffer.toString());
+    }
+
+    /**
+     * Prints debug message with a <code>[Pluto TCK Driver]</code> prefix.
+     * @param message  message to debug.
+     */
+    private void debugWithName(String message) {
+    	if (LOG.isDebugEnabled()) {
+    		LOG.debug("[Pluto TCK Driver] " + message);
+    	}
+    }
+
 }

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/TCKDriverServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/AdminConfiguration.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/AdminConfiguration.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/AdminConfiguration.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/AdminConfiguration.java Sat Dec 29 09:20:23 2007
@@ -1,64 +1,64 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver.config;
-
-import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
-import org.apache.pluto.driver.services.portal.admin.RenderConfigAdminService;
-
-import javax.servlet.ServletContext;
-
-/**
- * Interface defining a means for obtaining administrative
- * services for portal configuration.  An implementation
- * of this interface will be bound to the portal's
- * ServletContext IF administrative functions are
- * supported by the current implementation.
- *
- * @version 1.0
- * @since Nov 30, 2005
- */
-public interface AdminConfiguration {
-
-    /**
-     * Lifecyle method used to initialize the configuration
-     * @param context
-     */
-    void init(ServletContext context) throws DriverConfigurationException;
-
-    /**
-     * Lifecylce method used to remove the configuration
-     * from service.
-     */
-    void destroy() throws DriverConfigurationException;
-
-    /**
-     * Retrieve the administrative service for managing the
-     * portlet registry.
-     *
-     * @return the service if one has been provided
-     */
-    PortletRegistryAdminService getPortletRegistryAdminService();
-
-    /**
-     * Retrieve the administrative service for managing the
-     * render configuration.
-     * @return the service if one has been provided
-     */
-    RenderConfigAdminService getRenderConfigAdminService();
-
-
-}
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver.config;
+
+import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
+import org.apache.pluto.driver.services.portal.admin.RenderConfigAdminService;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Interface defining a means for obtaining administrative
+ * services for portal configuration.  An implementation
+ * of this interface will be bound to the portal's
+ * ServletContext IF administrative functions are
+ * supported by the current implementation.
+ *
+ * @version 1.0
+ * @since Nov 30, 2005
+ */
+public interface AdminConfiguration {
+
+    /**
+     * Lifecyle method used to initialize the configuration
+     * @param context
+     */
+    void init(ServletContext context) throws DriverConfigurationException;
+
+    /**
+     * Lifecylce method used to remove the configuration
+     * from service.
+     */
+    void destroy() throws DriverConfigurationException;
+
+    /**
+     * Retrieve the administrative service for managing the
+     * portlet registry.
+     *
+     * @return the service if one has been provided
+     */
+    PortletRegistryAdminService getPortletRegistryAdminService();
+
+    /**
+     * Retrieve the administrative service for managing the
+     * render configuration.
+     * @return the service if one has been provided
+     */
+    RenderConfigAdminService getRenderConfigAdminService();
+
+
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/AdminConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java Sat Dec 29 09:20:23 2007
@@ -1,117 +1,117 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver.config;
-
-import java.util.Collection;
-
-import javax.servlet.ServletContext;
-
-import org.apache.pluto.driver.services.portal.PageConfig;
-import org.apache.pluto.driver.services.portal.RenderConfigService;
-import org.apache.pluto.driver.url.PortalURLParser;
-import org.apache.pluto.spi.PortalCallbackService;
-import org.apache.pluto.spi.optional.PortletPreferencesService;
-
-/**
- * Interface defining a means for retrieving driver services
- * based upon configuration information. Within the portal,
- * an implementation of this interface should be bound to
- * the portal's ServletContext.
- *
- *
- * @since Sep 2, 2005
- *
- */
-public interface DriverConfiguration {
-
-//
-// Lifecycle Methods
-//
-
-    /**
-     * Initialization method used to place the driver
-     * configuration into service.
-     * @throws DriverConfigurationException when an error occurs during startup.
-     * @param context
-     */
-    void init(ServletContext context) throws DriverConfigurationException;
-
-    /**
-     * Shutdown method used to remove the driver
-     * configuration from service;
-     * @throws DriverConfigurationException when an error occurs during shutdown.
-     */
-    void destroy() throws DriverConfigurationException;
-
-//
-// Service / Configuration Methods
-//
-
-    /**
-     * Retrieve the name of the portal
-     * as should be returned in
-     * {@link javax.portlet.PortalContext#getPortalInfo()}
-     * @return the name of the portal.
-     */
-    String getPortalName();
-
-    /**
-     * Retrieve the version of the portal
-     * as should be returned in
-     * {@link javax.portlet.PortalContext#getPortalInfo()}
-     * @return the portal version.
-     */
-    String getPortalVersion();
-
-    /**
-     * Retrieves the name of the container which
-     * pluto should create and embed.
-     * @return the container name.
-     */
-    String getContainerName();
-
-    Collection getSupportedPortletModes();
-
-    Collection getSupportedWindowStates();
-
-    Collection getPages();
-
-    PageConfig getPageConfig(String pageId);
-
-    boolean isPortletModeSupportedByPortal(String mode);
-
-    boolean isPortletModeSupportedByPortlet(String portletId, String mode);
-
-    boolean isPortletModeSupported(String portletId, String mode);
-
-    boolean isWindowStateSupportedByPortal(String windowState);
-
-    boolean isWindowStateSupportedByPortlet(String portletId, String windowState);
-
-    boolean isWindowStateSupported(String portletId, String windowState);
-
-//
-// Utility methods for the container
-//
-    PortalCallbackService getPortalCallbackService();
-
-    PortletPreferencesService getPortletPreferencesService();
-
-    PortalURLParser getPortalUrlParser();
-    
-    public RenderConfigService getRenderConfigService();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver.config;
+
+import java.util.Collection;
+
+import javax.servlet.ServletContext;
+
+import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.services.portal.RenderConfigService;
+import org.apache.pluto.driver.url.PortalURLParser;
+import org.apache.pluto.spi.PortalCallbackService;
+import org.apache.pluto.spi.optional.PortletPreferencesService;
+
+/**
+ * Interface defining a means for retrieving driver services
+ * based upon configuration information. Within the portal,
+ * an implementation of this interface should be bound to
+ * the portal's ServletContext.
+ *
+ *
+ * @since Sep 2, 2005
+ *
+ */
+public interface DriverConfiguration {
+
+//
+// Lifecycle Methods
+//
+
+    /**
+     * Initialization method used to place the driver
+     * configuration into service.
+     * @throws DriverConfigurationException when an error occurs during startup.
+     * @param context
+     */
+    void init(ServletContext context) throws DriverConfigurationException;
+
+    /**
+     * Shutdown method used to remove the driver
+     * configuration from service;
+     * @throws DriverConfigurationException when an error occurs during shutdown.
+     */
+    void destroy() throws DriverConfigurationException;
+
+//
+// Service / Configuration Methods
+//
+
+    /**
+     * Retrieve the name of the portal
+     * as should be returned in
+     * {@link javax.portlet.PortalContext#getPortalInfo()}
+     * @return the name of the portal.
+     */
+    String getPortalName();
+
+    /**
+     * Retrieve the version of the portal
+     * as should be returned in
+     * {@link javax.portlet.PortalContext#getPortalInfo()}
+     * @return the portal version.
+     */
+    String getPortalVersion();
+
+    /**
+     * Retrieves the name of the container which
+     * pluto should create and embed.
+     * @return the container name.
+     */
+    String getContainerName();
+
+    Collection getSupportedPortletModes();
+
+    Collection getSupportedWindowStates();
+
+    Collection getPages();
+
+    PageConfig getPageConfig(String pageId);
+
+    boolean isPortletModeSupportedByPortal(String mode);
+
+    boolean isPortletModeSupportedByPortlet(String portletId, String mode);
+
+    boolean isPortletModeSupported(String portletId, String mode);
+
+    boolean isWindowStateSupportedByPortal(String windowState);
+
+    boolean isWindowStateSupportedByPortlet(String portletId, String windowState);
+
+    boolean isWindowStateSupported(String portletId, String windowState);
+
+//
+// Utility methods for the container
+//
+    PortalCallbackService getPortalCallbackService();
+
+    PortletPreferencesService getPortletPreferencesService();
+
+    PortalURLParser getPortalUrlParser();
+    
+    public RenderConfigService getRenderConfigService();
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java Sat Dec 29 09:20:23 2007
@@ -1,39 +1,39 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver.config;
-
-/**
- * @todo Document
- * @since Aug 10, 2005
- */
-public class DriverConfigurationException extends RuntimeException {
-
-    public DriverConfigurationException() {
-    }
-
-    public DriverConfigurationException(String message) {
-        super(message);
-    }
-
-    public DriverConfigurationException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public DriverConfigurationException(Throwable cause) {
-        super(cause);
-    }
-}
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver.config;
+
+/**
+ * @todo Document
+ * @since Aug 10, 2005
+ */
+public class DriverConfigurationException extends RuntimeException {
+
+    public DriverConfigurationException() {
+    }
+
+    public DriverConfigurationException(String message) {
+        super(message);
+    }
+
+    public DriverConfigurationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public DriverConfigurationException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html Sat Dec 29 09:20:23 2007
@@ -1,24 +1,24 @@
-<!--
+<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed  under the  License is distributed on an "AS IS" BASIS,
-WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
-implied.
-
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<html>
-<body>
-  Provides a single interface for retrieving configuration
-  and instantiating services.
-</body>
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed  under the  License is distributed on an "AS IS" BASIS,
+WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<html>
+<body>
+  Provides a single interface for retrieving configuration
+  and instantiating services.
+</body>
 </html>

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java Sat Dec 29 09:20:23 2007
@@ -1,121 +1,121 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pluto.driver.core;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
-
-import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.url.PortalURLParser;
-import org.apache.pluto.driver.AttributeKeys;
-import org.apache.pluto.driver.config.DriverConfiguration;
-
-/**
- * Defines the context of the currentl portal request.
- * Allows for the retrieval of the original request
- * and response throughout the lifetime of the request.
- *
- * Provides a consistent interface for parsing/creating
- * PortalURLs to the outside world.
- *
- */
-public class PortalRequestContext {
-
-    /**
-     * The attribute key to bind the portal environment instance to servlet
-     * request.
-     */
-    public final static String REQUEST_KEY =
-            PortalRequestContext.class.getName();
-
-    /** The servletContext of execution. **/
-    private ServletContext servletContext;
-
-    /** The incoming servlet request. */
-    private HttpServletRequest request;
-
-    /** The incoming servlet response. */
-    private HttpServletResponse response;
-
-    /** The requested portal URL. */
-    private PortalURL requestedPortalURL;
-
-
-    // Constructor -------------------------------------------------------------
-
-    /**
-     * Creates a PortalRequestContext instance.
-     * @param request  the incoming servlet request.
-     * @param response  the incoming servlet response.
-     */
-    public PortalRequestContext(ServletContext servletContext,
-                                HttpServletRequest request,
-                                HttpServletResponse response) {
-        this.servletContext = servletContext;
-        this.request = request;
-        this.response = response;
-
-        // Bind the instance to servlet request for later use.
-        request.setAttribute(REQUEST_KEY, this);
-    }
-
-    /**
-     * Returns the portal environment from the servlet request. The portal
-     * envirionment instance is saved in the request scope.
-     * @param request  the servlet request.
-     * @return the portal environment.
-     */
-    public static PortalRequestContext getContext(
-            HttpServletRequest request) {
-        return (PortalRequestContext) request.getAttribute(REQUEST_KEY);
-    }
-
-    /**
-     * Returns the servlet request.
-     * @return the servlet request.
-     */
-    public HttpServletRequest getRequest() {
-        return request;
-    }
-
-    /**
-     * Returns the servlet response.
-     * @return the servlet response.
-     */
-    public HttpServletResponse getResponse() {
-        return response;
-    }
-
-    /**
-     * Returns the requested portal URL.
-     * @return the requested portal URL.
-     */
-    public PortalURL getRequestedPortalURL() {
-        if(requestedPortalURL == null) {
-            DriverConfiguration config = (DriverConfiguration)
-                servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
-            PortalURLParser parser = config.getPortalUrlParser();
-            requestedPortalURL = parser.parse(request);
-        }
-        return requestedPortalURL;
-    }
-
-    public PortalURL createPortalURL() {
-        return (PortalURL)getRequestedPortalURL().clone();
-    }
-}
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.driver.core;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
+import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURLParser;
+import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.driver.config.DriverConfiguration;
+
+/**
+ * Defines the context of the currentl portal request.
+ * Allows for the retrieval of the original request
+ * and response throughout the lifetime of the request.
+ *
+ * Provides a consistent interface for parsing/creating
+ * PortalURLs to the outside world.
+ *
+ */
+public class PortalRequestContext {
+
+    /**
+     * The attribute key to bind the portal environment instance to servlet
+     * request.
+     */
+    public final static String REQUEST_KEY =
+            PortalRequestContext.class.getName();
+
+    /** The servletContext of execution. **/
+    private ServletContext servletContext;
+
+    /** The incoming servlet request. */
+    private HttpServletRequest request;
+
+    /** The incoming servlet response. */
+    private HttpServletResponse response;
+
+    /** The requested portal URL. */
+    private PortalURL requestedPortalURL;
+
+
+    // Constructor -------------------------------------------------------------
+
+    /**
+     * Creates a PortalRequestContext instance.
+     * @param request  the incoming servlet request.
+     * @param response  the incoming servlet response.
+     */
+    public PortalRequestContext(ServletContext servletContext,
+                                HttpServletRequest request,
+                                HttpServletResponse response) {
+        this.servletContext = servletContext;
+        this.request = request;
+        this.response = response;
+
+        // Bind the instance to servlet request for later use.
+        request.setAttribute(REQUEST_KEY, this);
+    }
+
+    /**
+     * Returns the portal environment from the servlet request. The portal
+     * envirionment instance is saved in the request scope.
+     * @param request  the servlet request.
+     * @return the portal environment.
+     */
+    public static PortalRequestContext getContext(
+            HttpServletRequest request) {
+        return (PortalRequestContext) request.getAttribute(REQUEST_KEY);
+    }
+
+    /**
+     * Returns the servlet request.
+     * @return the servlet request.
+     */
+    public HttpServletRequest getRequest() {
+        return request;
+    }
+
+    /**
+     * Returns the servlet response.
+     * @return the servlet response.
+     */
+    public HttpServletResponse getResponse() {
+        return response;
+    }
+
+    /**
+     * Returns the requested portal URL.
+     * @return the requested portal URL.
+     */
+    public PortalURL getRequestedPortalURL() {
+        if(requestedPortalURL == null) {
+            DriverConfiguration config = (DriverConfiguration)
+                servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
+            PortalURLParser parser = config.getPortalUrlParser();
+            requestedPortalURL = parser.parse(request);
+        }
+        return requestedPortalURL;
+    }
+
+    public PortalURL createPortalURL() {
+        return (PortalURL)getRequestedPortalURL().clone();
+    }
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message