You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by at...@apache.org on 2009/03/18 03:23:04 UTC

svn commit: r755458 - in /portals/pluto/trunk: pluto-container-api/src/main/java/org/apache/pluto/container/ pluto-container/src/main/java/org/apache/pluto/container/driver/impl/ pluto-container/src/main/java/org/apache/pluto/container/impl/

Author: ate
Date: Wed Mar 18 02:23:03 2009
New Revision: 755458

URL: http://svn.apache.org/viewvc?rev=755458&view=rev
Log:
PLUTO-537:
- extracting mostly generic base implementation of Portal Driver PortletContextImpl and PortletConfigImpl and provide them as default/base container implementations
- extending these new base classes for the Portal Driver as new DriverPortletContextImpl and DriverPortletConfigImpl 

Added:
    portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java   (with props)
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletConfigImpl.java   (contents, props changed)
      - copied, changed from r753593, portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletConfigImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletContextImpl.java   (contents, props changed)
      - copied, changed from r753593, portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java   (with props)
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java   (with props)
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java   (with props)
Removed:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletConfigImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextImpl.java
Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextManager.java

Added: portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java?rev=755458&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java (added)
+++ portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java Wed Mar 18 02:23:03 2009
@@ -0,0 +1,31 @@
+/*
+ * 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.container;
+
+/**
+ * @version $Id$
+ *
+ */
+public interface ContainerInfo
+{
+    String getServerInfo();
+    String getPortletContainerName();
+    String getPortletContainerVersion();
+    int getMajorSpecificationVersion();
+    int getMinorSpecificationVersion();
+}

Propchange: portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/container/ContainerInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletConfigImpl.java (from r753593, portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletConfigImpl.java)
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletConfigImpl.java?p2=portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletConfigImpl.java&p1=portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletConfigImpl.java&r1=753593&r2=755458&rev=755458&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletConfigImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletConfigImpl.java Wed Mar 18 02:23:03 2009
@@ -16,77 +16,26 @@
  */
 package org.apache.pluto.container.driver.impl;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 import java.util.ResourceBundle;
-import java.util.Set;
 
-import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.container.driver.DriverPortletConfig;
-import org.apache.pluto.container.driver.DriverPortletContext;
-import org.apache.pluto.container.om.portlet.ContainerRuntimeOption;
-import org.apache.pluto.container.om.portlet.EventDefinitionReference;
-import org.apache.pluto.container.om.portlet.InitParam;
-import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.impl.AbstractPortletConfigImpl;
 import org.apache.pluto.container.om.portlet.PortletDefinition;
 
-public class PortletConfigImpl implements PortletConfig, DriverPortletConfig {
+public class DriverPortletConfigImpl extends AbstractPortletConfigImpl implements DriverPortletConfig {
 
-    private static final Log LOG = LogFactory.getLog(PortletConfigImpl.class);
-
-    /**
-     * The Portlet Application Context within which we exist.
-     */
-    protected DriverPortletContext portletContext;
-
-    /**
-     * The portlet descriptor.
-     */
-    protected PortletDefinition portlet;
-    
-    /**
-     * The portlet application descriptor.
-     */
-    protected PortletApplicationDefinition portletApp;
+    private static final Log LOG = LogFactory.getLog(DriverPortletConfigImpl.class);
 
     protected ResourceBundleFactory bundles;
     
-    protected Map<String, String[]> containerRuntimeOptions;
-    
-    protected Set<String> supportedContainerRuntimeOptions; 
-
-    public PortletConfigImpl(DriverPortletContext portletContext,
-                             PortletDefinition portletDD,
-                             PortletApplicationDefinition portletAppDD) {
-        this.portletContext = portletContext;
-        this.portlet = portletDD;
-        this.portletApp = portletAppDD;
-        this.supportedContainerRuntimeOptions = new HashSet<String>();
-        for (Enumeration<String> e = portletContext.getContainerRuntimeOptions(); e.hasMoreElements(); )
-        {
-            supportedContainerRuntimeOptions.add(e.nextElement());
-        }
-    }
-
-    public String getPortletName() {
-        return portlet.getPortletName();
-    }
-
-    public PortletContext getPortletContext() {
-        return portletContext;
+    public DriverPortletConfigImpl(PortletContext portletContext,
+                             PortletDefinition portletDD) {
+        super(portletContext, portletDD);
     }
 
     public ResourceBundle getResourceBundle(Locale locale) {
@@ -98,164 +47,4 @@
         }
         return bundles.getResourceBundle(locale);
     }
-
-    public String getInitParameter(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Parameter name == null");
-        }
-
-        Iterator<? extends InitParam> parms = portlet.getInitParams().iterator();
-        while(parms.hasNext()) {
-            InitParam param = parms.next();
-            if (param.getParamName().equals(name)) {
-                return param.getParamValue();
-            }
-        }
-        return null;
-    }
-
-    public Enumeration<String> getInitParameterNames() {
-        return new java.util.Enumeration<String>() {
-            private Iterator<InitParam> iterator =
-                new ArrayList<InitParam>(portlet.getInitParams()).iterator();
-
-            public boolean hasMoreElements() {
-                return iterator.hasNext();
-            }
-
-            public String nextElement() {
-                if (iterator.hasNext()) {
-                    return iterator.next().getParamName();
-                } 
-                return null;
-            }
-        };
-    }
-
-    public PortletDefinition getPortletDefinition() {
-        return portlet;
-    }
-    // --------------------------------------------------------------------------------------------
-
-	public Enumeration<String> getPublicRenderParameterNames() {
-		if (portlet.getSupportedPublicRenderParameters() != null){
-			return Collections.enumeration(portlet.getSupportedPublicRenderParameters());
-		}
-		return  Collections.enumeration(new ArrayList<String>());
-	}
-
-	public String getDefaultNamespace() {
-		if (portletApp.getDefaultNamespace() == null)
-			return XMLConstants.NULL_NS_URI;
-		return portletApp.getDefaultNamespace();
-	}
-
-	public Enumeration<QName> getProcessingEventQNames() {
-	    ArrayList<QName> qnameList = new ArrayList<QName>();
-        for (EventDefinitionReference ref : portlet.getSupportedProcessingEvents())
-        {
-            QName name = ref.getQualifiedName(portletApp.getDefaultNamespace());
-            if (name == null)
-            {
-                continue;
-            }
-            else
-            {
-                qnameList.add(name);
-            }
-        }
-        return Collections.enumeration(qnameList);
-	}
-
-	public Enumeration<QName> getPublishingEventQNames() {
-        ArrayList<QName> qnameList = new ArrayList<QName>();
-        for (EventDefinitionReference ref : portlet.getSupportedPublishingEvents())
-        {
-            QName name = ref.getQualifiedName(portletApp.getDefaultNamespace());
-            if (name == null)
-            {
-                continue;
-            }
-            else
-            {
-                qnameList.add(name);
-            }
-        }
-        return Collections.enumeration(qnameList);
-	}
-
-	public Enumeration<Locale> getSupportedLocales() {
-		// for each String entry in SupportedLocales (portletDD)
-		// add an entry in the resut list (new Locale(string))
-		List<Locale> locals = new ArrayList<Locale>();
-		List<String> localsAsStrings = portlet.getSupportedLocales();
-		if (localsAsStrings!=null){
-			for (String string : localsAsStrings) {
-				locals.add(new Locale(string));
-			}
-		}
-		return Collections.enumeration(locals);
-	}
-	
-	public Map<String, String[]> getContainerRuntimeOptions()
-	{
-	    synchronized(this)
-	    {
-	        if (containerRuntimeOptions == null)
-	        {
-	            containerRuntimeOptions = new HashMap<String, String[]>();
-	            if (portletApp.getContainerRuntimeOptions() != null)
-	            {
-	                for (ContainerRuntimeOption option : portletApp.getContainerRuntimeOptions())
-	                {
-	                    List<String> values = option.getValues();
-	                    String [] tempValues = new String[values.size()];
-	                    for (int i=0;i<values.size();i++)
-	                    {
-	                        tempValues[i] = values.get(i);
-	                    }
-	                    containerRuntimeOptions.put(option.getName(),tempValues);
-	                }
-	            }
-	            if (portlet.getContainerRuntimeOptions() != null)
-	            {
-	                for (ContainerRuntimeOption option : portlet.getContainerRuntimeOptions())
-	                {
-	                    List<String> values = option.getValues();
-	                    String [] tempValues = new String[values.size()];
-	                    for (int i=0;i<values.size();i++)
-	                    {
-	                        tempValues[i] = values.get(i);
-	                    }
-	                    containerRuntimeOptions.put(option.getName(),tempValues);
-	                }
-	            }
-	            for (Iterator<String> iter = containerRuntimeOptions.keySet().iterator(); iter.hasNext(); )
-	            {
-	                String key = iter.next();
-	                if (!supportedContainerRuntimeOptions.contains(key))
-	                {
-	                    iter.remove();
-	                }
-	            }
-	        }
-	    }
-	    
-        if (!containerRuntimeOptions.isEmpty())
-        {
-            Map<String, String[]> result = new HashMap<String, String[]>(containerRuntimeOptions.size());
-            for (Map.Entry<String,String[]> entry : containerRuntimeOptions.entrySet())
-            {
-                if (entry.getValue() != null)
-                {
-                    result.put(entry.getKey(), entry.getValue().clone());
-                }
-            }
-            return Collections.unmodifiableMap(result);
-        }
-        else
-        {
-            return Collections.emptyMap();
-        }
-	}
 }

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletConfigImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletContextImpl.java (from r753593, portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextImpl.java)
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletContextImpl.java?p2=portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletContextImpl.java&p1=portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextImpl.java&r1=753593&r2=755458&rev=755458&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletContextImpl.java Wed Mar 18 02:23:03 2009
@@ -16,24 +16,10 @@
  */
 package org.apache.pluto.container.driver.impl;
 
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Set;
-
-import javax.portlet.PortletContext;
-import javax.portlet.PortletRequestDispatcher;
-import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletContext;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.container.RequestDispatcherPathInfoProvider;
 import org.apache.pluto.container.driver.DriverPortletContext;
-import org.apache.pluto.container.impl.PortletRequestDispatcherImpl;
-import org.apache.pluto.container.impl.RequestDispatcherPathInfoProviderImpl;
+import org.apache.pluto.container.impl.PortletContextImpl;
 import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
 
 /**
@@ -43,19 +29,10 @@
  * 
  * @version 1.1
  */
-public class PortletContextImpl
-implements PortletContext, DriverPortletContext {
+public class DriverPortletContextImpl extends PortletContextImpl implements DriverPortletContext {
 	
-	/**
-	 *  Logger.
-	 */
-    private static final Log LOG = LogFactory.getLog(PortletContextImpl.class);
-    
-    
     // Private Member Variables ------------------------------------------------
     
-    protected final PortletApplicationDefinition portletApp;
-    protected final ServletContext servletContext;
     protected ClassLoader contextClassLoader;
 
     // Constructor -------------------------------------------------------------
@@ -65,10 +42,10 @@
      * @param servletContext  the servlet context in which we are contained.
      * @param portletAppDD  the portlet application descriptor.
      */
-    public PortletContextImpl(ServletContext servletContext,
-                              PortletApplicationDefinition portletApp) {
-        this.servletContext = servletContext;
-        this.portletApp = portletApp;
+    public DriverPortletContextImpl(ServletContext servletContext,
+                              PortletApplicationDefinition portletApp)
+    {
+        super(servletContext, portletApp, PlutoContainerInfo.getInfo(), Configuration.getSupportedContainerRuntimeOptions());
         init();
     }
     
@@ -95,179 +72,5 @@
     public void setContextClassLoader(ClassLoader contextClassLoader) {
         this.contextClassLoader = contextClassLoader;
     }
-
-    public String getContextPath() {
-        return portletApp.getContextPath();
-    }
-    
-    // PortletContext Impl -----------------------------------------------------
-    
-    /**
-     * Retrieve the PortletContainer's server info.
-     * @return the server info in the form of <i>Server/Version</i>
-     * @see Environment#getServerInfo()
-     */
-    public String getServerInfo() {
-        return Configuration.getServerInfo();
-    }
-    
-    public PortletRequestDispatcher getRequestDispatcher(String path)
-    {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("PortletRequestDispatcher requested: " + path);
-        }
-        
-        // Check if the path name is valid. A valid path name must not be null
-        //   and must start with a slash '/' as defined by the portlet spec.
-        if (path == null || !path.startsWith("/")) {
-        	if (LOG.isInfoEnabled()) {
-        		LOG.info("Failed to retrieve PortletRequestDispatcher: "
-        				+ "path name must begin with a slash '/'.");
-        	}
-        	return null;
-        }
-        
-        // Construct PortletRequestDispatcher.
-        PortletRequestDispatcher portletRequestDispatcher = null;
-        try {
-            RequestDispatcher servletRequestDispatcher = servletContext.getRequestDispatcher(path);
-            if (servletRequestDispatcher != null) {
-
-                RequestDispatcherPathInfoProvider provider = RequestDispatcherPathInfoProviderImpl.getProvider(this, portletApp);
-            	portletRequestDispatcher = new PortletRequestDispatcherImpl(servletRequestDispatcher, provider.getPathInfo(getContextPath(), path));
-            } else {
-            	if (LOG.isInfoEnabled()) {
-            		LOG.info("No matching request dispatcher found for: " + path);
-            	}
-            }
-        } catch (Exception ex) {
-            // We need to catch exception because of a Tomcat 4.x bug.
-            //   Tomcat throws an exception instead of return null if the path
-        	//   was not found.
-        	if (LOG.isInfoEnabled()) {
-        		LOG.info("Failed to retrieve PortletRequestDispatcher: "
-        				+ ex.getMessage());
-        	}
-        	portletRequestDispatcher = null;
-        }
-        return portletRequestDispatcher;
-    }
-    
-    public PortletRequestDispatcher getNamedDispatcher(String name) {
-        RequestDispatcher dispatcher = servletContext.getNamedDispatcher(name);
-        if (dispatcher != null)
-        {
-            RequestDispatcherPathInfoProvider provider = RequestDispatcherPathInfoProviderImpl.getProvider(this, portletApp);
-            return new PortletRequestDispatcherImpl(dispatcher, provider.getNamedRequestDispatcherPathInfo());
-        } else {
-        	if (LOG.isInfoEnabled()) {
-        		LOG.info("No matching request dispatcher found for name: "
-        				+ name);
-        	}
-        }
-        return null;
-    }
-
-    public InputStream getResourceAsStream(String path) {
-        return servletContext.getResourceAsStream(path);
-    }
-
-    public int getMajorVersion() {
-        return Configuration.getMajorSpecificationVersion();
-    }
-
-    public int getMinorVersion() {
-        return Configuration.getMinorSpecificationVersion();
-    }
-
-    public String getMimeType(String file) {
-        return servletContext.getMimeType(file);
-    }
-
-    public String getRealPath(String path) {
-        return servletContext.getRealPath(path);
-    }
-
-    @SuppressWarnings("unchecked")
-    public Set<String> getResourcePaths(String path) {
-        return servletContext.getResourcePaths(path);
-    }
-
-    public URL getResource(String path)
-        throws java.net.MalformedURLException {
-        if (path == null || !path.startsWith("/")) {
-            throw new MalformedURLException("path must start with a '/'");
-        }
-        return servletContext.getResource(path);
-    }
-
-    public Object getAttribute(java.lang.String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Attribute name == null");
-        }
-
-        return servletContext.getAttribute(name);
-    }
-
-    @SuppressWarnings("unchecked")
-    public Enumeration<String> getAttributeNames() {
-        return servletContext.getAttributeNames();
-    }
-
-    public String getInitParameter(java.lang.String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Parameter name == null");
-        }
-
-        return servletContext.getInitParameter(name);
-    }
-
-    @SuppressWarnings("unchecked")
-    public Enumeration<String> getInitParameterNames() {
-        return servletContext.getInitParameterNames();
-    }
-
-    public void log(java.lang.String msg) {
-        servletContext.log(msg);
-    }
-
-    public void log(java.lang.String message, Throwable throwable) {
-        servletContext.log(message, throwable);
-    }
-
-    public void removeAttribute(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Attribute name == null");
-        }
-
-        servletContext.removeAttribute(name);
-    }
-
-    public void setAttribute(String name, Object object) {
-        if (name == null) {
-            throw new IllegalArgumentException("Attribute name == null");
-        }
-
-        servletContext.setAttribute(name, object);
-    }
-
-    public String getPortletContextName() {
-        return servletContext.getServletContextName();
-    }
-    
-    
-    // org.apache.pluto.core.InternalPortletContext Impl -----------------------
-    
-    public ServletContext getServletContext() {
-        return servletContext;
-    }
-
-    public PortletApplicationDefinition getPortletApplicationDefinition() {
-        return portletApp;
-    }
-
-	public Enumeration<String> getContainerRuntimeOptions() {
-	    return Collections.enumeration(Configuration.getSupportedContainerRuntimeOptions());
-	}
 }
 

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/DriverPortletContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java?rev=755458&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java Wed Mar 18 02:23:03 2009
@@ -0,0 +1,81 @@
+/*
+ * 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.container.driver.impl;
+
+import org.apache.pluto.container.ContainerInfo;
+
+/**
+ * @version $Id$
+ *
+ */
+public final class PlutoContainerInfo implements ContainerInfo
+{
+    private static final ContainerInfo instance = new PlutoContainerInfo();
+    
+    private PlutoContainerInfo()
+    {
+    }
+    
+    public static ContainerInfo getInfo()
+    {
+        return instance;
+    }
+    /**
+     * Retrieve the name of the container.
+     * @return the container name.
+     */
+    public String getPortletContainerName() {
+        return Configuration.getPortletContainerName();
+    }
+
+    /**
+     * Retrieve the portlet container version.
+     *
+     * @return container version
+     */
+    public String getPortletContainerVersion() {
+        return Configuration.getPortletContainerVersion();
+    }
+
+    /**
+     * Retrieve the major version number of the specification which this version
+     * of pluto supports.
+     * @return te major specification version.
+     */
+    public int getMajorSpecificationVersion() {
+        return Configuration.getMajorSpecificationVersion();
+    }
+
+    /**
+     * Retrieve the minor version number of the specification which this version
+     * of pluto supports.
+     * @return the minor specification version.
+     */
+    public int getMinorSpecificationVersion() {
+        return Configuration.getMinorSpecificationVersion();
+    }
+
+    /**
+     * Retrieve the formatted server info String required to be returned by the
+     * PortletContext.
+     * @return the server info.
+     */
+    public String getServerInfo() {
+        return Configuration.getServerInfo();
+    }
+}

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PlutoContainerInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextManager.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextManager.java?rev=755458&r1=755457&r2=755458&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextManager.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/driver/impl/PortletContextManager.java Wed Mar 18 02:23:03 2009
@@ -117,7 +117,7 @@
 
             PortletApplicationDefinition portletApp = portletRegistry.getPortletAppDD(servletContext, applicationName, contextPath);
 
-            DriverPortletContext portletContext = new PortletContextImpl(servletContext, portletApp);
+            DriverPortletContext portletContext = new DriverPortletContextImpl(servletContext, portletApp);
 
             portletContexts.put(applicationName, portletContext);
 
@@ -138,7 +138,7 @@
                 }
                 portletConfigs.put(
                     portletContext.getApplicationName() + "/" + portlet.getPortletName(),
-                    new PortletConfigImpl(portletContext, portlet, portletApp)
+                    new DriverPortletConfigImpl(portletContext, portlet)
                 );
             }
         } else {

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java?rev=755458&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java Wed Mar 18 02:23:03 2009
@@ -0,0 +1,236 @@
+/*
+ * 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.container.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+
+import org.apache.pluto.container.om.portlet.ContainerRuntimeOption;
+import org.apache.pluto.container.om.portlet.EventDefinitionReference;
+import org.apache.pluto.container.om.portlet.InitParam;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+
+/**
+ * Abstract PortletConfig base class Implementation.
+ * <p>
+ * An embedding Portal can extend this base class and is only required to provide
+ * an implementation of the getResourceBundle bundle method.
+ * </p>
+ * 
+ * @version $Id$
+ */
+public abstract class AbstractPortletConfigImpl implements PortletConfig
+{
+    protected PortletContext portletContext;
+    /**
+     * The portlet descriptor.
+     */
+    protected PortletDefinition portlet;
+    
+    protected Map<String, String[]> containerRuntimeOptions;
+    
+    protected Set<String> supportedContainerRuntimeOptions; 
+
+    public AbstractPortletConfigImpl(PortletContext portletContext, PortletDefinition portlet)
+    {
+        this.portletContext = portletContext;
+        this.portlet = portlet;
+        this.supportedContainerRuntimeOptions = new HashSet<String>();
+        for (Enumeration<String> e = portletContext.getContainerRuntimeOptions(); e.hasMoreElements(); )
+        {
+            supportedContainerRuntimeOptions.add(e.nextElement());
+        }
+    }
+
+    public abstract ResourceBundle getResourceBundle(Locale locale);
+    
+    public String getPortletName() {
+        return portlet.getPortletName();
+    }
+
+    public PortletContext getPortletContext() {
+        return portletContext;
+    }
+
+    public String getInitParameter(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Parameter name == null");
+        }
+
+        Iterator<? extends InitParam> parms = portlet.getInitParams().iterator();
+        while(parms.hasNext()) {
+            InitParam param = parms.next();
+            if (param.getParamName().equals(name)) {
+                return param.getParamValue();
+            }
+        }
+        return null;
+    }
+
+    public Enumeration<String> getInitParameterNames() {
+        return new java.util.Enumeration<String>() {
+            private Iterator<InitParam> iterator =
+                new ArrayList<InitParam>(portlet.getInitParams()).iterator();
+
+            public boolean hasMoreElements() {
+                return iterator.hasNext();
+            }
+
+            public String nextElement() {
+                if (iterator.hasNext()) {
+                    return iterator.next().getParamName();
+                } 
+                return null;
+            }
+        };
+    }
+
+    public PortletDefinition getPortletDefinition() {
+        return portlet;
+    }
+    // --------------------------------------------------------------------------------------------
+
+	public Enumeration<String> getPublicRenderParameterNames() {
+		if (portlet.getSupportedPublicRenderParameters() != null){
+			return Collections.enumeration(portlet.getSupportedPublicRenderParameters());
+		}
+		return  Collections.enumeration(new ArrayList<String>());
+	}
+
+	public String getDefaultNamespace() {
+		if (portlet.getApplication().getDefaultNamespace() == null)
+			return XMLConstants.NULL_NS_URI;
+		return portlet.getApplication().getDefaultNamespace();
+	}
+
+	public Enumeration<QName> getProcessingEventQNames() {
+	    ArrayList<QName> qnameList = new ArrayList<QName>();
+        for (EventDefinitionReference ref : portlet.getSupportedProcessingEvents())
+        {
+            QName name = ref.getQualifiedName(portlet.getApplication().getDefaultNamespace());
+            if (name == null)
+            {
+                continue;
+            }
+            else
+            {
+                qnameList.add(name);
+            }
+        }
+        return Collections.enumeration(qnameList);
+	}
+
+	public Enumeration<QName> getPublishingEventQNames() {
+        ArrayList<QName> qnameList = new ArrayList<QName>();
+        for (EventDefinitionReference ref : portlet.getSupportedPublishingEvents())
+        {
+            QName name = ref.getQualifiedName(portlet.getApplication().getDefaultNamespace());
+            if (name == null)
+            {
+                continue;
+            }
+            else
+            {
+                qnameList.add(name);
+            }
+        }
+        return Collections.enumeration(qnameList);
+	}
+
+	public Enumeration<Locale> getSupportedLocales() {
+		// for each String entry in SupportedLocales (portletDD)
+		// add an entry in the resut list (new Locale(string))
+		List<Locale> locals = new ArrayList<Locale>();
+		List<String> localsAsStrings = portlet.getSupportedLocales();
+		if (localsAsStrings!=null){
+			for (String string : localsAsStrings) {
+				locals.add(new Locale(string));
+			}
+		}
+		return Collections.enumeration(locals);
+	}
+	
+	public Map<String, String[]> getContainerRuntimeOptions()
+	{
+	    synchronized(this)
+	    {
+	        if (containerRuntimeOptions == null)
+	        {
+	            containerRuntimeOptions = new HashMap<String, String[]>();
+                for (ContainerRuntimeOption option : portlet.getApplication().getContainerRuntimeOptions())
+                {
+                    List<String> values = option.getValues();
+                    String [] tempValues = new String[values.size()];
+                    for (int i=0;i<values.size();i++)
+                    {
+                        tempValues[i] = values.get(i);
+                    }
+                    containerRuntimeOptions.put(option.getName(),tempValues);
+                }
+                for (ContainerRuntimeOption option : portlet.getContainerRuntimeOptions())
+                {
+                    List<String> values = option.getValues();
+                    String [] tempValues = new String[values.size()];
+                    for (int i=0;i<values.size();i++)
+                    {
+                        tempValues[i] = values.get(i);
+                    }
+                    containerRuntimeOptions.put(option.getName(),tempValues);
+                }
+	            for (Iterator<String> iter = containerRuntimeOptions.keySet().iterator(); iter.hasNext(); )
+	            {
+	                String key = iter.next();
+	                if (!supportedContainerRuntimeOptions.contains(key))
+	                {
+	                    iter.remove();
+	                }
+	            }
+	        }
+	    }
+	    
+        if (!containerRuntimeOptions.isEmpty())
+        {
+            Map<String, String[]> result = new HashMap<String, String[]>(containerRuntimeOptions.size());
+            for (Map.Entry<String,String[]> entry : containerRuntimeOptions.entrySet())
+            {
+                if (entry.getValue() != null)
+                {
+                    result.put(entry.getKey(), entry.getValue().clone());
+                }
+            }
+            return Collections.unmodifiableMap(result);
+        }
+        else
+        {
+            return Collections.emptyMap();
+        }
+	}
+}

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java?rev=755458&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java Wed Mar 18 02:23:03 2009
@@ -0,0 +1,245 @@
+/*
+ * 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.container.impl;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.container.ContainerInfo;
+import org.apache.pluto.container.RequestDispatcherPathInfoProvider;
+import org.apache.pluto.container.impl.PortletRequestDispatcherImpl;
+import org.apache.pluto.container.impl.RequestDispatcherPathInfoProviderImpl;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+
+/**
+ * Default Portlet Context Implementation.
+ * 
+ * @version $Id$
+ */
+public class PortletContextImpl implements PortletContext
+{
+	/**
+	 *  Logger.
+	 */
+    private static final Log LOG = LogFactory.getLog(PortletContextImpl.class);
+    
+    
+    // Private Member Variables ------------------------------------------------
+    
+    protected ServletContext servletContext;
+    protected PortletApplicationDefinition portletApp;
+    protected ContainerInfo containerInfo;
+    protected List<String> supportedContainerRuntimeOptions;
+
+    // Constructor -------------------------------------------------------------
+    
+    /**
+     * Constructs an instance.
+     * @param servletContext  the servlet context in which we are contained.
+     * @param portletAppDD  the portlet application descriptor.
+     */
+    public PortletContextImpl(ServletContext servletContext,
+                              PortletApplicationDefinition portletApp, 
+                              ContainerInfo containerInfo, 
+                              List<String> supportedContainerRuntimeOptions)
+    {
+        this.servletContext = servletContext;
+        this.portletApp = portletApp;
+        this.containerInfo = containerInfo;
+        this.supportedContainerRuntimeOptions = supportedContainerRuntimeOptions;
+    }
+    
+    // PortletContext Impl -----------------------------------------------------
+    
+    /**
+     * Retrieve the PortletContainer's server info.
+     * @return the server info in the form of <i>Server/Version</i>
+     */
+    public String getServerInfo() {
+        return containerInfo.getServerInfo();
+    }
+    
+    public PortletRequestDispatcher getRequestDispatcher(String path)
+    {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("PortletRequestDispatcher requested: " + path);
+        }
+        
+        // Check if the path name is valid. A valid path name must not be null
+        //   and must start with a slash '/' as defined by the portlet spec.
+        if (path == null || !path.startsWith("/")) {
+        	if (LOG.isInfoEnabled()) {
+        		LOG.info("Failed to retrieve PortletRequestDispatcher: "
+        				+ "path name must begin with a slash '/'.");
+        	}
+        	return null;
+        }
+        
+        // Construct PortletRequestDispatcher.
+        PortletRequestDispatcher portletRequestDispatcher = null;
+        try {
+            RequestDispatcher servletRequestDispatcher = servletContext.getRequestDispatcher(path);
+            if (servletRequestDispatcher != null) {
+
+                RequestDispatcherPathInfoProvider provider = RequestDispatcherPathInfoProviderImpl.getProvider(this, portletApp);
+            	portletRequestDispatcher = new PortletRequestDispatcherImpl(servletRequestDispatcher, provider.getPathInfo(portletApp.getContextPath(), path));
+            } else {
+            	if (LOG.isInfoEnabled()) {
+            		LOG.info("No matching request dispatcher found for: " + path);
+            	}
+            }
+        } catch (Exception ex) {
+            // We need to catch exception because of a Tomcat 4.x bug.
+            //   Tomcat throws an exception instead of return null if the path
+        	//   was not found.
+        	if (LOG.isInfoEnabled()) {
+        		LOG.info("Failed to retrieve PortletRequestDispatcher: "
+        				+ ex.getMessage());
+        	}
+        	portletRequestDispatcher = null;
+        }
+        return portletRequestDispatcher;
+    }
+    
+    public PortletRequestDispatcher getNamedDispatcher(String name) {
+        RequestDispatcher dispatcher = servletContext.getNamedDispatcher(name);
+        if (dispatcher != null)
+        {
+            RequestDispatcherPathInfoProvider provider = RequestDispatcherPathInfoProviderImpl.getProvider(this, portletApp);
+            return new PortletRequestDispatcherImpl(dispatcher, provider.getNamedRequestDispatcherPathInfo());
+        } else {
+        	if (LOG.isInfoEnabled()) {
+        		LOG.info("No matching request dispatcher found for name: "
+        				+ name);
+        	}
+        }
+        return null;
+    }
+
+    public InputStream getResourceAsStream(String path) {
+        return servletContext.getResourceAsStream(path);
+    }
+
+    public int getMajorVersion() {
+        return containerInfo.getMajorSpecificationVersion();
+    }
+
+    public int getMinorVersion() {
+        return containerInfo.getMinorSpecificationVersion();
+    }
+
+    public String getMimeType(String file) {
+        return servletContext.getMimeType(file);
+    }
+
+    public String getRealPath(String path) {
+        return servletContext.getRealPath(path);
+    }
+
+    @SuppressWarnings("unchecked")
+    public Set<String> getResourcePaths(String path) {
+        return servletContext.getResourcePaths(path);
+    }
+
+    public URL getResource(String path)
+        throws java.net.MalformedURLException {
+        if (path == null || !path.startsWith("/")) {
+            throw new MalformedURLException("path must start with a '/'");
+        }
+        return servletContext.getResource(path);
+    }
+
+    public Object getAttribute(java.lang.String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Attribute name == null");
+        }
+
+        return servletContext.getAttribute(name);
+    }
+
+    @SuppressWarnings("unchecked")
+    public Enumeration<String> getAttributeNames() {
+        return servletContext.getAttributeNames();
+    }
+
+    public String getInitParameter(java.lang.String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Parameter name == null");
+        }
+
+        return servletContext.getInitParameter(name);
+    }
+
+    @SuppressWarnings("unchecked")
+    public Enumeration<String> getInitParameterNames() {
+        return servletContext.getInitParameterNames();
+    }
+
+    public void log(java.lang.String msg) {
+        servletContext.log(msg);
+    }
+
+    public void log(java.lang.String message, Throwable throwable) {
+        servletContext.log(message, throwable);
+    }
+
+    public void removeAttribute(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Attribute name == null");
+        }
+
+        servletContext.removeAttribute(name);
+    }
+
+    public void setAttribute(String name, Object object) {
+        if (name == null) {
+            throw new IllegalArgumentException("Attribute name == null");
+        }
+
+        servletContext.setAttribute(name, object);
+    }
+
+    public String getPortletContextName() {
+        return servletContext.getServletContextName();
+    }
+    
+    
+    public ServletContext getServletContext() {
+        return servletContext;
+    }
+
+    public PortletApplicationDefinition getPortletApplicationDefinition() {
+        return portletApp;
+    }
+
+	public Enumeration<String> getContainerRuntimeOptions() {
+	    return Collections.enumeration(supportedContainerRuntimeOptions);
+	}
+}
+

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain