taylor 2002/09/18 18:24:13
Modified: src/java/org/apache/jetspeed/modules/actions/portlets
PsmlBrowseAction.java
src/java/org/apache/jetspeed/services/psmlmanager/db
DatabasePsmlManagerService.java
webapp/WEB-INF/conf JetspeedResources.properties
Log:
Added PsmlManager.caching-on property to Jrp. It is used by
DatabasePsmlManagerService to enable caching.
Removed code to read in data for psml browser from the session, as this action is
not tied into the creation/deletion of roles/users etc. Hence the psml entries are
invalid in the earlier stated circumstances. Now this action executes the query each
time buildNormalContext is called.
Revision Changes Path
1.7 +6 -4
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlBrowseAction.java
Index: PsmlBrowseAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlBrowseAction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PsmlBrowseAction.java 12 Aug 2002 02:04:55 -0000 1.6
+++ PsmlBrowseAction.java 19 Sep 2002 01:24:13 -0000 1.7
@@ -136,12 +136,14 @@
//check to see if resultset has changed due to PsmlUpdateAction
//if so reconstruct the iterator and rest the flag
+ /*
boolean refreshFlag = (rundata.getUser().getTemp(PSML_REFRESH_FLAG,
FALSE)).equals(TRUE);
rundata.getUser().setTemp(PSML_REFRESH_FLAG, FALSE);
+ */
//Get the iterator
DatabaseBrowserIterator windowIterator =
(DatabaseBrowserIterator) PortletSessionState.getAttribute(portlet,
rundata, PROFILE_ITERATOR);
- if ((windowIterator == null) || refreshFlag)
+ //if ((windowIterator == null) || refreshFlag)
{
int index = 0;
Iterator i = Profiler.query(new QueryLocator(QueryLocator.QUERY_ALL));
@@ -157,12 +159,12 @@
entryType.add("Profile");
windowIterator = new DatabaseBrowserIterator(entries, entryType,
entryType, size);
PortletSessionState.setAttribute(portlet, rundata, PROFILE_ITERATOR,
windowIterator);
- }
+ }/*
else
{
windowIterator.setTop(start);
}
-
+ */
if (windowIterator != null)
{
1.23 +59 -33
jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/db/DatabasePsmlManagerService.java
Index: DatabasePsmlManagerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/db/DatabasePsmlManagerService.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- DatabasePsmlManagerService.java 12 Sep 2002 13:38:05 -0000 1.22
+++ DatabasePsmlManagerService.java 19 Sep 2002 01:24:13 -0000 1.23
@@ -159,6 +159,12 @@
private final static String REFRESH_RATE = "refresh-rate";
private final static long DEFAULT_REFRESH_RATE = 60 * 60 * 8 * 1000; //8hrs
+ /** whether caching is allowed */
+ private boolean cachingOn; // default will be false
+
+ private final static String CACHING_ON = "caching-on";
+ private final static boolean DEFAULT_CACHING_ON = false;
+
private final static String POOL_NAME = "database";
/** the import/export consumer service **/
@@ -214,6 +220,8 @@
poolName = serviceConf.getString(POOL_NAME);
// new DatabaseInitializer(this, conf, serviceConf);
+ //find out if caching allowed
+ cachingOn = serviceConf.getBoolean(CACHING_ON, DEFAULT_CACHING_ON);
// psml castor mapping file
mapFile = serviceConf.getString("mapping",DEFAULT_MAPPING);
@@ -226,8 +234,11 @@
throw new InitializationException("Missing default refresh rate
parameter, during initializing DatabasePsmlManagerService, using defaults");
}
- this.refresher = new CacheRefresher();
- refresher.start();
+ if (cachingOn)
+ {
+ this.refresher = new CacheRefresher();
+ refresher.start();
+ }
}
@@ -524,28 +535,31 @@
String locStr = locatorToString(locator);
boolean inCache = false;
- synchronized (psmlCache)
+ if (cachingOn)
{
- // psmldoc = (PSMLDocument)psmlCache.get(locatorToString(locator));
- // if we have seached and found nothing, this is cached as a null value
- // so check to see if the key is there
- inCache = psmlCache.containsKey(locStr);
- if (inCache)
+ synchronized (psmlCache)
{
- psmldoc = (PSMLDocument)psmlCache.get(locStr);
- }
- }
+ // psmldoc = (PSMLDocument)psmlCache.get(locatorToString(locator));
+ // if we have seached and found nothing, this is cached as a null
value
+ // so check to see if the key is there
+ inCache = psmlCache.containsKey(locStr);
+ if (inCache)
+ {
+ psmldoc = (PSMLDocument)psmlCache.get(locStr);
+ }
+ }
// if (Log.getLogger().isDebugEnabled())
// Log.info("DatabasePsmlManagerService.getDocument(): psmlcache: " +
// (inCache ? ((psmldoc == null) ? "null present" : "doc present") :
"not in cache") + " : " + locStr);
-
- // if in the cache, doc or null, return what's in the cache
- if (inCache)
- {
- return psmldoc;
+ // if in the cache, doc or null, return what's in the cache
+ if (inCache)
+ {
+ return psmldoc;
+ }
}
+
try
{
return refresh(locator);
@@ -637,12 +651,15 @@
}
}
- // insert successful
- synchronized (psmlCache)
+ if (cachingOn)
{
- if (Log.getLogger().isDebugEnabled())
- Log.debug("DatabasePsmlManagerService.createOrSaveDocument:
caching document: profile: " + locatorToString(profile));
- psmlCache.put(locatorToString(profile), profile.getDocument());
+ // insert successful
+ synchronized (psmlCache)
+ {
+ if (Log.getLogger().isDebugEnabled())
+ Log.debug("DatabasePsmlManagerService.createOrSaveDocument:
caching document: profile: " + locatorToString(profile));
+ psmlCache.put(locatorToString(profile), profile.getDocument());
+ }
}
return profile.getDocument();
@@ -701,10 +718,13 @@
tableName = "JETSPEED_GROUP_PROFILE";
}
- // Delete successful
- synchronized (psmlCache)
+ if (cachingOn)
{
- psmlCache.remove(locatorToString(locator));
+ // Delete successful
+ synchronized (psmlCache)
+ {
+ psmlCache.remove(locatorToString(locator));
+ }
}
}
catch (Exception e) // insert failed
@@ -969,20 +989,26 @@
if (page != null && portlets != null)
{
psmldoc = getPSMLDocument(page, portlets);
- synchronized (psmlCache)
+ if (cachingOn)
{
- if (Log.getLogger().isDebugEnabled())
- Log.debug("DatabasePsmlManagerService.refresh: caching
document: profile: " + locatorToString(locator));
- psmlCache.put(locatorToString(locator), psmldoc);
+ synchronized (psmlCache)
+ {
+ if (Log.getLogger().isDebugEnabled())
+ Log.debug("DatabasePsmlManagerService.refresh: caching
document: profile: " + locatorToString(locator));
+ psmlCache.put(locatorToString(locator), psmldoc);
+ }
}
return psmldoc;
}
else
{
- // cache the fact that there is NO document matching this profile
- psmlCache.put(locatorToString(locator), null);
- if (Log.getLogger().isDebugEnabled())
- Log.debug("DatabasePsmlManagerService.refresh: caching
'document not found': profile: " + locatorToString(locator));
+ if (cachingOn)
+ {
+ // cache the fact that there is NO document matching this
profile
+ psmlCache.put(locatorToString(locator), null);
+ if (Log.getLogger().isDebugEnabled())
+ Log.debug("DatabasePsmlManagerService.refresh: caching
'document not found': profile: " + locatorToString(locator));
+ }
}
}
catch (Exception e)
1.90 +5 -1
jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
Index: JetspeedResources.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- JetspeedResources.properties 17 Sep 2002 20:11:54 -0000 1.89
+++ JetspeedResources.properties 19 Sep 2002 01:24:13 -0000 1.90
@@ -348,6 +348,10 @@
services.PsmlManager.root=/WEB-INF/psml
services.PsmlManager.ext=.psml
services.PsmlManager.mapping=/WEB-INF/conf/psml-mapping.xml
+#The following property is used for DatabasePsmlManagerService only. The default is
false that is caching is
+#not allowed with DatabasePsmlManagerService, as the current implementation of
caching does not work on a
+#distributed environment. It works only in a single server environment.
+services.PsmlManager.caching-on=false
#services.PsmlManager.default-resource=default.psml
#services.PsmlManager.media-types=html:wml
#services.PsmlManager.admin=admin
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>