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/27 18:29:51 UTC
svn commit: r381391 - in /portals/pluto/trunk:
pluto-container/src/main/java/org/apache/pluto/
pluto-container/src/main/java/org/apache/pluto/internal/impl/
pluto-container/src/main/java/org/apache/pluto/util/impl/
pluto-container/src/test/java/org/apa...
Author: zheng
Date: Mon Feb 27 09:29:42 2006
New Revision: 381391
URL: http://svn.apache.org/viewcvs?rev=381391&view=rev
Log:
Added getStringId() to interface PortletWindowID.
Added:
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java
Removed:
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/
Modified:
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/PortletSessionImpl.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/PortalDriverServlet.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.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/services/container/PortletURLProviderImpl.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java
Modified: 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=381391&r1=381390&r2=381391&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindowID.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/PortletWindowID.java Mon Feb 27 09:29:42 2006
@@ -2,9 +2,6 @@
/**
* The portlet window ID.
- *
- * TODO: add method getStringID().
- *
* @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
* @version 1.0
*/
@@ -12,8 +9,13 @@
/**
* Returns the unique string ID of the portlet window.
+ * <p>
+ * Depending on the implementation of <code>toString()</code> is dangerous,
+ * because the original implementation in <code>Object</code> is not
+ * qualified.
+ * </p>
* @return the unique string ID of the portlet window.
*/
- //public String getStringId();
+ public String getStringId();
}
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java?rev=381391&r1=381390&r2=381391&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java Mon Feb 27 09:29:42 2006
@@ -219,7 +219,7 @@
private String createPortletScopedId(String name) {
StringBuffer buffer = new StringBuffer();
buffer.append(PORTLET_SCOPE_NAMESPACE);
- buffer.append(internalPortletWindow.getId());
+ buffer.append(internalPortletWindow.getId().getStringId());
buffer.append(ID_NAME_SEPARATOR);
buffer.append(name);
return buffer.toString();
@@ -239,7 +239,7 @@
&& name.indexOf(ID_NAME_SEPARATOR) > -1) {
String id = name.substring(PORTLET_SCOPE_NAMESPACE.length(),
name.indexOf(ID_NAME_SEPARATOR));
- return (id.equals(internalPortletWindow.getId().toString()));
+ return (id.equals(internalPortletWindow.getId().getStringId()));
}
// Application-scoped attribute names are not in portlet scope.
else {
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=381391&r1=381390&r2=381391&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 Mon Feb 27 09:29:42 2006
@@ -36,33 +36,35 @@
// NamespaceMapper Impl ----------------------------------------------------
- public String encode(PortletWindowID ns, String name) {
+ public String encode(PortletWindowID portletWindowId, String name) {
StringBuffer buffer = new StringBuffer(50);
buffer.append("Pluto_");
- buffer.append(ns);
+ buffer.append(portletWindowId.getStringId());
buffer.append('_');
buffer.append(name);
return buffer.toString();
}
- public String encode(PortletWindowID ns1, PortletWindowID ns2, String name) {
+ public String encode(PortletWindowID portletWindowId1,
+ PortletWindowID portletWindowId2,
+ String name) {
StringBuffer buffer = new StringBuffer(50);
buffer.append("Pluto_");
- buffer.append(ns1);
+ buffer.append(portletWindowId1.getStringId());
buffer.append('_');
- buffer.append(ns2);
+ buffer.append(portletWindowId2.getStringId());
buffer.append('_');
buffer.append(name);
return buffer.toString();
}
- public String decode(PortletWindowID ns, String name) {
+ public String decode(PortletWindowID portletWindowId, String name) {
if (!name.startsWith("Pluto_")) {
return null;
}
StringBuffer buffer = new StringBuffer(50);
buffer.append("Pluto_");
- buffer.append(ns);
+ buffer.append(portletWindowId.getStringId());
buffer.append('_');
if (!name.startsWith(buffer.toString())) {
return null;
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=381391&r1=381390&r2=381391&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 Mon Feb 27 09:29:42 2006
@@ -56,7 +56,7 @@
id = objectIDCounter++;
}
- public String toString() {
+ public String getStringId() {
return "uniqueId"+id;
}
}
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java?rev=381391&r1=381390&r2=381391&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java Mon Feb 27 09:29:42 2006
@@ -97,7 +97,7 @@
actionWindowConfig, portalURL);
if (LOG.isDebugEnabled()) {
LOG.debug("Processing action request for window: "
- + portletWindow.getId());
+ + portletWindow.getId().getStringId());
}
try {
container.doAction(portletWindow, request, response);
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java?rev=381391&r1=381390&r2=381391&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java Mon Feb 27 09:29:42 2006
@@ -87,13 +87,13 @@
PortalURLParameter param = (PortalURLParameter) iterator.next();
String name = param.getName();
String[] values = param.getValues();
- if (param.getWindowId().equals(portletWindow.getId().toString())) {
+ if (param.getWindowId().equals(portletWindow.getId().getStringId())) {
portletParameters.put(name, values);
}
}
- String id = portletWindow.getId().toString();
- if (portletWindow.getId().toString().equals(id)) {
+ String id = portletWindow.getId().getStringId();
+ if (portletWindow.getId().getStringId().equals(id)) {
Enumeration params = super.getParameterNames();
while (params.hasMoreElements()) {
String name = params.nextElement().toString();
Added: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java?rev=381391&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java (added)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java Mon Feb 27 09:29:42 2006
@@ -0,0 +1,120 @@
+/*
+ * 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.driver.core;
+
+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
+ * processing.
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
+public class PortletWindowIDImpl implements PortletWindowID, Serializable {
+
+ // Private Member Variables ------------------------------------------------
+
+ private String stringId = null;
+ private int intId;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Private constructor that prevents external instantiation.
+ * @param intId the integer ID.
+ * @param stringId the string ID.
+ */
+ private PortletWindowIDImpl(int intId, String stringId) {
+ this.stringId = stringId;
+ this.intId = intId;
+ }
+
+
+ // PortletWindowID Impl ----------------------------------------------------
+
+ public String getStringId() {
+ return stringId;
+ }
+
+ // Internal Methods --------------------------------------------------------
+
+ private void readObject(ObjectInputStream stream) throws IOException {
+ intId = stream.readInt();
+ stringId = String.valueOf(intId);
+ }
+
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ stream.write(intId);
+ }
+
+ // Common Object Methods ---------------------------------------------------
+
+ /**
+ public boolean equals(Object object) {
+ boolean result = false;
+ if (object instanceof PortletWindowIDImpl) {
+ result = (intId == ((PortletWindowIDImpl) object).intId);
+ } else if (object instanceof String) {
+ result = stringId.equals(object);
+ } else if (object instanceof Integer) {
+ result = (intId == ((Integer) object).intValue());
+ }
+ return (result);
+ }
+ **/
+
+ public int hashCode() {
+ return intId;
+ }
+
+
+ // Additional Methods ------------------------------------------------------
+
+ public int intValue() {
+ return intId;
+ }
+
+ /**
+ * Creates a portlet window ID instance from a string.
+ * @param stringId the string ID from which the instance is created.
+ * @return a portlet window ID instance created from the string ID.
+ */
+ static public PortletWindowIDImpl createFromString(String stringId) {
+ char[] id = stringId.toCharArray();
+ int _id = 1;
+ for (int i = 0; i < id.length; i++) {
+ if ((i % 2) == 0) {
+ _id *= id[i];
+ } else {
+ _id ^= id[i];
+ }
+ _id = Math.abs(_id);
+ }
+ return new PortletWindowIDImpl(_id, stringId);
+ }
+
+}
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=381391&r1=381390&r2=381391&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 Mon Feb 27 09:29:42 2006
@@ -26,7 +26,6 @@
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;
/**
* Implementation of <code>PortletWindow</code> interface.
@@ -39,7 +38,7 @@
private PortletWindowConfig config = null;
private PortalURL portalURL = null;
- private ObjectIdImpl objectIdImpl = null;
+ private PortletWindowIDImpl objectIdImpl = null;
// Constructor -------------------------------------------------------------
@@ -66,16 +65,16 @@
}
public WindowState getWindowState() {
- return portalURL.getWindowState(getId().toString());
+ return portalURL.getWindowState(getId().getStringId());
}
public PortletMode getPortletMode() {
- return portalURL.getPortletMode(getId().toString());
+ return portalURL.getPortletMode(getId().getStringId());
}
public PortletWindowID getId() {
if (objectIdImpl == null) {
- objectIdImpl = ObjectIdImpl.createFromString(config.getId());
+ objectIdImpl = PortletWindowIDImpl.createFromString(config.getId());
}
return objectIdImpl;
}
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java?rev=381391&r1=381390&r2=381391&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java Mon Feb 27 09:29:42 2006
@@ -45,7 +45,7 @@
public PortletURLProviderImpl(HttpServletRequest request,
PortletWindow internalPortletWindow) {
url = PortalURLFactory.getFactory().createPortalURL(request);
- this.window = internalPortletWindow.getId().toString();
+ this.window = internalPortletWindow.getId().getStringId();
}
public void setPortletMode(PortletMode mode) {
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java?rev=381391&r1=381390&r2=381391&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java Mon Feb 27 09:29:42 2006
@@ -117,7 +117,7 @@
String windowId = (String) it.next();
WindowState windowState = (WindowState) windowStates.get(windowId);
if (WindowState.MAXIMIZED.equals(windowState)
- && !window.getId().equals(windowId)) {
+ && !window.getId().getStringId().equals(windowId)) {
return SKIP_BODY;
}
}