You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by me...@apache.org on 2016/04/17 15:19:26 UTC
svn commit: r1739605 - in /jspwiki/trunk: ChangeLog
jspwiki-war/src/main/java/org/apache/wiki/Release.java
jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java
Author: metskem
Date: Sun Apr 17 13:19:25 2016
New Revision: 1739605
URL: http://svn.apache.org/viewvc?rev=1739605&view=rev
Log:
2.10.3-svn-10
* Fixed JSPWIKI-935 RenderingManager uses ehcache if "jspwiki.usePageCache = false"
Modified:
jspwiki/trunk/ChangeLog
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java
Modified: jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/jspwiki/trunk/ChangeLog?rev=1739605&r1=1739604&r2=1739605&view=diff
==============================================================================
--- jspwiki/trunk/ChangeLog (original)
+++ jspwiki/trunk/ChangeLog Sun Apr 17 13:19:25 2016
@@ -1,3 +1,9 @@
+2016-04-17 Harry Metske (metskem@apache.org)
+
+ * 2.10.3-svn-10
+
+ * Fixed JSPWIKI-935 RenderingManager uses ehcache if "jspwiki.usePageCache = false"
+
2016-04-06 Dirk Frederickx (brushed AT apache DOT org)
* 2.10.3-svn-9 Few fixes on the HADDOCK template
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java?rev=1739605&r1=1739604&r2=1739605&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java Sun Apr 17 13:19:25 2016
@@ -72,7 +72,7 @@ public final class Release {
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "9";
+ public static final String BUILD = "10";
/**
* This is the generic version string you should use when printing out the version. It is of
Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java?rev=1739605&r1=1739604&r2=1739605&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java Sun Apr 17 13:19:25 2016
@@ -30,6 +30,7 @@ import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import org.apache.log4j.Logger;
+import org.apache.wiki.PageManager;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.api.exceptions.WikiException;
@@ -63,6 +64,8 @@ public class RenderingManager implements
private WikiEngine m_engine;
+ private boolean m_useCache = true;
+
private CacheManager m_cacheManager = CacheManager.getInstance();
/** The capacity of the caches, if you want something else, tweak ehcache.xml. */
@@ -73,13 +76,13 @@ public class RenderingManager implements
/** The name of the default renderer. */
public static final String DEFAULT_PARSER = JSPWikiMarkupParser.class.getName();
-
+
/** The name of the default renderer. */
public static final String DEFAULT_RENDERER = XHTMLRenderer.class.getName();
/** Stores the WikiDocuments that have been cached. */
private Cache m_documentCache;
-
+
/** Name of the regular page cache. */
public static final String DOCUMENTCACHE_NAME = "jspwiki.renderingCache";
@@ -112,7 +115,7 @@ public class RenderingManager implements
throws WikiException
{
m_engine = engine;
-
+
m_markupParserClass = properties.getProperty( PROP_PARSER, DEFAULT_PARSER );
if( !ClassUtil.assignable( m_markupParserClass, MarkupParser.class.getName() ) ) {
log.warn( m_markupParserClass + " does not subclass " + MarkupParser.class.getName() + " reverting to default markup parser." );
@@ -120,18 +123,22 @@ public class RenderingManager implements
}
log.info( "Using " + m_markupParserClass + " as markup parser." );
- String documentCacheName = engine.getApplicationName() + "." + DOCUMENTCACHE_NAME;
+ m_useCache = "true".equals(properties.getProperty(PageManager.PROP_USECACHE));
+
+ if (m_useCache) {
+ String documentCacheName = engine.getApplicationName() + "." + DOCUMENTCACHE_NAME;
- if (m_cacheManager.cacheExists(documentCacheName)) {
- m_documentCache = m_cacheManager.getCache(documentCacheName);
- } else {
- log.info("cache with name " + documentCacheName + " not found in ehcache.xml, creating it with defaults.");
- m_documentCache = new Cache(documentCacheName, DEFAULT_CACHESIZE, false, false, m_cacheExpiryPeriod, m_cacheExpiryPeriod);
- m_cacheManager.addCache(m_documentCache);
+ if (m_cacheManager.cacheExists(documentCacheName)) {
+ m_documentCache = m_cacheManager.getCache(documentCacheName);
+ } else {
+ log.info("cache with name " + documentCacheName + " not found in ehcache.xml, creating it with defaults.");
+ m_documentCache = new Cache(documentCacheName, DEFAULT_CACHESIZE, false, false, m_cacheExpiryPeriod, m_cacheExpiryPeriod);
+ m_cacheManager.addCache(m_documentCache);
+ }
}
String renderImplName = properties.getProperty( PROP_RENDERER, DEFAULT_RENDERER );
-
+
Class< ? >[] rendererParams = { WikiContext.class, WikiDocument.class };
try {
Class< ? > c = Class.forName( renderImplName );
@@ -143,7 +150,7 @@ public class RenderingManager implements
} catch( NoSuchMethodException e ) {
log.error( "Unable to locate the WikiRenderer(WikiContext,WikiDocument) constructor for " + renderImplName );
}
-
+
if( m_rendererConstructor == null ) {
throw new WikiException( "Failed to get WikiRenderer '" + renderImplName + "'." );
}
@@ -177,6 +184,7 @@ public class RenderingManager implements
// FIXME: The cache management policy is not very good: deleted/changed pages should be detected better.
protected WikiDocument getRenderedDocument(WikiContext context, String pagedata) throws IOException {
String pageid = context.getRealPage().getName() + VERSION_DELIMITER + context.getRealPage().getVersion();
+ if (m_useCache) {
Element element = m_documentCache.get(pageid);
if (element != null) {
@@ -192,7 +200,7 @@ public class RenderingManager implements
} else {
if (log.isDebugEnabled()) log.debug("Re-rendering and storing " + pageid);
}
-
+ }
//
// Refresh the data content
//
@@ -201,7 +209,9 @@ public class RenderingManager implements
MarkupParser parser = getParser( context, pagedata );
WikiDocument doc = parser.parse();
doc.setPageData( pagedata );
- m_documentCache.put( new Element(pageid, doc ));
+ if (m_useCache) {
+ m_documentCache.put(new Element(pageid, doc));
+ }
return doc;
}
catch( IOException ex )
@@ -289,28 +299,25 @@ public class RenderingManager implements
* @see org.apache.wiki.event.WikiEventListener#actionPerformed(org.apache.wiki.event.WikiEvent)
* @param event {@inheritDoc}
*/
- public void actionPerformed(WikiEvent event)
- {
- if( (event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.POST_SAVE_BEGIN) )
- {
- if( m_documentCache != null )
- {
- String pageName = ((WikiPageEvent) event).getPageName();
- m_documentCache.remove(pageName);
- Collection referringPages = m_engine.getReferenceManager().findReferrers( pageName );
-
- //
- // Flush also those pages that refer to this page (if an nonexistent page
- // appears; we need to flush the HTML that refers to the now-existent page
- //
- if( referringPages != null )
- {
- Iterator i = referringPages.iterator();
- while (i.hasNext())
- {
- String page = (String) i.next();
- if( log.isDebugEnabled() ) log.debug( "Flushing " + page );
- m_documentCache.remove(page);
+ public void actionPerformed(WikiEvent event) {
+ if (m_useCache) {
+ if ((event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.POST_SAVE_BEGIN)) {
+ if (m_documentCache != null) {
+ String pageName = ((WikiPageEvent) event).getPageName();
+ m_documentCache.remove(pageName);
+ Collection referringPages = m_engine.getReferenceManager().findReferrers(pageName);
+
+ //
+ // Flush also those pages that refer to this page (if an nonexistent page
+ // appears; we need to flush the HTML that refers to the now-existent page
+ //
+ if (referringPages != null) {
+ Iterator i = referringPages.iterator();
+ while (i.hasNext()) {
+ String page = (String) i.next();
+ if (log.isDebugEnabled()) log.debug("Flushing " + page);
+ m_documentCache.remove(page);
+ }
}
}
}