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 zh...@apache.org on 2006/02/24 14:07:44 UTC

svn commit: r380664 - in /portals/pluto/trunk: pluto-container/src/main/java/org/apache/pluto/ pluto-container/src/main/java/org/apache/pluto/core/ pluto-container/src/main/java/org/apache/pluto/internal/ pluto-container/src/main/java/org/apache/pluto/...

Author: zheng
Date: Fri Feb 24 05:07:37 2006
New Revision: 380664

URL: http://svn.apache.org/viewcvs?rev=380664&view=rev
Log:
Updated ObjectID to PortletWindowID.

Added:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindowID.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletWindowImpl.java
Removed:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/om/
Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletWindow.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/PortletEntity.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java
    portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java
    portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
    portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindow.java Fri Feb 24 05:07:37 2006
@@ -19,17 +19,16 @@
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
 
-import org.apache.pluto.om.ObjectID;
-
 /**
  * Thin representation of the portlet window for which the container
  * request should be processed.  The PortletWindow is used internally
  * to map the request to the configured Portlet Application and Portlet.
  *
- * @see org.apache.pluto.core.InternalPortletWindow
+ * @see org.apache.pluto.core.PortletWindowImpl
  * @see org.apache.pluto.descriptors.portlet.PortletDD
  *
- * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
  * @version 1.0
  * @since Sep 22, 2004
  */
@@ -40,7 +39,7 @@
      *  used to communicate back to the referencing portal.
      * @return unique id.
      */
-    public ObjectID getId();
+    public PortletWindowID getId();
 
     /**
      * Retrieve the context path in which the Portlet resides.
@@ -66,4 +65,5 @@
      * @return the current portlet mode.
      */
     public PortletMode getPortletMode();
+    
 }

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindowID.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindowID.java?rev=380664&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindowID.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindowID.java Fri Feb 24 05:07:37 2006
@@ -0,0 +1,19 @@
+package org.apache.pluto;
+
+/**
+ * The portlet window ID.
+ * 
+ * TODO: add method getStringID().
+ * 
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @version 1.0
+ */
+public interface PortletWindowID {
+	
+	/**
+	 * Returns the unique string ID of the portlet window.
+	 * @return the unique string ID of the portlet window.
+	 */
+	//public String getStringId();
+	
+}

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java Fri Feb 24 05:07:37 2006
@@ -29,6 +29,7 @@
 import org.apache.pluto.internal.InternalPortletWindow;
 import org.apache.pluto.internal.impl.ActionRequestImpl;
 import org.apache.pluto.internal.impl.ActionResponseImpl;
+import org.apache.pluto.internal.impl.PortletWindowImpl;
 import org.apache.pluto.internal.impl.RenderRequestImpl;
 import org.apache.pluto.internal.impl.RenderResponseImpl;
 import org.apache.pluto.spi.PortletURLProvider;
@@ -144,7 +145,7 @@
     	ensureInitialized();
     	
         InternalPortletWindow internalPortletWindow =
-        		new InternalPortletWindow(servletContext, portletWindow);
+        		new PortletWindowImpl(servletContext, portletWindow);
         debugWithName("Render request received for portlet: "
         		+ portletWindow.getPortletName());
         
@@ -178,7 +179,7 @@
     	ensureInitialized();
     	
         InternalPortletWindow internalPortletWindow =
-            	new InternalPortletWindow(servletContext, portletWindow);
+            	new PortletWindowImpl(servletContext, portletWindow);
     	debugWithName("Action request received for portlet: "
     			+ portletWindow.getPortletName());
     	
@@ -255,7 +256,7 @@
     	ensureInitialized();
     	
         InternalPortletWindow internalPortletWindow =
-        		new InternalPortletWindow(servletContext, portletWindow);
+        		new PortletWindowImpl(servletContext, portletWindow);
         debugWithName("Load request received for portlet: "
         		+ portletWindow.getPortletName());
         

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletWindow.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletWindow.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletWindow.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletWindow.java Fri Feb 24 05:07:37 2006
@@ -19,14 +19,9 @@
 
 package org.apache.pluto.internal;
 
-import javax.portlet.PortletMode;
-import javax.portlet.WindowState;
 import javax.servlet.ServletContext;
 
 import org.apache.pluto.PortletWindow;
-import org.apache.pluto.PortletContainerRuntimeException;
-import org.apache.pluto.util.StringManager;
-import org.apache.pluto.om.ObjectID;
 
 
 /**
@@ -35,114 +30,20 @@
  * between portlet windows and portlet entities. Adding the same portlet e.g.
  * twice on a page results in two different windows.
  * 
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
  */
-public class InternalPortletWindow implements PortletWindow {
-
-    private static final StringManager EXCEPTIONS =
-            StringManager.getManager(InternalPortletWindow.class.getPackage().getName());
-    
-    
-    // Private Member Variables ------------------------------------------------
-    
-    /** The underlying portlet window instance. */
-    private PortletWindow portletWindow = null;
-    
-    /** The servlet context of the portlet. */
-    private ServletContext servletContext = null;
-    
-    /** The portlet entity associated with the portlet window. */
-    private PortletEntity entity;
-    
-    
-    // Constructor -------------------------------------------------------------
-    
-    /**
-     * Constructs an internal portlet window that wraps a portlet window.
-     * An internal portlet window instance is created everytime when the portlet
-     * container's <code>doRender()</code> or <code>doAction()</code> method is
-     * invoked.
-     * 
-     * @param context  the servlet context from which this window is
-     *        being invoked.
-     * @param portletWindow  the underlying portlet window instance.
-     */
-    public InternalPortletWindow(ServletContext context,
-                                 PortletWindow portletWindow) {
-        this.servletContext = context.getContext(
-        		portletWindow.getContextPath());
-        if (servletContext == null) {
-            throw new PortletContainerRuntimeException(
-                EXCEPTIONS.getString(
-                    "error.config.context.null",
-                    portletWindow.getPortletName(),
-                    portletWindow.getContextPath()
-                )
-            );
-        }
-        this.portletWindow = portletWindow;
-    }
-
-    /**
-     * Standard Getter.
-     * @return the context path.
-     */
-    public String getContextPath() {
-        return portletWindow.getContextPath();
-    }
-
-    /**
-     * Standard getter.
-     * @return the portlet name as defined in the deployment descriptor.
-     */
-    public String getPortletName() {
-        return portletWindow.getPortletName();
-    }
-
-    /**
-     * Standard getter.
-     * @return the window state.
-     */
-    public WindowState getWindowState() {
-        return portletWindow.getWindowState();
-    }
-
-    /**
-     * Standard getter.
-     * @return the portlet mode the portlet mode
-     */
-    public PortletMode getPortletMode() {
-        return portletWindow.getPortletMode();
-    }
-
-
-    /**
-     * Returns the identifier of this portlet instance window as object id. The
-     * return value cannot be NULL.
-     * @return the object identifier
-     */
-    public ObjectID getId() {
-        return portletWindow.getId();
-    }
+public interface InternalPortletWindow extends PortletWindow {
 
     /**
      * The Context from which this window can be serviced.
      * @return the associated servlet context.
      */
-    public ServletContext getServletContext() {
-        return servletContext;
-    }
+    public ServletContext getServletContext();
 
     /**
      * Returns the portlet entity. The return value cannot be NULL.
      * @return the portlet entity
      */
-    public PortletEntity getPortletEntity() {
-        if (entity == null) {
-            entity = new PortletEntity(servletContext, this);
-        }
-        return entity;
-    }
-
+    public PortletEntity getPortletEntity();
+    
 }

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/PortletEntity.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/PortletEntity.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/PortletEntity.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/PortletEntity.java Fri Feb 24 05:07:37 2006
@@ -19,25 +19,12 @@
 
 package org.apache.pluto.internal;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.PortletContainerException;
-import org.apache.pluto.PortletWindow;
 import org.apache.pluto.internal.InternalPortletPreference;
-import org.apache.pluto.internal.impl.PortletPreferenceImpl;
-import org.apache.pluto.descriptors.portlet.PortletAppDD;
 import org.apache.pluto.descriptors.portlet.PortletDD;
-import org.apache.pluto.descriptors.portlet.PortletPreferenceDD;
-import org.apache.pluto.descriptors.portlet.PortletPreferencesDD;
 import org.apache.pluto.descriptors.servlet.ServletDD;
 
 import javax.portlet.PreferencesValidator;
 import javax.portlet.ValidatorException;
-import javax.servlet.ServletContext;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
 
 /**
  * The PortletEntity encapsulates all data pertaining to a single portlet
@@ -46,50 +33,16 @@
  * Definition as defined by the {@link PortletDD} and the Wrapping Servlet
  * information as defined by the{@link ServletDD}
  * 
- * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  */
-public class PortletEntity {
+public interface PortletEntity {
 	
-	/** Logger. */
-    private static final Log LOG = LogFactory.getLog(PortletEntity.class);
-    
-    /** URI prefix of the portlet invoker servlet. */
-    private static final String PREFIX = "/PlutoInvoker/";
-    
-    
-    // Private Member Variables ------------------------------------------------
-    
-    /** The servlet context. */
-    private ServletContext servletContext = null;
-    
-    /** The portlet window. */
-    private PortletWindow portletWindow = null;
-
-    /** The cached PortletDD retrieved from the portlet descriptor registry. */
-    private PortletDD portletDefinition = null;
-    
-    /** Default portlet preferences defined for this portlet. */
-    private InternalPortletPreference[] defaultPreferences = null;
-    
-    
-    // Constructor -------------------------------------------------------------
-    
-    PortletEntity(ServletContext servletContext, PortletWindow portletWindow) {
-        this.servletContext = servletContext;
-        this.portletWindow = portletWindow;
-    }
-    
-    
-    // Public Methods ----------------------------------------------------------
-    
     /**
      * Returns the URI to the controller servlet that wraps this portlet.
      * @return the URI to the controller servlet that wraps this portlet.
      */
-    public String getControllerServletUri() {
-        return PREFIX + portletWindow.getPortletName();
-    }
+    public String getControllerServletUri();
     
     /**
      * Returns an array of default preferences of this portlet. The default
@@ -113,41 +66,13 @@
      * 
      * @see org.apache.pluto.descriptors.portlet.PortletPreferenceDD
      */
-    public InternalPortletPreference[] getDefaultPreferences() {
-        if (defaultPreferences == null) {
-            PortletDD portletDD = getPortletDefinition();
-            PortletPreferencesDD prefsDD = portletDD.getPortletPreferences();
-            if (prefsDD != null) {
-            	List prefs = new ArrayList();
-            	for (Iterator it = prefsDD.getPortletPreferences().iterator();
-            			it.hasNext(); ) {
-            		PortletPreferenceDD prefDD = (PortletPreferenceDD) it.next();
-            		String[] values = null;
-            		if (prefDD.getValues().size() > 0) {
-            			values = (String[]) prefDD.getValues().toArray(
-            					new String[prefDD.getValues().size()]);
-            		}
-            		PortletPreferenceImpl pref = new PortletPreferenceImpl(
-            				prefDD.getName(), values, prefDD.isReadOnly());
-            		prefs.add(pref);
-            	}
-            	defaultPreferences = (InternalPortletPreference[])
-            			prefs.toArray(new InternalPortletPreference[prefs.size()]);
-            }
-        }
-        return defaultPreferences;
-    }
+    public InternalPortletPreference[] getDefaultPreferences();
 
     /**
      * Returns the portlet description. The return value cannot be NULL.
      * @return the portlet description.
      */
-    public PortletDD getPortletDefinition() {
-        if (portletDefinition == null) {
-            load();
-        }
-        return portletDefinition;
-    }
+    public PortletDD getPortletDefinition();
     
     /**
      * Returns the preferences validator instance for this portlet.
@@ -156,50 +81,9 @@
      * @throws ValidatorException  if fail to instantiate the validator.
      */
     public PreferencesValidator getPreferencesValidator()
-    throws ValidatorException {
-    	PreferencesValidator validator = PreferencesValidatorRegistry
-    			.getRegistry()
-    			.getPreferencesValidator(getPortletDefinition());
-    	return validator;
-    }
-    
-    
-    // Private Methods ---------------------------------------------------------
+    throws ValidatorException;
     
-    /**
-     * Loads the portlet definition.
-     */
-    private void load() {
-    	
-    	// Retrieve the cross servlet context for the portlet.
-        String contextPath = portletWindow.getContextPath();
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Loading portlet definition for context: " + contextPath);
-        }
-        ServletContext crossContext = servletContext.getContext(contextPath);
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Retrieved cross context: " + crossContext);
-        }
-        
-        // Load PortletAppDD and find out the portlet definition.
-        try {
-            PortletAppDD appDD = PortletDescriptorRegistry.getRegistry()
-            		.getPortletAppDD(crossContext);
-            for (Iterator it = appDD.getPortlets().iterator(); it.hasNext(); ) {
-                PortletDD portletDD = (PortletDD) it.next();
-                if (portletDD.getPortletName().equals(
-                		portletWindow.getPortletName())) {
-                	portletDefinition = portletDD;
-                	break;
-                }
-            }
-        } catch (PortletContainerException ex) {
-        	String message = "Unable to load Portlet App Deployment Descriptor:"
-        			+ ex.getMessage();
-        	LOG.error(message, ex);
-        	// FIXME: should this be a NullPointerException?
-            throw new NullPointerException(message);
-        }
-    }
-
 }
+
+
+

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java?rev=380664&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java Fri Feb 24 05:07:37 2006
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.internal.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.PortletWindow;
+import org.apache.pluto.internal.InternalPortletPreference;
+import org.apache.pluto.internal.PortletDescriptorRegistry;
+import org.apache.pluto.internal.PortletEntity;
+import org.apache.pluto.internal.PreferencesValidatorRegistry;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+import org.apache.pluto.descriptors.portlet.PortletPreferenceDD;
+import org.apache.pluto.descriptors.portlet.PortletPreferencesDD;
+import org.apache.pluto.descriptors.servlet.ServletDD;
+
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ValidatorException;
+import javax.servlet.ServletContext;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The PortletEntity encapsulates all data pertaining to a single portlet
+ * instance.  This instance may appear zero or more times per user. The
+ * PortletEntity consists of two primary peices of information, the Portlet
+ * Definition as defined by the {@link PortletDD} and the Wrapping Servlet
+ * information as defined by the{@link ServletDD}
+ * 
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
+public class PortletEntityImpl implements PortletEntity {
+	
+	/** Logger. */
+    private static final Log LOG = LogFactory.getLog(PortletEntityImpl.class);
+    
+    /** URI prefix of the portlet invoker servlet. */
+    private static final String PREFIX = "/PlutoInvoker/";
+    
+    
+    // Private Member Variables ------------------------------------------------
+    
+    /** The servlet context. */
+    private ServletContext servletContext = null;
+    
+    /** The portlet window. */
+    private PortletWindow portletWindow = null;
+
+    /** The cached PortletDD retrieved from the portlet descriptor registry. */
+    private PortletDD portletDefinition = null;
+    
+    /** Default portlet preferences defined for this portlet. */
+    private InternalPortletPreference[] defaultPreferences = null;
+    
+    
+    // Constructor -------------------------------------------------------------
+    
+    PortletEntityImpl(ServletContext servletContext, PortletWindow portletWindow) {
+        this.servletContext = servletContext;
+        this.portletWindow = portletWindow;
+    }
+    
+    
+    // PortletEntity Impl ------------------------------------------------------
+    
+    /**
+     * Returns the URI to the controller servlet that wraps this portlet.
+     * @return the URI to the controller servlet that wraps this portlet.
+     */
+    public String getControllerServletUri() {
+        return PREFIX + portletWindow.getPortletName();
+    }
+    
+    /**
+     * Returns an array of default preferences of this portlet. The default
+     * preferences are retrieved from the portlet application descriptor.
+     * <p>
+     * Data retrieved from <code>portlet.xml</code> are injected into the domain
+     * object <code>PortletPreferenceDD</code>. This method converts the domain
+     * objects into <code>PortletPreference</code> objects.
+     * </p>
+     * <p>
+     * Note that if no value is bound to a given preference key,
+     * <code>PortletPreferenceDD.getValues()</code> will return an empty string
+     * list, but the value array of <code>PortletPreference</code> should be set
+     * to null (instead of an empty array).
+     * </p>
+     * <p>
+     * This method never returns null, but the values held by PortletPreference
+     * may be null.
+     * </p>
+     * @return the preference set
+     * 
+     * @see org.apache.pluto.descriptors.portlet.PortletPreferenceDD
+     */
+    public InternalPortletPreference[] getDefaultPreferences() {
+        if (defaultPreferences == null) {
+            PortletDD portletDD = getPortletDefinition();
+            PortletPreferencesDD prefsDD = portletDD.getPortletPreferences();
+            if (prefsDD != null) {
+            	List prefs = new ArrayList();
+            	for (Iterator it = prefsDD.getPortletPreferences().iterator();
+            			it.hasNext(); ) {
+            		PortletPreferenceDD prefDD = (PortletPreferenceDD) it.next();
+            		String[] values = null;
+            		if (prefDD.getValues().size() > 0) {
+            			values = (String[]) prefDD.getValues().toArray(
+            					new String[prefDD.getValues().size()]);
+            		}
+            		PortletPreferenceImpl pref = new PortletPreferenceImpl(
+            				prefDD.getName(), values, prefDD.isReadOnly());
+            		prefs.add(pref);
+            	}
+            	defaultPreferences = (InternalPortletPreference[])
+            			prefs.toArray(new InternalPortletPreference[prefs.size()]);
+            }
+        }
+        return defaultPreferences;
+    }
+
+    /**
+     * Returns the portlet description. The return value cannot be NULL.
+     * @return the portlet description.
+     */
+    public PortletDD getPortletDefinition() {
+        if (portletDefinition == null) {
+            load();
+        }
+        return portletDefinition;
+    }
+    
+    /**
+     * Returns the preferences validator instance for this portlet.
+     * One validator instance is created per portlet definition.
+     * @return the preferences validator instance for this portlet.
+     * @throws ValidatorException  if fail to instantiate the validator.
+     */
+    public PreferencesValidator getPreferencesValidator()
+    throws ValidatorException {
+    	PreferencesValidator validator = PreferencesValidatorRegistry
+    			.getRegistry()
+    			.getPreferencesValidator(getPortletDefinition());
+    	return validator;
+    }
+    
+    
+    // Private Methods ---------------------------------------------------------
+    
+    /**
+     * Loads the portlet definition.
+     */
+    private void load() {
+    	
+    	// Retrieve the cross servlet context for the portlet.
+        String contextPath = portletWindow.getContextPath();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Loading portlet definition for context: " + contextPath);
+        }
+        ServletContext crossContext = servletContext.getContext(contextPath);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Retrieved cross context: " + crossContext);
+        }
+        
+        // Load PortletAppDD and find out the portlet definition.
+        try {
+            PortletAppDD appDD = PortletDescriptorRegistry.getRegistry()
+            		.getPortletAppDD(crossContext);
+            for (Iterator it = appDD.getPortlets().iterator(); it.hasNext(); ) {
+                PortletDD portletDD = (PortletDD) it.next();
+                if (portletDD.getPortletName().equals(
+                		portletWindow.getPortletName())) {
+                	portletDefinition = portletDD;
+                	break;
+                }
+            }
+        } catch (PortletContainerException ex) {
+        	String message = "Unable to load Portlet App Deployment Descriptor:"
+        			+ ex.getMessage();
+        	LOG.error(message, ex);
+        	// FIXME: should this be a NullPointerException?
+            throw new NullPointerException(message);
+        }
+    }
+
+}

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletWindowImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletWindowImpl.java?rev=380664&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletWindowImpl.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletWindowImpl.java Fri Feb 24 05:07:37 2006
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.internal.impl;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.servlet.ServletContext;
+
+import org.apache.pluto.PortletWindow;
+import org.apache.pluto.PortletContainerRuntimeException;
+import org.apache.pluto.PortletWindowID;
+import org.apache.pluto.util.StringManager;
+import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.internal.PortletEntity;
+
+/**
+ * Implementation of <code>InternalPortletWindow</code> interface.
+ * 
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
+public class PortletWindowImpl implements InternalPortletWindow {
+
+    private static final StringManager EXCEPTIONS = StringManager.getManager(
+    		PortletWindowImpl.class.getPackage().getName());
+    
+    
+    // Private Member Variables ------------------------------------------------
+    
+    /** The underlying portlet window instance. */
+    private PortletWindow portletWindow = null;
+    
+    /** The servlet context of the portlet. */
+    private ServletContext servletContext = null;
+    
+    /** The portlet entity associated with the portlet window. */
+    private PortletEntity entity = null;
+    
+    
+    // Constructor -------------------------------------------------------------
+    
+    /**
+     * Constructs an internal portlet window that wraps a portlet window.
+     * An internal portlet window instance is created everytime when the portlet
+     * container's <code>doRender()</code> or <code>doAction()</code> method is
+     * invoked.
+     * 
+     * @param context  the servlet context from which this window is
+     *        being invoked.
+     * @param portletWindow  the underlying portlet window instance.
+     */
+    public PortletWindowImpl(ServletContext context,
+                                 PortletWindow portletWindow) {
+        this.servletContext = context.getContext(
+        		portletWindow.getContextPath());
+        if (servletContext == null) {
+            throw new PortletContainerRuntimeException(EXCEPTIONS.getString(
+            		"error.config.context.null",
+                    portletWindow.getPortletName(),
+                    portletWindow.getContextPath()));
+        }
+        this.portletWindow = portletWindow;
+    }
+    
+    
+    // PortletWindow Impl ------------------------------------------------------
+    
+    public String getContextPath() {
+        return portletWindow.getContextPath();
+    }
+
+    public String getPortletName() {
+        return portletWindow.getPortletName();
+    }
+
+    public WindowState getWindowState() {
+        return portletWindow.getWindowState();
+    }
+
+    public PortletMode getPortletMode() {
+        return portletWindow.getPortletMode();
+    }
+    
+    public PortletWindowID getId() {
+        return portletWindow.getId();
+    }
+    
+    
+    // InternalPortletWindow Impl ----------------------------------------------
+    
+    public ServletContext getServletContext() {
+        return servletContext;
+    }
+
+    public PortletEntity getPortletEntity() {
+        if (entity == null) {
+            entity = new PortletEntityImpl(servletContext, this);
+        }
+        return entity;
+    }
+
+}

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/NamespaceMapper.java Fri Feb 24 05:07:37 2006
@@ -19,17 +19,17 @@
 
 package org.apache.pluto.util;
 
-import org.apache.pluto.om.ObjectID;
+import org.apache.pluto.PortletWindowID;
 
 /**
  **/
 public interface NamespaceMapper {
 
 
-    public String encode(ObjectID namespace, String name);
+    public String encode(PortletWindowID namespace, String name);
 
-    public String encode(ObjectID ns1, ObjectID ns2, String name);
+    public String encode(PortletWindowID ns1, PortletWindowID ns2, String name);
 
-    public String decode(ObjectID ns, String name);
+    public String decode(PortletWindowID ns, String name);
 
 }

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/impl/NamespaceMapperImpl.java Fri Feb 24 05:07:37 2006
@@ -19,18 +19,24 @@
 
 package org.apache.pluto.util.impl;
 
-import org.apache.pluto.om.ObjectID;
+import org.apache.pluto.PortletWindowID;
 import org.apache.pluto.util.NamespaceMapper;
 
 /**
- **/
-
+ * Default implementation of <code>NamespaceMapper</code> interface.
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
 public class NamespaceMapperImpl implements NamespaceMapper {
+	
     public NamespaceMapperImpl() {
+    	// Do nothing.
     }
-
-    // org.apache.pluto.util.NamespaceMapper implementation ---------------------------------------
-    public String encode(ObjectID ns, String name) {
+    
+    
+    // NamespaceMapper Impl ----------------------------------------------------
+    
+    public String encode(PortletWindowID ns, String name) {
         StringBuffer buffer = new StringBuffer(50);
         buffer.append("Pluto_");
         buffer.append(ns);
@@ -39,7 +45,7 @@
         return buffer.toString();
     }
 
-    public String encode(ObjectID ns1, ObjectID ns2, String name) {
+    public String encode(PortletWindowID ns1, PortletWindowID ns2, String name) {
         StringBuffer buffer = new StringBuffer(50);
         buffer.append("Pluto_");
         buffer.append(ns1);
@@ -50,7 +56,7 @@
         return buffer.toString();
     }
 
-    public String decode(ObjectID ns, String name) {
+    public String decode(PortletWindowID ns, String name) {
         if (!name.startsWith("Pluto_")) {
             return null;
         }
@@ -63,5 +69,5 @@
         }
         return name.substring(buffer.length());
     }
-    // --------------------------------------------------------------------------------------------
+    
 }

Modified: portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java (original)
+++ portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/impl/NamespaceMapperImplTest.java Fri Feb 24 05:07:37 2006
@@ -1,8 +1,8 @@
 package org.apache.pluto.util.impl;
 
+import org.apache.pluto.PortletWindowID;
 import org.apache.pluto.util.PlutoTestCase;
 import org.apache.pluto.util.NamespaceMapper;
-import org.apache.pluto.om.ObjectID;
 
 /**
  * Test Class
@@ -14,13 +14,13 @@
 public class NamespaceMapperImplTest extends PlutoTestCase {
 
     private NamespaceMapper mapper = new NamespaceMapperImpl();
-    private ObjectID id1;
-    private ObjectID id2;
+    private PortletWindowID id1;
+    private PortletWindowID id2;
 
     public void setUp() throws Exception {
         super.setUp();
-        id1 = new InternalObjectID();
-        id2 = new InternalObjectID();
+        id1 = new InternalPortletWindowID();
+        id2 = new InternalPortletWindowID();
     }
 
     public void testEncodeUniquenessWithSameName() {
@@ -46,10 +46,13 @@
     }
 
     private static int objectIDCounter = 1;
-    private class InternalObjectID implements ObjectID {
+    
+    
+    private class InternalPortletWindowID implements PortletWindowID {
+    	
         private int id;
 
-        public InternalObjectID() {
+        public InternalPortletWindowID() {
             id = objectIDCounter++;
         }
 

Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java Fri Feb 24 05:07:37 2006
@@ -23,10 +23,10 @@
 import javax.portlet.WindowState;
 
 import org.apache.pluto.PortletWindow;
+import org.apache.pluto.PortletWindowID;
 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
 import org.apache.pluto.driver.url.PortalURL;
 import org.apache.pluto.driver.util.ObjectIdImpl;
-import org.apache.pluto.om.ObjectID;
 
 /**
  * Implementation of <code>PortletWindow</code> interface.
@@ -73,7 +73,7 @@
         return portalURL.getPortletMode(getId().toString());
     }
 
-    public ObjectID getId() {
+    public PortletWindowID getId() {
         if (objectIdImpl == null) {
             objectIdImpl = ObjectIdImpl.createFromString(config.getId());
         }

Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java?rev=380664&r1=380663&r2=380664&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java Fri Feb 24 05:07:37 2006
@@ -22,15 +22,18 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import org.apache.pluto.PortletWindowID;
 
 /**
- * * Wraps around the internal Object IDs. By holding both * the string and the
- * integer version of an Object ID this class * helps speed up the internal
+ * Wraps around the internal Object IDs. By holding both the string and the
+ * integer version of an Object ID this class helps speed up the internal
  * processing.
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
  */
-
-public class ObjectIdImpl implements org.apache.pluto.om.ObjectID,
-                                     java.io.Serializable {
+public class ObjectIdImpl implements PortletWindowID, Serializable {
 
     private String stringOID = null;
     private int intOID;