Author: julien_viet
Date: 2009-10-24 11:08:58 -0400 (Sat, 24 Oct 2009)
New Revision: 419
Modified:
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
Log:
cache portlet preferences access
Modified:
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java
===================================================================
---
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java 2009-10-24
14:00:56 UTC (rev 418)
+++
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/config/model/PersistentApplicationState.java 2009-10-24
15:08:58 UTC (rev 419)
@@ -19,13 +19,15 @@
package org.exoplatform.portal.config.model;
+import java.io.Serializable;
+
/**
* Represents the state of the application when it is bound to the database.
*
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class PersistentApplicationState<S> extends ApplicationState<S>
+public class PersistentApplicationState<S> extends ApplicationState<S>
implements Serializable
{
/** The id of the content state. */
Modified:
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
===================================================================
---
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java 2009-10-24
14:00:56 UTC (rev 418)
+++
portal/branches/performance/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java 2009-10-24
15:08:58 UTC (rev 419)
@@ -22,6 +22,8 @@
import org.exoplatform.portal.config.model.PersistentApplicationState;
import org.exoplatform.portal.pom.config.AbstractPOMTask;
import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.cache.CacheableDataTask;
+import org.exoplatform.portal.pom.config.cache.DataAccessMode;
import org.gatein.mop.api.content.Customization;
/**
@@ -31,7 +33,10 @@
public abstract class PreferencesTask<S> extends AbstractPOMTask
{
- public static class Load<S> extends PreferencesTask<S>
+ /** . */
+ private static final Object NULL_PREFS = new Object();
+
+ public static class Load<S> extends PreferencesTask<S> implements
CacheableDataTask<PersistentApplicationState<S>, Object>
{
/** . */
@@ -40,11 +45,39 @@
/** . */
private S prefs;
- public Load(PersistentApplicationState state)
+ public Load(PersistentApplicationState<S> state)
{
this.state = state;
}
+ public DataAccessMode getAccessMode()
+ {
+ return DataAccessMode.READ;
+ }
+
+ public void setValue(Object value)
+ {
+ if (value != NULL_PREFS)
+ {
+ prefs = (S)value;
+ }
+ }
+
+ public Class<Object> getValueType()
+ {
+ return Object.class;
+ }
+
+ public Object getValue()
+ {
+ return prefs == null ? NULL_PREFS : prefs;
+ }
+
+ public PersistentApplicationState<S> getKey()
+ {
+ return state;
+ }
+
public void run(POMSession session) throws Exception
{
String id = state.getStorageId();
@@ -64,7 +97,7 @@
}
}
- public static class Save<S> extends PreferencesTask<S>
+ public static class Save<S> extends PreferencesTask<S> implements
CacheableDataTask<PersistentApplicationState<S>, Object>
{
/** . */
@@ -79,6 +112,31 @@
this.prefs = prefs;
}
+ public DataAccessMode getAccessMode()
+ {
+ return DataAccessMode.WRITE;
+ }
+
+ public void setValue(Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class<Object> getValueType()
+ {
+ return Object.class;
+ }
+
+ public Object getValue()
+ {
+ return prefs == null ? NULL_PREFS : prefs;
+ }
+
+ public PersistentApplicationState<S> getKey()
+ {
+ return state;
+ }
+
public void run(POMSession session) throws Exception
{
Show replies by date