[portal-commits] JBoss Portal SVN: r9165 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation: impl/model/state and 4 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Nov 28 09:00:50 EST 2007


Author: julien at jboss.com
Date: 2007-11-28 09:00:49 -0500 (Wed, 28 Nov 2007)
New Revision: 9165

Added:
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/content/
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/content/ContentStateContextImpl.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java
Modified:
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/ContentStateContext.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java
Log:
- delegate storage of navigational and content state to dedicated context which allow a better control of the state life cycle of the overral model

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java	2007-11-28 13:46:43 UTC (rev 9164)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java	2007-11-28 14:00:49 UTC (rev 9165)
@@ -124,10 +124,10 @@
       switch (scopeType)
       {
          case CONTENT:
-            value = context.contentStateContext.get(propertyName);
+            value = context.contentStateContext.get(id, propertyName);
             break;
          case NAVIGATIONAL:
-            value = context.navigationalStateContext.get(propertyName);
+            value = context.navigationalStateContext.get(id, propertyName);
             break;
          case STRUCTURAL:
             value = state.getProperties().get(propertyName);
@@ -156,10 +156,10 @@
       switch (scopeType)
       {
          case CONTENT:
-            context.contentStateContext.set(propertyName, propertyValue);
+            context.contentStateContext.set(id, propertyName, propertyValue);
             break;
          case NAVIGATIONAL:
-            context.navigationalStateContext.set(propertyName, propertyValue);
+            context.navigationalStateContext.set(id, propertyName, propertyValue);
             break;
          case STRUCTURAL:
             if (propertyValue instanceof String)

Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/content/ContentStateContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/content/ContentStateContextImpl.java	                        (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/content/ContentStateContextImpl.java	2007-11-28 14:00:49 UTC (rev 9165)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.presentation.impl.model.state.content;
+
+import org.jboss.portal.presentation.model.state.content.ContentStateContext;
+import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.StateException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContentStateContextImpl implements ContentStateContext
+{
+
+   /** . */
+   private final Map<Key, Object> map;
+
+   public ContentStateContextImpl(Map<Key, Object> map)
+   {
+      this.map = map;
+   }
+
+   public ContentStateContextImpl()
+   {
+      this(new HashMap<Key, Object>());
+   }
+
+   public Object get(String objectId, String key) throws IllegalArgumentException
+   {
+      return map.get(new Key(objectId, key));
+   }
+
+   public void set(String objectId, String key, Object contentState) throws StateChangeVetoException, StateException, IllegalArgumentException
+   {
+      map.put(new Key(objectId, key), contentState);
+   }
+
+   private final class Key
+   {
+      /** . */
+      private final String objectId;
+
+      /** . */
+      private final String key;
+
+      private Key(String objectId, String key)
+      {
+         if (objectId == null)
+         {
+            throw new IllegalArgumentException();
+         }
+         if (key == null)
+         {
+            throw new IllegalArgumentException();
+         }
+         this.objectId = objectId;
+         this.key = key;
+      }
+
+      public int hashCode()
+      {
+         return objectId.hashCode() * 43 + key.hashCode();
+      }
+
+      public boolean equals(Object o)
+      {
+         if (o == this)
+         {
+            return true;
+         }
+         if (o instanceof Key)
+         {
+            Key that = (Key)o;
+            return objectId.equals(that.objectId) && key.equals(that.key);
+         }
+         return false;
+      }
+   }
+}

Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java	                        (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java	2007-11-28 14:00:49 UTC (rev 9165)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.presentation.impl.model.state.navigational;
+
+import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.StateException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NavigationalStateContextImpl implements NavigationalStateContext
+{
+
+   /** . */
+   private final Map<Key, Object> map;
+
+   public NavigationalStateContextImpl(Map<Key, Object> map)
+   {
+      this.map = map;
+   }
+
+   public NavigationalStateContextImpl()
+   {
+      this(new HashMap<Key, Object>());
+   }
+
+   public void set(String objectId, String key, Object navigationalState) throws StateChangeVetoException, StateException, IllegalArgumentException
+   {
+      map.put(new Key(objectId, key), navigationalState);
+   }
+
+   public Object get(String objectId, String key) throws IllegalArgumentException
+   {
+      return map.get(new Key(objectId, key));
+   }
+
+   private final class Key
+   {
+      /** . */
+      private final String objectId;
+
+      /** . */
+      private final String key;
+
+      private Key(String objectId, String key)
+      {
+         if (objectId == null)
+         {
+            throw new IllegalArgumentException();
+         }
+         if (key == null)
+         {
+            throw new IllegalArgumentException();
+         }
+         this.objectId = objectId;
+         this.key = key;
+      }
+
+      public int hashCode()
+      {
+         return objectId.hashCode() * 43 + key.hashCode();
+      }
+
+      public boolean equals(Object o)
+      {
+         if (o == this)
+         {
+            return true;
+         }
+         if (o instanceof Key)
+         {
+            Key that = (Key)o;
+            return objectId.equals(that.objectId) && key.equals(that.key);
+         }
+         return false;
+      }
+   }
+}
\ No newline at end of file

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/ContentStateContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/ContentStateContext.java	2007-11-28 13:46:43 UTC (rev 9164)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/ContentStateContext.java	2007-11-28 14:00:49 UTC (rev 9165)
@@ -22,12 +22,17 @@
  ******************************************************************************/
 package org.jboss.portal.presentation.model.state.content;
 
+import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.StateException;
+
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision: 630 $
  */
 public interface ContentStateContext
 {
-   void set(String key, Object contentState);
-   Object get(String key);
+
+   Object get(String objectId, String key) throws IllegalArgumentException;
+
+   void set(String objectId, String key, Object contentState) throws StateChangeVetoException, StateException, IllegalArgumentException;
 }

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java	2007-11-28 13:46:43 UTC (rev 9164)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java	2007-11-28 14:00:49 UTC (rev 9165)
@@ -22,12 +22,16 @@
  ******************************************************************************/
 package org.jboss.portal.presentation.model.state.navigational;
 
+import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.StateException;
+
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision: 630 $
  */
 public interface NavigationalStateContext
 {
-   void set(String key, Object navigationalState);
-   Object get(String key);
+   Object get(String objectId, String key) throws IllegalArgumentException;
+
+   void set(String objectId, String key, Object navigationalState) throws StateChangeVetoException, StateException, IllegalArgumentException;
 }




More information about the portal-commits mailing list