Deprecated methods should go in the compatibility aspect.
tmortagne (SVN) wrote:
Author: tmortagne
Date: 2008-10-15 15:15:33 +0200 (Wed, 15 Oct 2008)
New Revision: 13575
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
Log:
XWIKI-2741: Add a CacheManager component based on configuration component to get default
cache and local cache hint
* modify XWiki#getFatory and XWiki#getLocalFactory to use CacheManager component
Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java 2008-10-15
13:09:38 UTC (rev 13574)
+++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java 2008-10-15
13:15:33 UTC (rev 13575)
@@ -81,12 +81,15 @@
import org.xwiki.cache.Cache;
import org.xwiki.cache.CacheException;
import org.xwiki.cache.CacheFactory;
+import org.xwiki.cache.CacheManager;
import org.xwiki.cache.config.CacheConfiguration;
import org.xwiki.cache.eviction.LRUEvictionConfiguration;
+import org.xwiki.component.manager.ComponentLookupException;
import org.xwiki.observation.ObservationManager;
import org.xwiki.observation.event.DocumentDeleteEvent;
import org.xwiki.observation.event.DocumentSaveEvent;
import org.xwiki.observation.event.DocumentUpdateEvent;
+import org.xwiki.query.QueryException;
import com.xpn.xwiki.api.Api;
import com.xpn.xwiki.api.Document;
@@ -158,7 +161,6 @@
import com.xpn.xwiki.web.XWikiURLFactoryService;
import com.xpn.xwiki.web.XWikiURLFactoryServiceImpl;
import com.xpn.xwiki.web.includeservletasstring.IncludeServletAsString;
-import org.xwiki.query.QueryException;
public class XWiki implements XWikiDocChangeNotificationInterface
{
@@ -5161,23 +5163,53 @@
/**
* @return the cache factory.
* @since 1.5M2.
+ * @deprecated Since 1.7M1, use {@link CacheManager} component instead using {@link
Utils#getComponent(String)}.
*/
+ @Deprecated
public CacheFactory getCacheFactory()
{
- String cacheHint = Param("xwiki.cache.cachefactory.hint",
"jbosscache");
+ CacheFactory cacheFactory;
- return (CacheFactory) Utils.getComponent(CacheFactory.ROLE, cacheHint);
+ String cacheHint = Param("xwiki.cache.cachefactory.hint", null);
+
+ if (cacheHint == null) {
+ CacheManager cacheManager = (CacheManager)
Utils.getComponent(CacheManager.ROLE, "default");
+ try {
+ cacheFactory = cacheManager.getCacheFactory();
+ } catch (ComponentLookupException e) {
+ throw new RuntimeException("Failed to get cache factory
component", e);
+ }
+ } else {
+ cacheFactory = (CacheFactory) Utils.getComponent(CacheFactory.ROLE,
cacheHint);
+ }
+
+ return cacheFactory;
}
/**
* @return the cache factory creating local caches.
* @since 1.5M2.
+ * @deprecated Since 1.7M1, use {@link CacheManager} component instead using {@link
Utils#getComponent(String)}.
*/
+ @Deprecated
public CacheFactory getLocalCacheFactory()
{
- String localCacheHint = Param("xwiki.cache.cachefactory.local.hint",
"jbosscache/local");
+ CacheFactory localCacheFactory;
- return (CacheFactory) Utils.getComponent(CacheFactory.ROLE, localCacheHint);
+ String localCacheHint = Param("xwiki.cache.cachefactory.local.hint",
null);
+
+ if ((CacheFactory) Utils.getComponent(CacheFactory.ROLE, localCacheHint) ==
null) {
+ CacheManager cacheManager = (CacheManager)
Utils.getComponent(CacheManager.ROLE, "default");
+ try {
+ localCacheFactory = cacheManager.getLocalCacheFactory();
+ } catch (ComponentLookupException e) {
+ throw new RuntimeException("Failed to get local cache factory
component", e);
+ }
+ } else {
+ localCacheFactory = (CacheFactory) Utils.getComponent(CacheFactory.ROLE,
localCacheHint);
+ }
+
+ return localCacheFactory;
}
public int getHttpTimeout(XWikiContext context)
--
Sergiu Dumitriu
http://purl.org/net/sergiu/