mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/mward/clustering_p1 to HEAD:
41454: ALF-15881: Disabling clustering in community 41500: ALF-15883: Move configuration files 41503: ALF-15884: Move cluster package to enterprise repository project 41504: ALF-15884: Move cluster package to enterprise repository project 41519: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41523: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41525: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41527: ALF-15886: References/definition for "hazelcastInstanceFactory" must be in enterprise repo only 41530: ALF-15886: remove import for class no longer in project. 41532: ALF-15887: LockStoreFactoryImpl must be separated into community and enterprise versions 41535: ALF-15883: Move configuration files 41561: ALF-15886: factory class to create key fileserver config beans. 41578: ALF-15888: separate transactional and shared cache bean definitions. 41623: ALF-15888: first pass at DefaultSimpleCache implementation. 41646: ALF-15888: move ehcache-default.xml 41651: ALF-15888: update javadoc to reflect changes 41762: ALF-15888: improve cache test to prove that null values are stored correctly. 41812: ALF-15888: added new cache provider for use by hibernate: DefaultCacheProvider. 41830: ALF-15888: make DefaultSimpleCache BeanNameAware to help with debugging etc. 41831: ALF-15888: missing file from commit - adds enterprise override capability for hibernate-cfg.properties 41850: ALF-15888: move tickets cache to cache-context.xml 41857: ALF-15888: make RemoteAlfrescoTicketServiceImpl cache implementation agnostic. 41866: ALF-15888: extract caches from fileservers and web-client and provide enterprise overrides 41881: ALF-15888: replace use of EhCacheAdapter with DefaultSimpleCache and SimpleCache interface. 41884: ALF-15888: added DefaultSimpleCache configuration to CachingContentStore sample XML. 41885: ALF-15888: move EhCacheAdapter to new package. 41886: ALF-15888: correct absolute class names in config for EhCacheAdapter. 41892: ALF-15888: fix CachingContentStore tests. 41897: ALF-15888: move CacheTest and config to new package. 41898: ALF-15888: remove redundant directory 41899: ALF-15889: move EhCacheManagerFactoryBean to new package. 41902: ALF-15889: moved EhCacheTracerJob to new package. 41913: ALF-15889: move InternalEhCacheManagerFactoryBean to new package. 41916: ALF-15889: move AlfrescoCacheManagerPeerProviderFactory to new package. 41937: ALF-15889: decouple TransactionalCache from EhCache 41966: ALF-15889: decouple RetryingTransactionHelper from ehcache. 41989: ALF-15889: added ContextListener test. 41996: ALF-15889: moved cache test to its own class. 41998: ALF-15889: move ehcache jars. 41999: ALF-15889: modify .classpath to reflect jar moves. 42037: ALF-15889: update poms to reflect lib moves. 42038: ALF-15889: add eclipse library reference to enterprise projects. 42093: ALF-15916: moved core properties to enterprise 42114: ALF-15888: externalized cache sizes to repository.properties. 42127: ALF-16136: move re-indexing configuration 42140: ALF-16136: move cluster check property. 42186: ALF-15889: removing seemingly redundant test config file. 42187: ALF-15888: tidy up config changes. 42189: ALF-15888: cleanup config 42190: ALF-15888: config cleanup 42191: ALF-15888: config cleanup 42198: ALF-16136: restored lost property git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42210 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -43,21 +43,11 @@
|
|||||||
|
|
||||||
<!-- The cross-transaction shared cache for in-memory GlobalConfig -->
|
<!-- The cross-transaction shared cache for in-memory GlobalConfig -->
|
||||||
|
|
||||||
<bean name="globalConfigSharedCache" class="org.alfresco.repo.cache.EhCacheAdapter">
|
<!-- TODO: globalConfigShareCache moved into cache-context.xml files,
|
||||||
<property name="cache">
|
may need a way of defining caches alongside related beans as it was previously. -->
|
||||||
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" >
|
|
||||||
<property name="cacheManager">
|
|
||||||
<ref bean="internalEHCacheManager" />
|
|
||||||
</property>
|
|
||||||
<property name="cacheName">
|
|
||||||
<value>org.alfresco.cache.globalConfigCache</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- The transactional cache for in-memory GlobalConfig -->
|
<!-- The transactional cache for in-memory GlobalConfig -->
|
||||||
|
<!-- TODO: should this move to tx-cache-context.xml -->
|
||||||
<bean name="globalConfigCache" class="org.alfresco.repo.cache.TransactionalCache">
|
<bean name="globalConfigCache" class="org.alfresco.repo.cache.TransactionalCache">
|
||||||
<property name="sharedCache">
|
<property name="sharedCache">
|
||||||
<ref bean="globalConfigSharedCache" />
|
<ref bean="globalConfigSharedCache" />
|
||||||
|
@@ -26,7 +26,6 @@ import javax.servlet.http.HttpSessionListener;
|
|||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.cache.InternalEhCacheManagerFactoryBean;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -54,6 +53,8 @@ public class ContextListener implements ServletContextListener, HttpSessionListe
|
|||||||
private static Log logger = LogFactory.getLog(ContextListener.class);
|
private static Log logger = LogFactory.getLog(ContextListener.class);
|
||||||
|
|
||||||
private ServletContext servletContext;
|
private ServletContext servletContext;
|
||||||
|
private ServletContextListener enterpriseListener;
|
||||||
|
private String enterpriseListenerClass = "org.alfresco.enterprise.repo.EnterpriseContextListener";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
|
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
|
||||||
@@ -123,16 +124,51 @@ public class ContextListener implements ServletContextListener, HttpSessionListe
|
|||||||
}
|
}
|
||||||
catch (Exception ex) {}
|
catch (Exception ex) {}
|
||||||
}
|
}
|
||||||
|
synchronized(this)
|
||||||
|
{
|
||||||
|
findEnterpriseListener();
|
||||||
|
if (enterpriseListener != null)
|
||||||
|
{
|
||||||
|
// Perform any extra context initialisation required for enterprise.
|
||||||
|
enterpriseListener.contextInitialized(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void findEnterpriseListener()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class<?> c = Class.forName(enterpriseListenerClass);
|
||||||
|
enterpriseListener = (ServletContextListener) c.newInstance();
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
// It's OK not to have the enterprise context destroyer available.
|
||||||
|
}
|
||||||
|
catch (InstantiationException e)
|
||||||
|
{
|
||||||
|
logger.error("Failed to instantiate enterprise ServletContextListener.", e);
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException e)
|
||||||
|
{
|
||||||
|
logger.error("Failed to instantiate enterprise ServletContextListener.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* <p>
|
|
||||||
* Forcibly kills Alfresco's EHCache CacheManager
|
|
||||||
*/
|
*/
|
||||||
public void contextDestroyed(ServletContextEvent event)
|
public void contextDestroyed(ServletContextEvent event)
|
||||||
{
|
{
|
||||||
InternalEhCacheManagerFactoryBean.getInstance().shutdown();
|
synchronized(this)
|
||||||
|
{
|
||||||
|
if (enterpriseListener != null)
|
||||||
|
{
|
||||||
|
// Perform any extra destruction required for enterprise.
|
||||||
|
enterpriseListener.contextDestroyed(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,4 +188,16 @@ public class ContextListener implements ServletContextListener, HttpSessionListe
|
|||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("HTTP session destroyed: " + event.getSession().getId());
|
logger.debug("HTTP session destroyed: " + event.getSession().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject a different class name (from the default) for the enterprise ServletContextListener.
|
||||||
|
* <p>
|
||||||
|
* Useful for testing.
|
||||||
|
*
|
||||||
|
* @param listenerClass Class name to use.
|
||||||
|
*/
|
||||||
|
protected void setEnterpriseListenerClass(String listenerClass)
|
||||||
|
{
|
||||||
|
this.enterpriseListenerClass = listenerClass;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
81
source/java/org/alfresco/web/app/ContextListenerTest.java
Normal file
81
source/java/org/alfresco/web/app/ContextListenerTest.java
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.web.app;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the ContextListener class.
|
||||||
|
*
|
||||||
|
* @author Matt Ward
|
||||||
|
*/
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class ContextListenerTest
|
||||||
|
{
|
||||||
|
private ContextListener contextListener;
|
||||||
|
private @Mock ServletContextEvent event;
|
||||||
|
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception
|
||||||
|
{
|
||||||
|
contextListener = new ContextListener();
|
||||||
|
contextListener.setEnterpriseListenerClass("org.alfresco.web.app.ContextListenerTest$StubEnterpriseListener");
|
||||||
|
StubEnterpriseListener.enterpriseDestroyed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testContextDestroyed()
|
||||||
|
{
|
||||||
|
contextListener.findEnterpriseListener();
|
||||||
|
contextListener.contextDestroyed(event);
|
||||||
|
|
||||||
|
assertTrue("Enterprise contextDestroyed() not executed.", StubEnterpriseListener.enterpriseDestroyed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ServletContextListener to simulate an enterprise-specific context listener.
|
||||||
|
*/
|
||||||
|
protected static class StubEnterpriseListener implements ServletContextListener
|
||||||
|
{
|
||||||
|
static boolean enterpriseDestroyed;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextDestroyed(ServletContextEvent arg0)
|
||||||
|
{
|
||||||
|
enterpriseDestroyed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextInitialized(ServletContextEvent arg0)
|
||||||
|
{
|
||||||
|
// Noop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user