From 1a481a63c20262ac1abee01959ba31ddd1443513 Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Mon, 23 Nov 2009 20:20:06 +0000 Subject: [PATCH] Merged BRANCHES/DEV/DAVEW/SPRING3 to HEAD 15422: Fix deploy-virtual-tomcat macro for Spring 3 15391: Fix ContentStoreReplicatorTest for Spring 3 15390: Upgrade CXF to version 2.2.2 for Spring 3 compatibility 15385: Correction to previous checkin 15384: Fix ClassPathStore.createRelative() to work with Spring 3 - Relative resource path resolution with directory resources has changed 15346: Merged V3.3_SPRING3 to SPRING3 15310: Spring 3: Change to the way that FileContentStore broadcasts its existence to interested parties (for enterprise-only monitoring) - Introduced new SafeEventPublisher singleton that queues up events until after the application context has finished refreshing 15309: Use AUTODETECT_NONE auto detect mode for JMX exporters to be compatible with Spring 3 15308: Fix IBATIS integration to be compatible with Spring 3 15307: Added missing runtime dependencies - org.springframework.expression-3.0.0.RC2.jar - org.springframework.asm-3.0.0.RC2.jar 15289: Move Alfresco stack to Spring 3 - Stage 1: get it compiling in eclipse and update ant scripts - Still requires Web Framework contributions from Uzi git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17624 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/audit-services-context.xml | 3 + config/alfresco/content-services-context.xml | 11 ++- config/alfresco/core-services-context.xml | 3 + .../alfresco/email/server/EmailServer.java | 4 +- .../org/alfresco/filesys/CIFSServerBean.java | 4 +- .../org/alfresco/filesys/FTPServerBean.java | 6 +- .../org/alfresco/filesys/NFSServerBean.java | 6 +- .../org/alfresco/jcr/test/BaseJCRTest.java | 4 +- .../java/org/alfresco/jcr/test/TestData.java | 6 +- .../feed/cleanup/FeedCleanerTest.java | 4 +- .../repo/admin/Log4JHierarchyInitTest.java | 4 +- .../org/alfresco/repo/cache/CacheTest.java | 4 +- .../java/org/alfresco/repo/clt/CltBase.java | 4 +- .../AbstractReadOnlyContentStoreTest.java | 7 +- .../repo/content/ContentServiceImpl.java | 31 +++---- .../repo/content/RoutingContentStoreTest.java | 6 +- .../TenantRoutingFileContentStore.java | 31 +++---- .../cleanup/ContentStoreCleanerTest.java | 9 +- .../content/filestore/FileContentStore.java | 73 +++++---------- .../filestore/FileContentStoreTest.java | 6 +- .../NoRandomAccessFileContentStoreTest.java | 6 +- .../ReadOnlyFileContentStoreTest.java | 6 +- .../xml/XmlMetadataExtracterTest.java | 4 +- .../ContentStoreReplicatorTest.java | 2 +- .../ReplicatingContentStoreTest.java | 2 +- .../contentdata/ContentDataDAOTest.java | 4 +- .../repo/management/SafeEventPublisher.java | 93 +++++++++++++++++++ .../AbstractPropertyBackedBean.java | 13 ++- .../ChildApplicationContextFactory.java | 15 ++- .../alfresco/repo/module/ComponentsTest.java | 4 +- .../lucene/fts/FullTextSearchIndexerImpl.java | 5 +- .../search/impl/lucene/index/IndexInfo.java | 3 +- .../impl/PublicServiceAccessServiceImpl.java | 2 +- .../ChainingUserRegistrySynchronizerTest.java | 4 +- .../StoreRedirectorProxyFactoryTest.java | 8 +- .../alfresco/repo/tenant/MultiTDemoTest.java | 4 +- .../util/ApplicationContextHelper.java | 9 +- .../org/alfresco/util/BaseSpringTest.java | 4 +- .../org/alfresco/util/schemadump/Main.java | 3 +- .../wcm/AbstractWCMServiceImplTest.java | 4 +- .../tenant/mt-contentstore-context.xml | 3 + 41 files changed, 258 insertions(+), 166 deletions(-) create mode 100644 source/java/org/alfresco/repo/management/SafeEventPublisher.java diff --git a/config/alfresco/audit-services-context.xml b/config/alfresco/audit-services-context.xml index 47e819db31..44ec53987f 100644 --- a/config/alfresco/audit-services-context.xml +++ b/config/alfresco/audit-services-context.xml @@ -59,6 +59,9 @@ ${dir.auditcontentstore} + + + diff --git a/config/alfresco/content-services-context.xml b/config/alfresco/content-services-context.xml index ac8b916846..16488c8b75 100644 --- a/config/alfresco/content-services-context.xml +++ b/config/alfresco/content-services-context.xml @@ -2,11 +2,14 @@ - + ${dir.contentstore} + + + @@ -14,6 +17,9 @@ ${dir.contentstore.deleted} + + + @@ -90,6 +96,9 @@ + + + diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index b7f3c779e0..c46ce19805 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -1419,4 +1419,7 @@ + + + diff --git a/source/java/org/alfresco/email/server/EmailServer.java b/source/java/org/alfresco/email/server/EmailServer.java index 40331c155d..fa0c087620 100644 --- a/source/java/org/alfresco/email/server/EmailServer.java +++ b/source/java/org/alfresco/email/server/EmailServer.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Set; import java.util.StringTokenizer; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.service.cmr.email.EmailMessageException; import org.alfresco.service.cmr.email.EmailService; @@ -37,7 +38,6 @@ import org.alfresco.util.PropertyCheck; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationEvent; import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Base implementation of an email server. @@ -260,7 +260,7 @@ public abstract class EmailServer extends AbstractLifecycleBean AbstractApplicationContext context = null; try { - context = new ClassPathXmlApplicationContext(args); + context = new FixedClassPathXmlApplicationContext(args); } catch (BeansException e) { System.err.println("Erro create context: " + e); diff --git a/source/java/org/alfresco/filesys/CIFSServerBean.java b/source/java/org/alfresco/filesys/CIFSServerBean.java index 5fdf747c50..35f6d046ee 100644 --- a/source/java/org/alfresco/filesys/CIFSServerBean.java +++ b/source/java/org/alfresco/filesys/CIFSServerBean.java @@ -30,6 +30,7 @@ import java.net.SocketException; import java.util.LinkedList; import java.util.List; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.jlan.netbios.server.NetBIOSNameServer; import org.alfresco.jlan.server.NetworkServer; @@ -42,7 +43,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * CIFS Server Class @@ -213,7 +213,7 @@ public class CIFSServerBean extends AbstractLifecycleBean { // Create the configuration service in the same way that Spring creates it - ApplicationContext ctx = new ClassPathXmlApplicationContext("alfresco/application-context.xml"); + ApplicationContext ctx = new FixedClassPathXmlApplicationContext("alfresco/application-context.xml"); // Get the CIFS server bean diff --git a/source/java/org/alfresco/filesys/FTPServerBean.java b/source/java/org/alfresco/filesys/FTPServerBean.java index 90c5edc31d..00754f5ab0 100644 --- a/source/java/org/alfresco/filesys/FTPServerBean.java +++ b/source/java/org/alfresco/filesys/FTPServerBean.java @@ -28,17 +28,17 @@ import java.io.IOException; import java.io.PrintStream; import java.net.SocketException; +import org.alfresco.config.FixedClassPathXmlApplicationContext; +import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.jlan.ftp.FTPConfigSection; import org.alfresco.jlan.ftp.FTPServer; import org.alfresco.jlan.server.NetworkServer; import org.alfresco.jlan.server.config.ServerConfiguration; -import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.util.AbstractLifecycleBean; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * FTP Server Class @@ -174,7 +174,7 @@ public class FTPServerBean extends AbstractLifecycleBean { // Create the configuration service in the same way that Spring creates it - ApplicationContext ctx = new ClassPathXmlApplicationContext("alfresco/application-context.xml"); + ApplicationContext ctx = new FixedClassPathXmlApplicationContext("alfresco/application-context.xml"); // Get the FTP server bean diff --git a/source/java/org/alfresco/filesys/NFSServerBean.java b/source/java/org/alfresco/filesys/NFSServerBean.java index 3d3f6f5d7e..12d86a3dda 100644 --- a/source/java/org/alfresco/filesys/NFSServerBean.java +++ b/source/java/org/alfresco/filesys/NFSServerBean.java @@ -28,19 +28,19 @@ import java.io.PrintStream; import java.net.SocketException; import java.util.Vector; +import org.alfresco.config.FixedClassPathXmlApplicationContext; +import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.jlan.oncrpc.mount.MountServer; import org.alfresco.jlan.oncrpc.nfs.NFSConfigSection; import org.alfresco.jlan.oncrpc.nfs.NFSServer; import org.alfresco.jlan.oncrpc.portmap.PortMapperServer; import org.alfresco.jlan.server.NetworkServer; import org.alfresco.jlan.server.config.ServerConfiguration; -import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.util.AbstractLifecycleBean; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * NFS Server Class @@ -203,7 +203,7 @@ public class NFSServerBean extends AbstractLifecycleBean { // Create the configuration service in the same way that Spring creates it - ApplicationContext ctx = new ClassPathXmlApplicationContext("alfresco/application-context.xml"); + ApplicationContext ctx = new FixedClassPathXmlApplicationContext("alfresco/application-context.xml"); // Get the NFS server bean diff --git a/source/java/org/alfresco/jcr/test/BaseJCRTest.java b/source/java/org/alfresco/jcr/test/BaseJCRTest.java index de5c75f111..f3457ffe71 100644 --- a/source/java/org/alfresco/jcr/test/BaseJCRTest.java +++ b/source/java/org/alfresco/jcr/test/BaseJCRTest.java @@ -28,12 +28,12 @@ import javax.jcr.Repository; import junit.framework.TestCase; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.jcr.repository.RepositoryFactory; import org.alfresco.jcr.repository.RepositoryImpl; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.repository.StoreRef; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Base JCR Test @@ -47,7 +47,7 @@ public class BaseJCRTest extends TestCase protected StoreRef storeRef; protected String adminUserName; - protected static ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:org/alfresco/jcr/test/test-context.xml"); + protected static ApplicationContext applicationContext = new FixedClassPathXmlApplicationContext("classpath:org/alfresco/jcr/test/test-context.xml"); protected String getWorkspace() { diff --git a/source/java/org/alfresco/jcr/test/TestData.java b/source/java/org/alfresco/jcr/test/TestData.java index 6b14914be7..31fdfa05a4 100644 --- a/source/java/org/alfresco/jcr/test/TestData.java +++ b/source/java/org/alfresco/jcr/test/TestData.java @@ -28,10 +28,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.repo.security.authentication.AuthenticationContext; import org.alfresco.repo.security.authentication.MutableAuthenticationDao; -import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeService; @@ -41,7 +42,6 @@ import org.alfresco.service.cmr.view.ImporterService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.transaction.TransactionService; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -56,7 +56,7 @@ public class TestData */ public static void main(String[] args) { - ApplicationContext context = new ClassPathXmlApplicationContext("org/alfresco/jcr/test/test-context.xml"); + ApplicationContext context = new FixedClassPathXmlApplicationContext("org/alfresco/jcr/test/test-context.xml"); generateTestData(context, TEST_WORKSPACE); System.out.println("Generated TCK test data to workspace: " + TEST_WORKSPACE); System.exit(0); diff --git a/source/java/org/alfresco/repo/activities/feed/cleanup/FeedCleanerTest.java b/source/java/org/alfresco/repo/activities/feed/cleanup/FeedCleanerTest.java index 55f5f38247..c58f289f88 100644 --- a/source/java/org/alfresco/repo/activities/feed/cleanup/FeedCleanerTest.java +++ b/source/java/org/alfresco/repo/activities/feed/cleanup/FeedCleanerTest.java @@ -37,7 +37,7 @@ import org.alfresco.service.cmr.activities.ActivityService; import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.ApplicationContext; /** * @see org.alfresco.repo.activities.feed.cleanup.FeedCleaner @@ -46,7 +46,7 @@ import org.springframework.context.ConfigurableApplicationContext; */ public class FeedCleanerTest extends TestCase { - private static ConfigurableApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); + private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); private ActivityFeedDAO feedDAO; private FeedCleaner cleaner; diff --git a/source/java/org/alfresco/repo/admin/Log4JHierarchyInitTest.java b/source/java/org/alfresco/repo/admin/Log4JHierarchyInitTest.java index 81fb31620c..835afda4ae 100644 --- a/source/java/org/alfresco/repo/admin/Log4JHierarchyInitTest.java +++ b/source/java/org/alfresco/repo/admin/Log4JHierarchyInitTest.java @@ -26,10 +26,10 @@ package org.alfresco.repo.admin; import junit.framework.TestCase; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @see Log4JHierarchyInit @@ -39,7 +39,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; */ public class Log4JHierarchyInitTest extends TestCase { - private static ApplicationContext ctx = new ClassPathXmlApplicationContext( + private static ApplicationContext ctx = new FixedClassPathXmlApplicationContext( new String[] {"classpath:log4j/log4j-test-context.xml"} ); diff --git a/source/java/org/alfresco/repo/cache/CacheTest.java b/source/java/org/alfresco/repo/cache/CacheTest.java index 70ed1bf488..95daabff13 100644 --- a/source/java/org/alfresco/repo/cache/CacheTest.java +++ b/source/java/org/alfresco/repo/cache/CacheTest.java @@ -33,6 +33,7 @@ import javax.transaction.UserTransaction; import junit.framework.TestCase; import net.sf.ehcache.CacheManager; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.repo.cache.TransactionalCache.NullValueMarker; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -42,7 +43,6 @@ import org.alfresco.service.ServiceRegistry; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @see org.alfresco.repo.cache.EhCacheAdapter @@ -51,7 +51,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; */ public class CacheTest extends TestCase { - private static ApplicationContext ctx =new ClassPathXmlApplicationContext( + private static ApplicationContext ctx =new FixedClassPathXmlApplicationContext( new String[] {"classpath:cache-test-context.xml", ApplicationContextHelper.CONFIG_LOCATIONS[0]} ); diff --git a/source/java/org/alfresco/repo/clt/CltBase.java b/source/java/org/alfresco/repo/clt/CltBase.java index 769de0a0c1..140867b792 100644 --- a/source/java/org/alfresco/repo/clt/CltBase.java +++ b/source/java/org/alfresco/repo/clt/CltBase.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.repo.remote.ClientTicketHolder; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.remote.AVMRemote; @@ -18,7 +19,6 @@ import org.alfresco.service.cmr.remote.RepoRemote; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.util.Pair; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * This is the base class for AVM clts. @@ -64,7 +64,7 @@ public abstract class CltBase */ protected CltBase() { - fContext = new ClassPathXmlApplicationContext("clt-context.xml"); + fContext = new FixedClassPathXmlApplicationContext("clt-context.xml"); fAVMRemote = (AVMRemote)fContext.getBean("avmRemote"); fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService"); fRepoRemote = (RepoRemote)fContext.getBean("repoRemote"); diff --git a/source/java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java b/source/java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java index 9a02579eb6..25d705d49d 100644 --- a/source/java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/AbstractReadOnlyContentStoreTest.java @@ -40,7 +40,8 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationEventPublisher; /** * Abstract base class that provides a set of tests for implementations @@ -54,10 +55,11 @@ import org.springframework.context.ConfigurableApplicationContext; */ public abstract class AbstractReadOnlyContentStoreTest extends TestCase { - protected static final ConfigurableApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); + protected static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); private static Log logger = LogFactory.getLog(AbstractReadOnlyContentStoreTest.class); + protected ApplicationEventPublisher applicationEventPublisher; protected TransactionService transactionService; private UserTransaction txn; @@ -72,6 +74,7 @@ public abstract class AbstractReadOnlyContentStoreTest extends TestCase @Override public void setUp() throws Exception { + applicationEventPublisher = (ApplicationEventPublisher) ctx.getBean("applicationEventPublisher"); transactionService = (TransactionService) ctx.getBean("TransactionService"); txn = transactionService.getUserTransaction(); txn.begin(); diff --git a/source/java/org/alfresco/repo/content/ContentServiceImpl.java b/source/java/org/alfresco/repo/content/ContentServiceImpl.java index a69c9b2329..6e75c2e2bb 100644 --- a/source/java/org/alfresco/repo/content/ContentServiceImpl.java +++ b/source/java/org/alfresco/repo/content/ContentServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,7 +18,7 @@ * As a special exception to the terms and conditions of version 2.0 of * the GPL, you may redistribute this Program in connection with Free/Libre * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing + * FLOSS exception. You should have received a copy of the text describing * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ @@ -69,10 +69,7 @@ import org.alfresco.util.Pair; import org.alfresco.util.TempFileProvider; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.ApplicationEventPublisher; /** @@ -86,7 +83,7 @@ import org.springframework.context.ConfigurableApplicationContext; * @author Derek Hulley * @since 3.2 */ -public class ContentServiceImpl implements ContentService, ApplicationContextAware +public class ContentServiceImpl implements ContentService { private static Log logger = LogFactory.getLog(ContentServiceImpl.class); @@ -94,7 +91,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa private NodeService nodeService; private AVMService avmService; private RetryingTransactionHelper transactionHelper; - private ApplicationContext applicationContext; + private ApplicationEventPublisher applicationEventPublisher; /** a registry of all available content transformers */ private ContentTransformerRegistry transformerRegistry; @@ -163,14 +160,16 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa { this.imageMagickContentTransformer = imageMagickContentTransformer; } - - - /* (non-Javadoc) - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) + + /** + * Sets the application event publisher. + * + * @param applicationEventPublisher + * the new application event publisher */ - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { - this.applicationContext = applicationContext; + this.applicationEventPublisher = applicationEventPublisher; } /** @@ -179,8 +178,8 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa public void init() { // Set up a temporary store - this.tempStore = new FileContentStore((ConfigurableApplicationContext) this.applicationContext, - TempFileProvider.getTempDir().getAbsolutePath()); + this.tempStore = new FileContentStore(this.applicationEventPublisher, TempFileProvider.getTempDir() + .getAbsolutePath()); // Bind on update properties behaviour this.policyComponent.bindClassBehaviour( diff --git a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java index 3fb6a2c081..ccda4c7cc1 100644 --- a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java @@ -65,13 +65,13 @@ public class RoutingContentStoreTest extends AbstractWritableContentStoreTest File tempDir = TempFileProvider.getTempDir(); // Create a subdirectory for A File storeADir = new File(tempDir, "A"); - storeA = new FileContentStore(ctx, storeADir); + storeA = new FileContentStore(applicationEventPublisher, storeADir); // Create a subdirectory for B File storeBDir = new File(tempDir, "B"); - storeB = new FileContentStore(ctx, storeBDir); + storeB = new FileContentStore(applicationEventPublisher, storeBDir); // Create a subdirectory for C File storeCDir = new File(tempDir, "C"); - storeC = new DumbReadOnlyFileStore(new FileContentStore(ctx, storeCDir)); + storeC = new DumbReadOnlyFileStore(new FileContentStore(applicationEventPublisher, storeCDir)); // No subdirectory for D storeD = new SupportsNoUrlFormatStore(); // Create the routing store diff --git a/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java b/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java index 9ca9d94285..4a7bec9b7c 100755 --- a/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java +++ b/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java @@ -18,7 +18,7 @@ * As a special exception to the terms and conditions of version 2.0 of * the GPL, you may redistribute this Program in connection with Free/Libre * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing + * FLOSS exception. You should have received a copy of the text describing * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ @@ -36,24 +36,21 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.tenant.Tenant; import org.alfresco.repo.tenant.TenantDeployer; import org.alfresco.repo.tenant.TenantService; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.ApplicationEventPublisher; /** * Content Store that supports tenant routing, if multi-tenancy is enabled. * * Note: Need to initialise before the dictionary service, in the case that models are dynamically loaded for the tenant. */ -public class TenantRoutingFileContentStore extends AbstractRoutingContentStore implements TenantDeployer, ApplicationContextAware +public class TenantRoutingFileContentStore extends AbstractRoutingContentStore implements TenantDeployer { // cache of tenant file stores Map tenantFileStores = new ConcurrentHashMap(); private String defaultRootDirectory; private TenantService tenantService; - private ApplicationContext applicationContext; + private ApplicationEventPublisher applicationEventPublisher; public void setDefaultRootDir(String defaultRootDirectory) @@ -65,17 +62,18 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i { this.tenantService = tenantService; } - - /* - * (non-Javadoc) - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context. - * ApplicationContext) + + /** + * Sets the application event publisher. + * + * @param applicationEventPublisher + * the new application event publisher */ - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { - this.applicationContext = applicationContext; + this.applicationEventPublisher = applicationEventPublisher; } - + @Override protected ContentStore selectWriteStore(ContentContext ctx) { @@ -138,8 +136,7 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i tenantDomain = tenant.getTenantDomain(); } - putTenantFileStore(tenantDomain, new FileContentStore((ConfigurableApplicationContext) this.applicationContext, - new File(rootDir))); + putTenantFileStore(tenantDomain, new FileContentStore(this.applicationEventPublisher, new File(rootDir))); } public void destroy() diff --git a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java index c0cd44703a..c4b3f46fc7 100644 --- a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java +++ b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java @@ -59,7 +59,8 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.GUID; import org.alfresco.util.TempFileProvider; -import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationEventPublisher; /** * @see org.alfresco.repo.content.cleanup.ContentStoreCleaner @@ -68,7 +69,7 @@ import org.springframework.context.ConfigurableApplicationContext; */ public class ContentStoreCleanerTest extends TestCase { - private static ConfigurableApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); + private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); private ContentService contentService; private NodeService nodeService; @@ -96,12 +97,14 @@ public class ContentStoreCleanerTest extends TestCase AVMNodeDAO avmNodeDAO = (AVMNodeDAO) ctx.getBean("newAvmNodeDAO"); ContentCleanDAO contentCleanDAO = (ContentCleanDAO) ctx.getBean("contentCleanDAO"); ContentDataDAO contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); + ApplicationEventPublisher applicationEventPublisher = (ApplicationEventPublisher) ctx + .getBean("applicationEventPublisher"); eagerCleaner = (EagerContentStoreCleaner) ctx.getBean("eagerContentStoreCleaner"); eagerCleaner.setEagerOrphanCleanup(false); // we need a store - store = new FileContentStore(ctx, TempFileProvider.getTempDir().getAbsolutePath()); + store = new FileContentStore(applicationEventPublisher, TempFileProvider.getTempDir().getAbsolutePath()); // and a listener listener = new DummyCleanerListener(); // initialise record of deleted URLs diff --git a/source/java/org/alfresco/repo/content/filestore/FileContentStore.java b/source/java/org/alfresco/repo/content/filestore/FileContentStore.java index 9acbe67b06..8876f55cf4 100644 --- a/source/java/org/alfresco/repo/content/filestore/FileContentStore.java +++ b/source/java/org/alfresco/repo/content/filestore/FileContentStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -44,13 +44,8 @@ import org.alfresco.util.GUID; import org.alfresco.util.Pair; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationListener; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.event.ContextRefreshedEvent; /** * Provides a store of node content directly to the file system. The writers @@ -61,7 +56,7 @@ import org.springframework.context.event.ContextRefreshedEvent; * * @author Derek Hulley */ -public class FileContentStore extends AbstractContentStore implements ApplicationContextAware, ApplicationListener +public class FileContentStore extends AbstractContentStore { /** * store is the new prefix for file content URLs @@ -75,7 +70,7 @@ public class FileContentStore extends AbstractContentStore implements Applicatio private String rootAbsolutePath; private boolean allowRandomAccess; private boolean readOnly; - private ApplicationContext applicationContext; + private ApplicationEventPublisher applicationEventPublisher; /** * Private: for Spring-constructed instances only. @@ -113,32 +108,32 @@ public class FileContentStore extends AbstractContentStore implements Applicatio /** * Public constructor for programmatic use. * - * @param context - * application context through which events can be published + * @param applicationEventPublisher + * the application event publisher * @param rootDirectoryStr * the root under which files will be stored. The directory will be created if it does not exist. * @see FileContentStore#FileContentStore(File) */ - public FileContentStore(ConfigurableApplicationContext context, String rootDirectoryStr) + public FileContentStore(ApplicationEventPublisher applicationEventPublisher, String rootDirectoryStr) { this(rootDirectoryStr); - setApplicationContext(context); - publishEvent(context); + setApplicationEventPublisher(applicationEventPublisher); + publishEvent(); } /** * Public constructor for programmatic use. * - * @param context - * application context through which events can be published + * @param applicationEventPublisher + * the application event publisher * @param rootDirectory * the root under which files will be stored. The directory will be created if it does not exist. */ - public FileContentStore(ConfigurableApplicationContext context, File rootDirectory) + public FileContentStore(ApplicationEventPublisher applicationEventPublisher, File rootDirectory) { this(rootDirectory); - setApplicationContext(context); - publishEvent(context); + setApplicationEventPublisher(applicationEventPublisher); + publishEvent(); } @@ -153,13 +148,16 @@ public class FileContentStore extends AbstractContentStore implements Applicatio return sb.toString(); } - - /* (non-Javadoc) - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) + + /** + * Sets the application event publisher. + * + * @param applicationEventPublisher + * the new application event publisher */ - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { - this.applicationContext = applicationContext; + this.applicationEventPublisher = applicationEventPublisher; } /** @@ -638,32 +636,9 @@ public class FileContentStore extends AbstractContentStore implements Applicatio /** * Publishes an event to the application context that will notify any interested parties of the existence of this * content store. - * - * @param context - * the application context */ - private void publishEvent(ConfigurableApplicationContext context) + private void publishEvent() { - // If the context isn't running yet, we have to wait until the refresh event - try - { - // Neither context.isActive() or context.isRunning() seem to detect whether the refresh() has completed - context.publishEvent(new ContentStoreCreatedEvent(this)); - } - catch (IllegalStateException e) - { - context.addApplicationListener(this); - } - } - - public void onApplicationEvent(ApplicationEvent event) - { - // Once the context has been refreshed, we tell other interested beans about the existence of this content store - // (e.g. for monitoring purposes) - if (event instanceof ContextRefreshedEvent && event.getSource() == this.applicationContext) - { - ((ContextRefreshedEvent) event).getApplicationContext().publishEvent( - new ContentStoreCreatedEvent(this)); - } + this.applicationEventPublisher.publishEvent(new ContentStoreCreatedEvent(this)); } } diff --git a/source/java/org/alfresco/repo/content/filestore/FileContentStoreTest.java b/source/java/org/alfresco/repo/content/filestore/FileContentStoreTest.java index 5614573ef3..fd14511871 100644 --- a/source/java/org/alfresco/repo/content/filestore/FileContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/filestore/FileContentStoreTest.java @@ -52,10 +52,8 @@ public class FileContentStoreTest extends AbstractWritableContentStoreTest // create a store that uses a subdirectory of the temp directory File tempDir = TempFileProvider.getTempDir(); - store = new FileContentStore(ctx, - tempDir.getAbsolutePath() + - File.separatorChar + - getName()); + store = new FileContentStore(applicationEventPublisher, tempDir.getAbsolutePath() + File.separatorChar + + getName()); } @Override diff --git a/source/java/org/alfresco/repo/content/filestore/NoRandomAccessFileContentStoreTest.java b/source/java/org/alfresco/repo/content/filestore/NoRandomAccessFileContentStoreTest.java index f376b2dd24..3e053111e4 100644 --- a/source/java/org/alfresco/repo/content/filestore/NoRandomAccessFileContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/filestore/NoRandomAccessFileContentStoreTest.java @@ -49,10 +49,8 @@ public class NoRandomAccessFileContentStoreTest extends AbstractWritableContentS // create a store that uses a subdirectory of the temp directory File tempDir = TempFileProvider.getTempDir(); - store = new FileContentStore(ctx, - tempDir.getAbsolutePath() + - File.separatorChar + - getName()); + store = new FileContentStore(applicationEventPublisher, tempDir.getAbsolutePath() + File.separatorChar + + getName()); // disallow random access store.setAllowRandomAccess(false); } diff --git a/source/java/org/alfresco/repo/content/filestore/ReadOnlyFileContentStoreTest.java b/source/java/org/alfresco/repo/content/filestore/ReadOnlyFileContentStoreTest.java index 89a60ebe94..ce7387e02a 100644 --- a/source/java/org/alfresco/repo/content/filestore/ReadOnlyFileContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/filestore/ReadOnlyFileContentStoreTest.java @@ -50,10 +50,8 @@ public class ReadOnlyFileContentStoreTest extends AbstractReadOnlyContentStoreTe // create a store that uses a subdirectory of the temp directory File tempDir = TempFileProvider.getTempDir(); - store = new FileContentStore(ctx, - tempDir.getAbsolutePath() + - File.separatorChar + - getName()); + store = new FileContentStore(applicationEventPublisher, tempDir.getAbsolutePath() + File.separatorChar + + getName()); // disallow random access store.setReadOnly(true); } diff --git a/source/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java b/source/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java index df15f84d03..6b186bbb17 100644 --- a/source/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java +++ b/source/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java @@ -30,6 +30,7 @@ import java.net.URL; import junit.framework.TestCase; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.model.ContentModel; import org.alfresco.repo.action.ActionImpl; import org.alfresco.repo.action.executer.ActionExecuter; @@ -54,7 +55,6 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Tests various aspects of XML metadata extraction. @@ -71,7 +71,7 @@ public class XmlMetadataExtracterTest extends TestCase private static final String FILE_MALFORMED = "xml-metadata/malformed-sample.xml"; private static final String CTX_LOCATION = "classpath:xml-metadata/xml-metadata-test-context.xml"; - private static final ApplicationContext ctx = new ClassPathXmlApplicationContext(CTX_LOCATION); + private static final ApplicationContext ctx = new FixedClassPathXmlApplicationContext(CTX_LOCATION); private ServiceRegistry serviceRegistry; private AuthenticationComponent authenticationComponent; diff --git a/source/java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java b/source/java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java index 9e92944486..aee4ac2bc6 100644 --- a/source/java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java +++ b/source/java/org/alfresco/repo/content/replication/ContentStoreReplicatorTest.java @@ -37,7 +37,7 @@ import org.alfresco.repo.content.filestore.FileContentStore; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.util.GUID; import org.alfresco.util.TempFileProvider; -import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.support.StaticApplicationContext; /** diff --git a/source/java/org/alfresco/repo/content/replication/ReplicatingContentStoreTest.java b/source/java/org/alfresco/repo/content/replication/ReplicatingContentStoreTest.java index d2e4d5efcb..dab5fd4041 100644 --- a/source/java/org/alfresco/repo/content/replication/ReplicatingContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/replication/ReplicatingContentStoreTest.java @@ -70,7 +70,7 @@ public class ReplicatingContentStoreTest extends AbstractWritableContentStoreTes File tempDir = TempFileProvider.getTempDir(); // create a primary file store String storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate(); - primaryStore = new FileContentStore(ctx, storeDir); + primaryStore = new FileContentStore(applicationEventPublisher, storeDir); // create some secondary file stores secondaryStores = new ArrayList(3); for (int i = 0; i < 4; i++) diff --git a/source/java/org/alfresco/repo/domain/contentdata/ContentDataDAOTest.java b/source/java/org/alfresco/repo/domain/contentdata/ContentDataDAOTest.java index 6fcf399a9b..3e67165ec5 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/ContentDataDAOTest.java +++ b/source/java/org/alfresco/repo/domain/contentdata/ContentDataDAOTest.java @@ -42,6 +42,7 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.Pair; import org.alfresco.util.TempFileProvider; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ConfigurableApplicationContext; /** @@ -65,9 +66,10 @@ public class ContentDataDAOTest extends TestCase ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionService = serviceRegistry.getTransactionService(); txnHelper = transactionService.getRetryingTransactionHelper(); + ApplicationEventPublisher applicationEventPublisher = (ApplicationEventPublisher) ctx.getBean("applicationEventPublisher"); contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); - contentStore = new FileContentStore(ctx, TempFileProvider.getTempDir()); + contentStore = new FileContentStore(applicationEventPublisher, TempFileProvider.getTempDir()); } private Pair create(final ContentData contentData) diff --git a/source/java/org/alfresco/repo/management/SafeEventPublisher.java b/source/java/org/alfresco/repo/management/SafeEventPublisher.java new file mode 100644 index 0000000000..40833312f6 --- /dev/null +++ b/source/java/org/alfresco/repo/management/SafeEventPublisher.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2005-2009 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have received a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.management; + +import java.util.LinkedList; +import java.util.List; + +import org.alfresco.util.AbstractLifecycleBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ApplicationEventPublisher; + +/** + * An event publisher that is safe to use while the context is in the process of refreshing. It queues up events until + * the context has refreshed, after which point events are published in real time. + * + * @author dward + */ +public class SafeEventPublisher extends AbstractLifecycleBean implements ApplicationEventPublisher +{ + + /** Has the application started? */ + private boolean isApplicationStarted; + + /** The queued events. */ + private List queuedEvents = new LinkedList(); + + /* + * (non-Javadoc) + * @see org.alfresco.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onBootstrap(ApplicationEvent event) + { + this.isApplicationStarted = true; + for (ApplicationEvent queuedEvent : this.queuedEvents) + { + publishEvent(queuedEvent); + } + this.queuedEvents.clear(); + } + + /* + * (non-Javadoc) + * @see org.alfresco.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent) + */ + @Override + protected void onShutdown(ApplicationEvent event) + { + this.isApplicationStarted = false; + } + + /* + * (non-Javadoc) + * @see + * org.springframework.context.ApplicationEventPublisher#publishEvent(org.springframework.context.ApplicationEvent) + */ + public void publishEvent(ApplicationEvent event) + { + ApplicationContext context = getApplicationContext(); + if (this.isApplicationStarted) + { + context.publishEvent(event); + } + else + { + this.queuedEvents.add(event); + } + } + +} diff --git a/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java b/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java index da8cee3dc0..4f2c0ff308 100644 --- a/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java +++ b/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java @@ -27,7 +27,6 @@ package org.alfresco.repo.management.subsystems; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Properties; import java.util.Set; @@ -36,12 +35,12 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.util.PropertyPlaceholderHelper; /** * A base class for {@link PropertyBackedBean}s. Gets its category from its Spring bean name and automatically @@ -485,10 +484,10 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean, } /** - * Uses a Spring {@link PropertyPlaceholderConfigurer} to resolve placeholders in the property defaults. This means + * Uses a Spring {@link PropertyPlaceholderHelper} to resolve placeholders in the property defaults. This means * that placeholders need not be displayed in the configuration UI or JMX console. */ - public class DefaultResolver extends PropertyPlaceholderConfigurer + public class DefaultResolver extends PropertyPlaceholderHelper { /** @@ -496,7 +495,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean, */ public DefaultResolver() { - setIgnoreUnresolvablePlaceholders(true); + super("${", "}", ":", true); } /** @@ -508,8 +507,8 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean, */ public String resolveValue(String val) { - return AbstractPropertyBackedBean.this.propertyDefaults == null ? null : parseStringValue(val, - AbstractPropertyBackedBean.this.propertyDefaults, new HashSet()); + return AbstractPropertyBackedBean.this.propertyDefaults == null ? null : replacePlaceholders( + val, AbstractPropertyBackedBean.this.propertyDefaults); } } diff --git a/source/java/org/alfresco/repo/management/subsystems/ChildApplicationContextFactory.java b/source/java/org/alfresco/repo/management/subsystems/ChildApplicationContextFactory.java index 33f0292b31..8782d29a08 100644 --- a/source/java/org/alfresco/repo/management/subsystems/ChildApplicationContextFactory.java +++ b/source/java/org/alfresco/repo/management/subsystems/ChildApplicationContextFactory.java @@ -36,6 +36,7 @@ import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.config.JBossEnabledResourcePatternResolver; import org.alfresco.config.JndiPropertiesFactoryBean; import org.alfresco.util.config.RepositoryPathConfigBean; @@ -350,12 +351,12 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i * * @author dward */ - private class ChildApplicationContext extends ClassPathXmlApplicationContext + private class ChildApplicationContext extends FixedClassPathXmlApplicationContext { /** The composite property values. */ private Map> compositeProperties; - + /** * The Constructor. * @@ -373,8 +374,14 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i { ChildApplicationContextFactory.CLASSPATH_PREFIX + getCategory() + '/' + getTypeName() + ChildApplicationContextFactory.CONTEXT_SUFFIX, - ChildApplicationContextFactory.EXTENSION_CLASSPATH_PREFIX + getCategory() + '/' + getTypeName() + '/' - + getId().get(getId().size() - 1) + '/' + ChildApplicationContextFactory.CONTEXT_SUFFIX + ChildApplicationContextFactory.EXTENSION_CLASSPATH_PREFIX + + getCategory() + + '/' + + getTypeName() + + '/' + + ChildApplicationContextFactory.this.getId().get( + ChildApplicationContextFactory.this.getId().size() - 1) + '/' + + ChildApplicationContextFactory.CONTEXT_SUFFIX }, false, ChildApplicationContextFactory.this.getParent()); this.compositeProperties = compositeProperties; diff --git a/source/java/org/alfresco/repo/module/ComponentsTest.java b/source/java/org/alfresco/repo/module/ComponentsTest.java index b448fe7d57..568aa4438c 100644 --- a/source/java/org/alfresco/repo/module/ComponentsTest.java +++ b/source/java/org/alfresco/repo/module/ComponentsTest.java @@ -30,6 +30,7 @@ import javax.transaction.UserTransaction; import junit.framework.TestCase; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.service.ServiceRegistry; @@ -40,7 +41,6 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.search.CategoryService; import org.alfresco.service.transaction.TransactionService; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Tests various module components. @@ -52,7 +52,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; */ public class ComponentsTest extends TestCase { - private static ApplicationContext ctx = new ClassPathXmlApplicationContext("module/module-component-test-beans.xml"); + private static ApplicationContext ctx = new FixedClassPathXmlApplicationContext("module/module-component-test-beans.xml"); private ServiceRegistry serviceRegistry; private AuthenticationComponent authenticationComponent; diff --git a/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerImpl.java index dc3e7de7a7..b9e46c5efd 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerImpl.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/fts/FullTextSearchIndexerImpl.java @@ -28,6 +28,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.repo.search.BackgroundIndexerAware; import org.alfresco.repo.search.Indexer; import org.alfresco.repo.search.IndexerAndSearcher; @@ -36,9 +37,7 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Background index update scheduler @@ -242,7 +241,7 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc public static void main(String[] args) throws InterruptedException { @SuppressWarnings("unused") - ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml"); + ApplicationContext ctx = new FixedClassPathXmlApplicationContext("classpath:alfresco/application-context.xml"); } diff --git a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java index 2fb1bf9708..d940967a3c 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java @@ -101,6 +101,7 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.RAMDirectory; import org.safehaus.uuid.UUID; import org.saxpath.SAXPathException; +import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; @@ -2510,7 +2511,7 @@ public class IndexInfo implements IndexMonitor static Query getPathQuery(String path) throws SAXPathException { - ConfigurableApplicationContext ac = ApplicationContextHelper.getApplicationContext(); + ApplicationContext ac = ApplicationContextHelper.getApplicationContext(); XPathReader reader = new XPathReader(); LuceneXPathHandler handler = new LuceneXPathHandler(); handler.setNamespacePrefixResolver((NamespaceService) ac.getBean("namespaceService")); diff --git a/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java b/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java index 99e07d05c6..c79f7e4391 100644 --- a/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java +++ b/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java @@ -65,7 +65,7 @@ public class PublicServiceAccessServiceImpl implements PublicServiceAccessServic { if (method.getParameterTypes().length == args.length) { - methodInvocation = new ReflectiveMethodInvocation(null, null, method, args, null, null); + methodInvocation = new ReflectiveMethodInvocation(null, null, method, args, null, null) {}; } } } diff --git a/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizerTest.java b/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizerTest.java index 73b97e286d..c469027755 100644 --- a/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizerTest.java +++ b/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizerTest.java @@ -39,6 +39,7 @@ import java.util.Set; import junit.framework.TestCase; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.model.ContentModel; import org.alfresco.repo.management.subsystems.ChildApplicationContextManager; import org.alfresco.repo.security.authentication.AuthenticationContext; @@ -52,7 +53,6 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.StaticApplicationContext; /** @@ -70,7 +70,7 @@ public class ChainingUserRegistrySynchronizerTest extends TestCase }; /** The Spring application context. */ - private static ApplicationContext context = new ClassPathXmlApplicationContext( + private static ApplicationContext context = new FixedClassPathXmlApplicationContext( ChainingUserRegistrySynchronizerTest.CONFIG_LOCATIONS); /** The synchronizer we are testing. */ diff --git a/source/java/org/alfresco/repo/service/StoreRedirectorProxyFactoryTest.java b/source/java/org/alfresco/repo/service/StoreRedirectorProxyFactoryTest.java index 41f275d306..6f9281dc35 100644 --- a/source/java/org/alfresco/repo/service/StoreRedirectorProxyFactoryTest.java +++ b/source/java/org/alfresco/repo/service/StoreRedirectorProxyFactoryTest.java @@ -24,12 +24,12 @@ */ package org.alfresco.repo.service; +import junit.framework.TestCase; + +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import junit.framework.TestCase; public class StoreRedirectorProxyFactoryTest extends TestCase { @@ -38,7 +38,7 @@ public class StoreRedirectorProxyFactoryTest extends TestCase public void setUp() { - factory = new ClassPathXmlApplicationContext("org/alfresco/repo/service/testredirector.xml"); + factory = new FixedClassPathXmlApplicationContext("org/alfresco/repo/service/testredirector.xml"); } public void testRedirect() diff --git a/source/java/org/alfresco/repo/tenant/MultiTDemoTest.java b/source/java/org/alfresco/repo/tenant/MultiTDemoTest.java index 3c40e7e6d2..59f01fe6ef 100644 --- a/source/java/org/alfresco/repo/tenant/MultiTDemoTest.java +++ b/source/java/org/alfresco/repo/tenant/MultiTDemoTest.java @@ -37,6 +37,7 @@ import java.util.Set; import junit.framework.TestCase; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ApplicationModel; import org.alfresco.model.ContentModel; @@ -70,13 +71,12 @@ import org.alfresco.util.ApplicationContextHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; public class MultiTDemoTest extends TestCase { private static Log logger = LogFactory.getLog(MultiTDemoTest.class); - private static ApplicationContext ctx =new ClassPathXmlApplicationContext( + private static ApplicationContext ctx =new FixedClassPathXmlApplicationContext( new String[] {ApplicationContextHelper.CONFIG_LOCATIONS[0], "classpath:tenant/mt-*context.xml"} ); diff --git a/source/java/org/alfresco/util/ApplicationContextHelper.java b/source/java/org/alfresco/util/ApplicationContextHelper.java index 9a3854c87e..d9f71eb191 100644 --- a/source/java/org/alfresco/util/ApplicationContextHelper.java +++ b/source/java/org/alfresco/util/ApplicationContextHelper.java @@ -26,7 +26,8 @@ package org.alfresco.util; import java.util.Arrays; -import org.springframework.context.ConfigurableApplicationContext; +import org.alfresco.config.FixedClassPathXmlApplicationContext; +import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** @@ -52,7 +53,7 @@ public class ApplicationContextHelper * * @return Returns an application context for the default Alfresco configuration */ - public synchronized static ConfigurableApplicationContext getApplicationContext() + public synchronized static ApplicationContext getApplicationContext() { return getApplicationContext(CONFIG_LOCATIONS); } @@ -66,7 +67,7 @@ public class ApplicationContextHelper * * @return Returns an application context for the given configuration */ - public synchronized static ConfigurableApplicationContext getApplicationContext(String[] configLocations) + public synchronized static ApplicationContext getApplicationContext(String[] configLocations) { if (configLocations == null) { @@ -80,7 +81,7 @@ public class ApplicationContextHelper // The config has changed so close the current context (if any) closeApplicationContext(); - instance = new ClassPathXmlApplicationContext(configLocations); + instance = new FixedClassPathXmlApplicationContext(configLocations); usedConfiguration = configLocations; return instance; diff --git a/source/java/org/alfresco/util/BaseSpringTest.java b/source/java/org/alfresco/util/BaseSpringTest.java index 5a1f7a54dc..e5b3abbf47 100644 --- a/source/java/org/alfresco/util/BaseSpringTest.java +++ b/source/java/org/alfresco/util/BaseSpringTest.java @@ -24,10 +24,10 @@ */ package org.alfresco.util; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.orm.hibernate3.SessionFactoryUtils; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; @@ -120,7 +120,7 @@ public abstract class BaseSpringTest extends AbstractTransactionalDataSourceSpri else { String[] configLocations = (String[]) key; - return new ClassPathXmlApplicationContext(configLocations); + return new FixedClassPathXmlApplicationContext(configLocations); } } } diff --git a/source/java/org/alfresco/util/schemadump/Main.java b/source/java/org/alfresco/util/schemadump/Main.java index 881661ad22..bd2eb93538 100644 --- a/source/java/org/alfresco/util/schemadump/Main.java +++ b/source/java/org/alfresco/util/schemadump/Main.java @@ -47,6 +47,7 @@ import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.TypeNames; @@ -101,7 +102,7 @@ public class Main @SuppressWarnings("unchecked") public Main(final String contextPath) throws Exception { - final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] + final ClassPathXmlApplicationContext context = new FixedClassPathXmlApplicationContext(new String[] { "file:" + contextPath }); diff --git a/source/java/org/alfresco/wcm/AbstractWCMServiceImplTest.java b/source/java/org/alfresco/wcm/AbstractWCMServiceImplTest.java index af10a05d04..d723dd61f2 100644 --- a/source/java/org/alfresco/wcm/AbstractWCMServiceImplTest.java +++ b/source/java/org/alfresco/wcm/AbstractWCMServiceImplTest.java @@ -28,6 +28,7 @@ import java.util.List; import junit.framework.TestCase; +import org.alfresco.config.FixedClassPathXmlApplicationContext; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -45,7 +46,6 @@ import org.alfresco.wcm.webproject.WebProjectService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Abstract WCM Service implementation unit test @@ -65,7 +65,7 @@ public class AbstractWCMServiceImplTest extends TestCase protected static final int POLL_MAX_ATTEMPTS = 10; // note: all tests share same context (when run via WCMTestSuite) - protected static ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {ApplicationContextHelper.CONFIG_LOCATIONS[0], SUBMIT_CONFIG_LOCATION, PREVIEW_CONFIG_LOCATION});; + protected static ApplicationContext ctx = new FixedClassPathXmlApplicationContext(new String[] {ApplicationContextHelper.CONFIG_LOCATIONS[0], SUBMIT_CONFIG_LOCATION, PREVIEW_CONFIG_LOCATION});; // // test data diff --git a/source/test-resources/tenant/mt-contentstore-context.xml b/source/test-resources/tenant/mt-contentstore-context.xml index c413b93cfa..1a9f934f0b 100644 --- a/source/test-resources/tenant/mt-contentstore-context.xml +++ b/source/test-resources/tenant/mt-contentstore-context.xml @@ -25,6 +25,9 @@ + + + ${dir.contentstore}