[jboss-cvs] jboss-portal/portlet/src/main/org/jboss/portal/portlet/state ...
Julien Viet
julien at jboss.com
Sun Jul 30 08:36:23 EDT 2006
User: julien
Date: 06/07/30 08:36:23
Modified: portlet/src/main/org/jboss/portal/portlet/state
AbstractPropertyContext.java PropertyContext.java
Log:
JBPORTAL-973 : Portlet instance container integration testing
JBPORTAL-972 : Portlet stateful invoker testing
Revision Changes Path
1.3 +26 -15 jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractPropertyContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- AbstractPropertyContext.java 1 May 2006 20:44:32 -0000 1.2
+++ AbstractPropertyContext.java 30 Jul 2006 12:36:23 -0000 1.3
@@ -32,11 +32,20 @@
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class AbstractPropertyContext implements PropertyContext
{
+ /** No change have been done or attempted. */
+ public static final int NO_CHANGE = 0;
+
+ /** Attempts to update the state that failed has been performed. */
+ public static final int UPDATE_FAILED = 1;
+
+ /** The state has been succesfully updated. */
+ public static final int UPDATE_SUCCEDED = 2;
+
/** The user prefs. */
private ValueMap prefs;
@@ -46,8 +55,8 @@
/** The access mode. */
private AccessMode access;
- /** True if state change occured. */
- private boolean changed;
+ /** State change status. */
+ private int status;
/**
* Create a new object. If the userPrefs argument is null then the object is considered
@@ -70,27 +79,29 @@
this.access = access;
this.prefs = userPrefs;
this.portletPrefs = portletPrefs;
- this.changed = false;
+ this.status = NO_CHANGE;
}
public void update(PropertyChange[] changes) throws IllegalStateException
{
if (access == AccessMode.READ_ONLY)
{
+ status = UPDATE_FAILED;
throw new IllegalStateException("Cannot update when read only");
}
if (changes.length > 0)
{
- if (access == AccessMode.CLONE_BEFORE_WRITE && !changed && prefs != null)
+ if (status == NO_CHANGE)
{
- prefs = new SimpleValueMap(prefs);
- }
-
- //
if (prefs == null)
{
prefs = new SimpleValueMap();
}
+ else
+ {
+ prefs = new SimpleValueMap(prefs);
+ }
+ }
//
for (int i = 0; i < changes.length; i++)
@@ -98,7 +109,7 @@
PropertyChange change = changes[i];
prefs.setValue(change.getKey(), change.getValue());
}
- changed = true;
+ status = UPDATE_SUCCEDED;
}
}
@@ -155,8 +166,8 @@
return prefs;
}
- public boolean isChanged()
+ public int getStatus()
{
- return changed;
+ return status;
}
}
1.2 +3 -3 jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PropertyContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PropertyContext.java 20 Apr 2006 12:56:47 -0000 1.1
+++ PropertyContext.java 30 Jul 2006 12:36:23 -0000 1.2
@@ -30,7 +30,7 @@
* Exposes to the portlet the interface to deal with the personalization state.
*
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public interface PropertyContext
{
@@ -60,8 +60,8 @@
/**
* Update the preferences.
*
- * @throws IllegalStateException if the preferences is not clonable
- * @throws IllegalArgumentException if the changes is not valid
+ * @throws IllegalStateException if the preferences is not writable
+ * @throws IllegalArgumentException if any change is not valid
*/
void update(PropertyChange[] changes) throws IllegalStateException;
More information about the jboss-cvs-commits
mailing list