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