Search in sources :

Example 1 with XWikiCacheStoreInterface

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) {
    }
}
Also used : XWikiCacheStoreInterface(com.xpn.xwiki.store.XWikiCacheStoreInterface) XWikiPluginManager(com.xpn.xwiki.plugin.XWikiPluginManager) ParseGroovyFromString(com.xpn.xwiki.internal.render.groovy.ParseGroovyFromString) IncludeServletAsString(com.xpn.xwiki.web.includeservletasstring.IncludeServletAsString) XWikiStoreInterface(com.xpn.xwiki.store.XWikiStoreInterface) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) IOException(java.io.IOException) JobException(org.xwiki.job.JobException) ParseException(org.xwiki.rendering.parser.ParseException) QueryException(org.xwiki.query.QueryException) URIException(org.apache.commons.httpclient.URIException) InvocationTargetException(java.lang.reflect.InvocationTargetException) HibernateException(org.hibernate.HibernateException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) NamingException(javax.naming.NamingException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException)

Example 2 with XWikiCacheStoreInterface

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;
}
Also used : XWikiCacheStoreInterface(com.xpn.xwiki.store.XWikiCacheStoreInterface) XWikiContext(com.xpn.xwiki.XWikiContext) XWikiHibernateBaseStore(com.xpn.xwiki.store.XWikiHibernateBaseStore) DatabaseMetaData(java.sql.DatabaseMetaData) XWikiStoreInterface(com.xpn.xwiki.store.XWikiStoreInterface)

Example 3 with XWikiCacheStoreInterface

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"));
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) XWikiHibernateStore(com.xpn.xwiki.store.XWikiHibernateStore) XWikiCacheStoreInterface(com.xpn.xwiki.store.XWikiCacheStoreInterface) XWikiContext(com.xpn.xwiki.XWikiContext) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 4 with XWikiCacheStoreInterface

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());
}
Also used : XWikiCacheStoreInterface(com.xpn.xwiki.store.XWikiCacheStoreInterface) XWikiStoreInterface(com.xpn.xwiki.store.XWikiStoreInterface)

Aggregations

XWikiCacheStoreInterface (com.xpn.xwiki.store.XWikiCacheStoreInterface)4 XWikiStoreInterface (com.xpn.xwiki.store.XWikiStoreInterface)3 XWikiContext (com.xpn.xwiki.XWikiContext)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 ParseGroovyFromString (com.xpn.xwiki.internal.render.groovy.ParseGroovyFromString)1 XWikiPluginManager (com.xpn.xwiki.plugin.XWikiPluginManager)1 XWikiHibernateBaseStore (com.xpn.xwiki.store.XWikiHibernateBaseStore)1 XWikiHibernateStore (com.xpn.xwiki.store.XWikiHibernateStore)1 IncludeServletAsString (com.xpn.xwiki.web.includeservletasstring.IncludeServletAsString)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 NamingException (javax.naming.NamingException)1 URIException (org.apache.commons.httpclient.URIException)1 HibernateException (org.hibernate.HibernateException)1 Test (org.junit.Test)1 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 Execution (org.xwiki.context.Execution)1 ExecutionContext (org.xwiki.context.ExecutionContext)1