This allows intra/inter portlet to portlet communication inside Seam. Basically 
everything that goes to Session scope is also put to both PORTLET_SCOPE(portlet 
private, only the portlet putting has access to it) and APPLICATION_SCOPE 
(portal wide, every portlet inside portal sees it). A more elegant/resource 
wise solution might be better, but it is not actually trivial without adding 
new configuration options.

/*
  |  * JBoss, Home of Professional Open Source
  |  *
  |  * Distributable under LGPL license.
  |  * See terms of license at gnu.org.
  |  */
  | package org.jboss.seam.portlet;
  | 
  | import java.util.Collections;
  | import java.util.Enumeration;
  | import java.util.List;
  | 
  | import javax.portlet.PortletSession;
  | 
  | import org.apache.commons.collections.ListUtils;
  | import org.jboss.seam.contexts.ContextAdaptor;
  | 
  | /**
  |  * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Heute </a>
  |  * @version $Revision: 1.4 $
  |  */
  | public class PortletSessionImpl extends ContextAdaptor {
  | 
  |     private PortletSession session;
  | 
  |     public PortletSessionImpl(PortletSession session) {
  |             this.session = session;
  |     }
  | 
  |     public Object getAttribute(String key) {
  |             // search for key first in PORTLET_SCOPE
  |             Object o = session.getAttribute(key);
  |             Object po = null;
  |             // if nothing is found there try APPLICATION_SCOPE
  |             if (o == null) {
  |                     po = session.getAttribute(key, 
PortletSession.APPLICATION_SCOPE);
  |                     return po;
  |             } else {
  |                     // TODO: just do some cleaning up or maybe not
  |                     // session.removeAttribute(key, 
PortletSession.APPLICATION_SCOPE);
  |             }
  | 
  |             return o;
  |     }
  | 
  |     public void removeAttribute(String key) {
  |             session.removeAttribute(key);
  |             session.removeAttribute(key, PortletSession.APPLICATION_SCOPE);
  |     }
  | 
  |     public Enumeration getAttributeNames() {
  |             Enumeration portletAttributeNamesEnum = 
session.getAttributeNames();
  |             Enumeration portalAttributeNamesEnum = session
  |                             
.getAttributeNames(PortletSession.APPLICATION_SCOPE);
  | 
  |             List portletAttributeNames = Collections
  |                             .list(portletAttributeNamesEnum);
  |             List portalAttributeNames = 
Collections.list(portalAttributeNamesEnum);
  | 
  |             // TODO: Is this correct?
  |             List allNames = ListUtils.sum(portalAttributeNames,
  |                             portalAttributeNames);
  | 
  |             return Collections.enumeration(allNames);
  |     }
  | 
  |     public void setAttribute(String key, Object value) {
  |             session.setAttribute(key, value);
  |             session.setAttribute(key, value, 
PortletSession.APPLICATION_SCOPE);
  |     }
  | 
  |     public void invalidate() {
  |             session.invalidate();
  |     }
  | 
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973176#3973176

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973176
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to