Author: julien(a)jboss.com
Date: 2007-11-15 11:35:04 -0500 (Thu, 15 Nov 2007)
New Revision: 8951
Modified:
branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/PageObject.java
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/RegionObject.java
Log:
udpate 2.6 to updates in common/web/portlet
Modified: branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2007-11-15 16:30:05 UTC
(rev 8950)
+++ branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2007-11-15 16:35:04 UTC
(rev 8951)
@@ -48,7 +48,7 @@
-->
<componentref name="jboss-portal/modules/common"
version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/web"
version="1.0.0"/>
+ <componentref name="jboss-portal/modules/web"
version="trunk-SNAPSHOT"/>
<componentref name="jboss-portal/modules/test"
version="1.0-SNAPSHOT"/>
<componentref name="jboss-portal/modules/portlet"
version="1.0-SNAPSHOT"/>
<componentref name="jboss-portal/modules/identity"
version="1.0.0"/>
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java 2007-11-15
16:30:05 UTC (rev 8950)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletState.java 2007-11-15
16:35:04 UTC (rev 8951)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.impl.portlet.state;
import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.util.TypedMap;
import org.jboss.portal.portlet.state.AbstractPropertyMap;
import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.portlet.state.producer.PortletState;
@@ -195,21 +196,50 @@
{
if (ctx == null)
{
- PropertyMap props = new AbstractPropertyMap(entries)
- {
- protected Object getInternalValue(Object value)
- {
- throw new IllegalArgumentException("Immutable");
- }
-
- protected Object getExternalValue(Object value)
- {
- PersistentPortletStateEntry entry = (PersistentPortletStateEntry)value;
- return entry.getValue();
- }
- };
+ PropertyMap props = new AbstractPropertyMap(entries, KEY_CONVERTER,
VALUE_CONVERTER);
ctx = new PortletState(portletId, props);
}
return ctx;
}
+
+ private static final TypedMap.Converter KEY_CONVERTER = new TypedMap.Converter()
+ {
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
+ {
+ if (!(o instanceof String))
+ {
+ throw new ClassCastException("Was expecting an instanceof " +
String.class.getName() + " but was " + o.getClass().getName());
+ }
+ return o;
+ }
+ protected Object getExternal(Object o)
+ {
+ if (!(o instanceof String))
+ {
+ throw new ClassCastException("Was expecting an instanceof " +
String.class.getName() + " but was " + o.getClass().getName());
+ }
+ return o;
+ }
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
+
+ private static TypedMap.Converter VALUE_CONVERTER = new TypedMap.Converter()
+ {
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
+ {
+ throw new IllegalArgumentException("Immutable");
+ }
+ protected Object getExternal(Object o)
+ {
+ return ((PersistentPortletStateEntry)o).getValue();
+ }
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
+
}
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java 2007-11-15
16:30:05 UTC (rev 8950)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java 2007-11-15
16:35:04 UTC (rev 8951)
@@ -33,6 +33,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -64,7 +65,7 @@
this.persistentHandle = null;
this.relatedConsumer = null;
this.persistentStatus = null;
- this.persistentProperties = null;
+ this.persistentProperties = new HashMap();
this.properties = new Properties();
this.relatedPortletStates = null;
}
@@ -248,32 +249,55 @@
// ***********
- /** Implement registration properties semantics, mostly validation and equality. */
- public class Properties extends TypedMap
+ private static final TypedMap.Converter KEY_CONVERTER = new TypedMap.Converter()
{
-
- public Properties()
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
{
- super(persistentProperties);
- }
-
- protected void assertKeyValidity(Object key) throws ClassCastException
- {
- if (key instanceof QName == false)
+ if (o instanceof QName == false)
{
throw new ClassCastException();
}
+ return o;
}
+ protected Object getExternal(Object o)
+ {
+ return o;
+ }
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
- protected Object getInternalValue(Object value) throws ClassCastException
+ private static final TypedMap.Converter VALUE_CONVERTER = new TypedMap.Converter()
+ {
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
{
- if (value instanceof String == false)
+ if (o instanceof String == false)
{
throw new ClassCastException();
}
- return value;
+ return o;
}
+ protected Object getExternal(Object o)
+ {
+ return o;
+ }
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
+ /** Implement registration properties semantics, mostly validation and equality. */
+ public class Properties extends TypedMap
+ {
+
+ public Properties()
+ {
+ super(persistentProperties, KEY_CONVERTER, VALUE_CONVERTER);
+ }
+
public void setProperty(String propertyName, Object value)
{
if (propertyName == null)
Modified:
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/PageObject.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/PageObject.java 2007-11-15
16:30:05 UTC (rev 8950)
+++
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/PageObject.java 2007-11-15
16:35:04 UTC (rev 8951)
@@ -109,18 +109,46 @@
return rendererContext;
}
+ private static final TypedMap.Converter REGION_CONVERTER = new TypedMap.Converter()
+ {
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
+ {
+ throw new IllegalArgumentException("read only");
+ }
+
+ protected Object getExternal(Object o)
+ {
+ RegionObject region = (RegionObject)o;
+ return region.getRendererContext();
+ }
+
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
+
+ private static final TypedMap.Converter TRIVIAL_CONVERTER = new TypedMap.Converter()
+ {
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
+ {
+ return o;
+ }
+ protected Object getExternal(Object o)
+ {
+ return o;
+ }
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
+
private PageRendererContext rendererContext = new PageRendererContext()
{
public Collection getRegions()
{
- return new TypedMap(regions)
- {
- protected Object getExternalValue(Object value)
- {
- RegionObject region = (RegionObject)value;
- return region.getRendererContext();
- }
- }.values();
+ return new TypedMap(regions, TRIVIAL_CONVERTER, REGION_CONVERTER).values();
}
public RegionRendererContext getRegion(String regionName)
Modified:
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/RegionObject.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/RegionObject.java 2007-11-15
16:30:05 UTC (rev 8950)
+++
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/test/theme/model/RegionObject.java 2007-11-15
16:35:04 UTC (rev 8951)
@@ -97,6 +97,41 @@
return rendererContext;
}
+ private static final TypedMap.Converter WINDOW_CONVERTER = new TypedMap.Converter()
+ {
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
+ {
+ throw new IllegalArgumentException("read only");
+ }
+
+ protected Object getExternal(Object o)
+ {
+ WindowObject window = (WindowObject)o;
+ return window.getRendererContext();
+ }
+
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
+
+ private static final TypedMap.Converter TRIVIAL_CONVERTER = new TypedMap.Converter()
+ {
+ protected Object getInternal(Object o) throws IllegalArgumentException,
ClassCastException
+ {
+ return o;
+ }
+ protected Object getExternal(Object o)
+ {
+ return o;
+ }
+ protected boolean equals(Object o, Object o1)
+ {
+ return o.equals(o1);
+ }
+ };
+
private RegionRendererContext rendererContext = new RegionRendererContext()
{
public String getId()
@@ -106,14 +141,7 @@
public Collection getWindows()
{
- return new TypedMap(windows)
- {
- protected Object getExternalValue(Object value)
- {
- WindowObject window = (WindowObject)value;
- return window.getRendererContext();
- }
- }.values();
+ return new TypedMap(windows, TRIVIAL_CONVERTER, WINDOW_CONVERTER).values();
}
public Orientation getOrientation()