use of com.xpn.xwiki.store.XWikiCacheStoreInterface in project xwiki-platform by xwiki.
the class XWiki method flushCache.
public void flushCache(XWikiContext context) {
// We need to flush the virtual wiki list
this.initializedWikis = new ConcurrentHashMap<>();
// We need to flush the group service cache
if (this.groupService != null) {
this.groupService.flushCache();
}
// If we use the Cache Store layer.. we need to flush it
XWikiStoreInterface store = getStore();
if ((store != null) && (store instanceof XWikiCacheStoreInterface)) {
((XWikiCacheStoreInterface) getStore()).flushCache();
}
// Flush renderers.. Groovy renderer has a cache
getOldRendering().flushCache();
getParseGroovyFromString().flushCache();
XWikiPluginManager pmanager = getPluginManager();
if (pmanager != null) {
pmanager.flushCache(context);
}
// Make sure we call all classes flushCache function
try {
List<String> classes = getClassList(context);
for (int i = 0; i < classes.size(); i++) {
String className = classes.get(i);
try {
getClass(className, context).flushCache();
} catch (Exception e) {
}
}
} catch (Exception e) {
}
}
use of com.xpn.xwiki.store.XWikiCacheStoreInterface in project xwiki-platform by xwiki.
the class DatabasePingDataProvider method getDatabaseMetaData.
private DatabaseMetaData getDatabaseMetaData() {
DatabaseMetaData metaData = null;
XWikiContext xcontext = (XWikiContext) this.execution.getContext().getProperty(XWikiContext.EXECUTIONCONTEXT_KEY);
if (xcontext != null) {
XWikiStoreInterface storeInterface = xcontext.getWiki().getStore();
if (storeInterface instanceof XWikiCacheStoreInterface) {
storeInterface = ((XWikiCacheStoreInterface) storeInterface).getStore();
}
if (XWikiHibernateBaseStore.class.isAssignableFrom(storeInterface.getClass())) {
XWikiHibernateBaseStore baseStore = (XWikiHibernateBaseStore) storeInterface;
metaData = baseStore.getDatabaseMetaData();
}
}
return metaData;
}
use of com.xpn.xwiki.store.XWikiCacheStoreInterface in project xwiki-platform by xwiki.
the class DatabasePingDataProviderTest method provideData.
@Test
public void provideData() throws Exception {
Execution execution = this.mocker.getInstance(Execution.class);
ExecutionContext executionContext = mock(ExecutionContext.class);
when(execution.getContext()).thenReturn(executionContext);
XWikiContext xwikiContext = mock(XWikiContext.class);
when(executionContext.getProperty(XWikiContext.EXECUTIONCONTEXT_KEY)).thenReturn(xwikiContext);
com.xpn.xwiki.XWiki xwiki = mock(com.xpn.xwiki.XWiki.class);
when(xwikiContext.getWiki()).thenReturn(xwiki);
XWikiCacheStoreInterface cacheStore = mock(XWikiCacheStoreInterface.class);
when(xwiki.getStore()).thenReturn(cacheStore);
XWikiHibernateStore store = mock(XWikiHibernateStore.class);
when(cacheStore.getStore()).thenReturn(store);
DatabaseMetaData databaseMetaData = mock(DatabaseMetaData.class);
when(store.getDatabaseMetaData()).thenReturn(databaseMetaData);
when(databaseMetaData.getDatabaseProductName()).thenReturn("HSQL Database Engine");
when(databaseMetaData.getDatabaseProductVersion()).thenReturn("2.2.9");
Map<String, Object> data = this.mocker.getComponentUnderTest().provideData();
assertEquals(2, data.size());
assertEquals("HSQL Database Engine", data.get("dbName"));
assertEquals("2.2.9", data.get("dbVersion"));
}
use of com.xpn.xwiki.store.XWikiCacheStoreInterface in project xwiki-platform by xwiki.
the class XWiki method initializeStores.
private void initializeStores() throws ComponentLookupException {
XWikiStoreInterface mainStore = getStoreConfiguration().getXWikiStore();
// Check if we need to use the cache store..
if (getStoreConfiguration().isStoreCacheEnabled()) {
XWikiCacheStoreInterface cachestore = (XWikiCacheStoreInterface) Utils.getComponent(XWikiStoreInterface.class, "cache");
cachestore.setStore(mainStore);
setStore(cachestore);
} else {
setStore(mainStore);
}
setDefaultAttachmentContentStore(getStoreConfiguration().getXWikiAttachmentStore());
setVersioningStore(getStoreConfiguration().getXWikiVersioningStore());
setDefaultAttachmentArchiveStore(getStoreConfiguration().getAttachmentVersioningStore());
setRecycleBinStore(getStoreConfiguration().getXWikiRecycleBinStore());
setAttachmentRecycleBinStore(getStoreConfiguration().getAttachmentRecycleBinStore());
}
Aggregations