svn commit: r618820 - in /lenya/trunk/src/java/org/apache/lenya/cms/cocoon: components/modules/input/ source/

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Tue Feb  5 15:26:28 2008
New Revision: 618820

URL: http://svn.apache.org/viewvc?rev=618820&view=rev
Log:
Delegate logic from FallbackModule to source factory, leverage source URI caching in module.

Removed:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PublicationFallbackModule.java
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PublicationTemplateFallbackModule.java
Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java?rev=618820&r1=618819&r2=618820&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingFallbackSourceFactory.java Tue Feb  5 15:26:28 2008
@@ -53,7 +53,7 @@
 
         if (useCache()) {
             MRUMemoryStore store = getStore();
-            final String cacheKey = getCacheKey(location);
+            final String cacheKey = getCacheKey(getPublicationId(), location);
             final String[] cachedUris = (String[]) store.get(cacheKey);
             if (cachedUris == null) {
                 uris = findUris(location, parameters);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java?rev=618820&r1=618819&r2=618820&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java Tue Feb  5 15:26:28 2008
@@ -65,7 +65,7 @@
     protected static MRUMemoryStore store;
     private static Boolean useCache = null;
 
-    protected static final String STORE_ROLE = FallbackSourceFactory.class.getName() + "Store";
+    public static final String STORE_ROLE = FallbackSourceFactory.class.getName() + "Store";
 
     protected boolean useCache() {
         if (useCache == null) {
@@ -95,7 +95,8 @@
 
         if (useCache()) {
             MRUMemoryStore store = getStore();
-            final String cacheKey = getCacheKey(location);
+            final String pubId = getPublicationId();
+            final String cacheKey = getCacheKey(pubId, location);
             final String cachedSourceUri = (String) store.get(cacheKey);
 
             if (cachedSourceUri == null) {
@@ -132,9 +133,13 @@
         return source;
     }
 
-    protected String getCacheKey(final String location) {
-        String pubId = getPublicationId();
-        String cacheKey = pubId == null ? location : pubId + ":" + location;
+    /**
+     * @param pubId The publication ID.
+     * @param fallbackUri The fallback:// (or template-fallback:// etc.) URI.
+     * @return A string.
+     */
+    public static String getCacheKey(final String pubId, final String fallbackUri) {
+        String cacheKey = pubId == null ? fallbackUri : pubId + ":" + fallbackUri;
         return cacheKey;
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.