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
This commit is contained in:
Dave Ward
2009-11-23 20:20:06 +00:00
parent 512e7c8cb5
commit 1a481a63c2
41 changed files with 258 additions and 166 deletions

View File

@@ -59,6 +59,9 @@
<constructor-arg> <constructor-arg>
<value>${dir.auditcontentstore}</value> <value>${dir.auditcontentstore}</value>
</constructor-arg> </constructor-arg>
<property name="applicationEventPublisher">
<ref bean="applicationEventPublisher"/>
</property>
</bean> </bean>
<!-- The audit model --> <!-- The audit model -->

View File

@@ -2,11 +2,14 @@
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans> <beans>
<bean id="fileContentStore" class="org.alfresco.repo.content.filestore.FileContentStore"> <bean id="fileContentStore" class="org.alfresco.repo.content.filestore.FileContentStore">
<constructor-arg> <constructor-arg>
<value>${dir.contentstore}</value> <value>${dir.contentstore}</value>
</constructor-arg> </constructor-arg>
<property name="applicationEventPublisher">
<ref bean="applicationEventPublisher" />
</property>
</bean> </bean>
<!-- deleted content will get pushed into this store, where it can be cleaned up at will --> <!-- deleted content will get pushed into this store, where it can be cleaned up at will -->
@@ -14,6 +17,9 @@
<constructor-arg> <constructor-arg>
<value>${dir.contentstore.deleted}</value> <value>${dir.contentstore.deleted}</value>
</constructor-arg> </constructor-arg>
<property name="applicationEventPublisher">
<ref bean="applicationEventPublisher" />
</property>
</bean> </bean>
<!-- bean to move deleted content into the the backup store --> <!-- bean to move deleted content into the the backup store -->
<bean id="deletedContentBackupListener" class="org.alfresco.repo.content.cleanup.DeletedContentBackupCleanerListener" > <bean id="deletedContentBackupListener" class="org.alfresco.repo.content.cleanup.DeletedContentBackupCleanerListener" >
@@ -90,6 +96,9 @@
<!-- Abstract bean definition defining base definition for content service --> <!-- Abstract bean definition defining base definition for content service -->
<bean id="baseContentService" class="org.alfresco.repo.content.ContentServiceImpl" abstract="true" init-method="init"> <bean id="baseContentService" class="org.alfresco.repo.content.ContentServiceImpl" abstract="true" init-method="init">
<property name="applicationEventPublisher">
<ref bean="applicationEventPublisher"/>
</property>
<property name="retryingTransactionHelper"> <property name="retryingTransactionHelper">
<ref bean="retryingTransactionHelper"/> <ref bean="retryingTransactionHelper"/>
</property> </property>

View File

@@ -1419,4 +1419,7 @@
</property> </property>
</bean> </bean>
<!-- Bean that can be used for publishing events, even when the app is starting up -->
<bean id="applicationEventPublisher" class="org.alfresco.repo.management.SafeEventPublisher"/>
</beans> </beans>

View File

@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.email.EmailMessageException; import org.alfresco.service.cmr.email.EmailMessageException;
import org.alfresco.service.cmr.email.EmailService; import org.alfresco.service.cmr.email.EmailService;
@@ -37,7 +38,6 @@ import org.alfresco.util.PropertyCheck;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* Base implementation of an email server. * Base implementation of an email server.
@@ -260,7 +260,7 @@ public abstract class EmailServer extends AbstractLifecycleBean
AbstractApplicationContext context = null; AbstractApplicationContext context = null;
try try
{ {
context = new ClassPathXmlApplicationContext(args); context = new FixedClassPathXmlApplicationContext(args);
} catch (BeansException e) } catch (BeansException e)
{ {
System.err.println("Erro create context: " + e); System.err.println("Erro create context: " + e);

View File

@@ -30,6 +30,7 @@ import java.net.SocketException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.jlan.netbios.server.NetBIOSNameServer; import org.alfresco.jlan.netbios.server.NetBIOSNameServer;
import org.alfresco.jlan.server.NetworkServer; import org.alfresco.jlan.server.NetworkServer;
@@ -42,7 +43,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* CIFS Server Class * CIFS Server Class
@@ -213,7 +213,7 @@ public class CIFSServerBean extends AbstractLifecycleBean
{ {
// Create the configuration service in the same way that Spring creates it // 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 // Get the CIFS server bean

View File

@@ -28,17 +28,17 @@ import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.SocketException; 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.FTPConfigSection;
import org.alfresco.jlan.ftp.FTPServer; import org.alfresco.jlan.ftp.FTPServer;
import org.alfresco.jlan.server.NetworkServer; import org.alfresco.jlan.server.NetworkServer;
import org.alfresco.jlan.server.config.ServerConfiguration; import org.alfresco.jlan.server.config.ServerConfiguration;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.util.AbstractLifecycleBean; import org.alfresco.util.AbstractLifecycleBean;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* FTP Server Class * FTP Server Class
@@ -174,7 +174,7 @@ public class FTPServerBean extends AbstractLifecycleBean
{ {
// Create the configuration service in the same way that Spring creates it // 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 // Get the FTP server bean

View File

@@ -28,19 +28,19 @@ import java.io.PrintStream;
import java.net.SocketException; import java.net.SocketException;
import java.util.Vector; 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.mount.MountServer;
import org.alfresco.jlan.oncrpc.nfs.NFSConfigSection; import org.alfresco.jlan.oncrpc.nfs.NFSConfigSection;
import org.alfresco.jlan.oncrpc.nfs.NFSServer; import org.alfresco.jlan.oncrpc.nfs.NFSServer;
import org.alfresco.jlan.oncrpc.portmap.PortMapperServer; import org.alfresco.jlan.oncrpc.portmap.PortMapperServer;
import org.alfresco.jlan.server.NetworkServer; import org.alfresco.jlan.server.NetworkServer;
import org.alfresco.jlan.server.config.ServerConfiguration; import org.alfresco.jlan.server.config.ServerConfiguration;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.util.AbstractLifecycleBean; import org.alfresco.util.AbstractLifecycleBean;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* NFS Server Class * NFS Server Class
@@ -203,7 +203,7 @@ public class NFSServerBean extends AbstractLifecycleBean
{ {
// Create the configuration service in the same way that Spring creates it // 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 // Get the NFS server bean

View File

@@ -28,12 +28,12 @@ import javax.jcr.Repository;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.jcr.repository.RepositoryFactory; import org.alfresco.jcr.repository.RepositoryFactory;
import org.alfresco.jcr.repository.RepositoryImpl; import org.alfresco.jcr.repository.RepositoryImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* Base JCR Test * Base JCR Test
@@ -47,7 +47,7 @@ public class BaseJCRTest extends TestCase
protected StoreRef storeRef; protected StoreRef storeRef;
protected String adminUserName; 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() protected String getWorkspace()
{ {

View File

@@ -28,10 +28,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.security.authentication.AuthenticationContext; import org.alfresco.repo.security.authentication.AuthenticationContext;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao; 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.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService; 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.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -56,7 +56,7 @@ public class TestData
*/ */
public static void main(String[] args) 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); generateTestData(context, TEST_WORKSPACE);
System.out.println("Generated TCK test data to workspace: " + TEST_WORKSPACE); System.out.println("Generated TCK test data to workspace: " + TEST_WORKSPACE);
System.exit(0); System.exit(0);

View File

@@ -37,7 +37,7 @@ import org.alfresco.service.cmr.activities.ActivityService;
import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ApplicationContext;
/** /**
* @see org.alfresco.repo.activities.feed.cleanup.FeedCleaner * @see org.alfresco.repo.activities.feed.cleanup.FeedCleaner
@@ -46,7 +46,7 @@ import org.springframework.context.ConfigurableApplicationContext;
*/ */
public class FeedCleanerTest extends TestCase public class FeedCleanerTest extends TestCase
{ {
private static ConfigurableApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
private ActivityFeedDAO feedDAO; private ActivityFeedDAO feedDAO;
private FeedCleaner cleaner; private FeedCleaner cleaner;

View File

@@ -26,10 +26,10 @@ package org.alfresco.repo.admin;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* @see Log4JHierarchyInit * @see Log4JHierarchyInit
@@ -39,7 +39,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/ */
public class Log4JHierarchyInitTest extends TestCase 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"} new String[] {"classpath:log4j/log4j-test-context.xml"}
); );

View File

@@ -33,6 +33,7 @@ import javax.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.sf.ehcache.CacheManager; import net.sf.ehcache.CacheManager;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.repo.cache.TransactionalCache.NullValueMarker; import org.alfresco.repo.cache.TransactionalCache.NullValueMarker;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
@@ -42,7 +43,6 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* @see org.alfresco.repo.cache.EhCacheAdapter * @see org.alfresco.repo.cache.EhCacheAdapter
@@ -51,7 +51,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/ */
public class CacheTest extends TestCase 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]} new String[] {"classpath:cache-test-context.xml", ApplicationContextHelper.CONFIG_LOCATIONS[0]}
); );

View File

@@ -11,6 +11,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.repo.remote.ClientTicketHolder; import org.alfresco.repo.remote.ClientTicketHolder;
import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.remote.AVMRemote; 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.service.cmr.security.AuthenticationService;
import org.alfresco.util.Pair; import org.alfresco.util.Pair;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* This is the base class for AVM clts. * This is the base class for AVM clts.
@@ -64,7 +64,7 @@ public abstract class CltBase
*/ */
protected CltBase() protected CltBase()
{ {
fContext = new ClassPathXmlApplicationContext("clt-context.xml"); fContext = new FixedClassPathXmlApplicationContext("clt-context.xml");
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote"); fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService"); fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService");
fRepoRemote = (RepoRemote)fContext.getBean("repoRemote"); fRepoRemote = (RepoRemote)fContext.getBean("repoRemote");

View File

@@ -40,7 +40,8 @@ import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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 * 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 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); private static Log logger = LogFactory.getLog(AbstractReadOnlyContentStoreTest.class);
protected ApplicationEventPublisher applicationEventPublisher;
protected TransactionService transactionService; protected TransactionService transactionService;
private UserTransaction txn; private UserTransaction txn;
@@ -72,6 +74,7 @@ public abstract class AbstractReadOnlyContentStoreTest extends TestCase
@Override @Override
public void setUp() throws Exception public void setUp() throws Exception
{ {
applicationEventPublisher = (ApplicationEventPublisher) ctx.getBean("applicationEventPublisher");
transactionService = (TransactionService) ctx.getBean("TransactionService"); transactionService = (TransactionService) ctx.getBean("TransactionService");
txn = transactionService.getUserTransaction(); txn = transactionService.getUserTransaction();
txn.begin(); txn.begin();

View File

@@ -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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 * 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 * the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's * 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: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * http://www.alfresco.com/legal/licensing"
*/ */
@@ -69,10 +69,7 @@ import org.alfresco.util.Pair;
import org.alfresco.util.TempFileProvider; import org.alfresco.util.TempFileProvider;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
/** /**
@@ -86,7 +83,7 @@ import org.springframework.context.ConfigurableApplicationContext;
* @author Derek Hulley * @author Derek Hulley
* @since 3.2 * @since 3.2
*/ */
public class ContentServiceImpl implements ContentService, ApplicationContextAware public class ContentServiceImpl implements ContentService
{ {
private static Log logger = LogFactory.getLog(ContentServiceImpl.class); private static Log logger = LogFactory.getLog(ContentServiceImpl.class);
@@ -94,7 +91,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
private NodeService nodeService; private NodeService nodeService;
private AVMService avmService; private AVMService avmService;
private RetryingTransactionHelper transactionHelper; private RetryingTransactionHelper transactionHelper;
private ApplicationContext applicationContext; private ApplicationEventPublisher applicationEventPublisher;
/** a registry of all available content transformers */ /** a registry of all available content transformers */
private ContentTransformerRegistry transformerRegistry; private ContentTransformerRegistry transformerRegistry;
@@ -163,14 +160,16 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
{ {
this.imageMagickContentTransformer = imageMagickContentTransformer; this.imageMagickContentTransformer = imageMagickContentTransformer;
} }
/**
/* (non-Javadoc) * Sets the application event publisher.
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) *
* @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() public void init()
{ {
// Set up a temporary store // Set up a temporary store
this.tempStore = new FileContentStore((ConfigurableApplicationContext) this.applicationContext, this.tempStore = new FileContentStore(this.applicationEventPublisher, TempFileProvider.getTempDir()
TempFileProvider.getTempDir().getAbsolutePath()); .getAbsolutePath());
// Bind on update properties behaviour // Bind on update properties behaviour
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(

View File

@@ -65,13 +65,13 @@ public class RoutingContentStoreTest extends AbstractWritableContentStoreTest
File tempDir = TempFileProvider.getTempDir(); File tempDir = TempFileProvider.getTempDir();
// Create a subdirectory for A // Create a subdirectory for A
File storeADir = new File(tempDir, "A"); File storeADir = new File(tempDir, "A");
storeA = new FileContentStore(ctx, storeADir); storeA = new FileContentStore(applicationEventPublisher, storeADir);
// Create a subdirectory for B // Create a subdirectory for B
File storeBDir = new File(tempDir, "B"); File storeBDir = new File(tempDir, "B");
storeB = new FileContentStore(ctx, storeBDir); storeB = new FileContentStore(applicationEventPublisher, storeBDir);
// Create a subdirectory for C // Create a subdirectory for C
File storeCDir = new File(tempDir, "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 // No subdirectory for D
storeD = new SupportsNoUrlFormatStore(); storeD = new SupportsNoUrlFormatStore();
// Create the routing store // Create the routing store

View File

@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of * 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 * the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's * 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: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * 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.Tenant;
import org.alfresco.repo.tenant.TenantDeployer; import org.alfresco.repo.tenant.TenantDeployer;
import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantService;
import org.springframework.beans.BeansException; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
/** /**
* Content Store that supports tenant routing, if multi-tenancy is enabled. * 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. * 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 // cache of tenant file stores
Map<String, FileContentStore> tenantFileStores = new ConcurrentHashMap<String, FileContentStore>(); Map<String, FileContentStore> tenantFileStores = new ConcurrentHashMap<String, FileContentStore>();
private String defaultRootDirectory; private String defaultRootDirectory;
private TenantService tenantService; private TenantService tenantService;
private ApplicationContext applicationContext; private ApplicationEventPublisher applicationEventPublisher;
public void setDefaultRootDir(String defaultRootDirectory) public void setDefaultRootDir(String defaultRootDirectory)
@@ -65,17 +62,18 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i
{ {
this.tenantService = tenantService; this.tenantService = tenantService;
} }
/* /**
* (non-Javadoc) * Sets the application event publisher.
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context. *
* ApplicationContext) * @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 @Override
protected ContentStore selectWriteStore(ContentContext ctx) protected ContentStore selectWriteStore(ContentContext ctx)
{ {
@@ -138,8 +136,7 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i
tenantDomain = tenant.getTenantDomain(); tenantDomain = tenant.getTenantDomain();
} }
putTenantFileStore(tenantDomain, new FileContentStore((ConfigurableApplicationContext) this.applicationContext, putTenantFileStore(tenantDomain, new FileContentStore(this.applicationEventPublisher, new File(rootDir)));
new File(rootDir)));
} }
public void destroy() public void destroy()

View File

@@ -59,7 +59,8 @@ import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.GUID; import org.alfresco.util.GUID;
import org.alfresco.util.TempFileProvider; 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 * @see org.alfresco.repo.content.cleanup.ContentStoreCleaner
@@ -68,7 +69,7 @@ import org.springframework.context.ConfigurableApplicationContext;
*/ */
public class ContentStoreCleanerTest extends TestCase public class ContentStoreCleanerTest extends TestCase
{ {
private static ConfigurableApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
private ContentService contentService; private ContentService contentService;
private NodeService nodeService; private NodeService nodeService;
@@ -96,12 +97,14 @@ public class ContentStoreCleanerTest extends TestCase
AVMNodeDAO avmNodeDAO = (AVMNodeDAO) ctx.getBean("newAvmNodeDAO"); AVMNodeDAO avmNodeDAO = (AVMNodeDAO) ctx.getBean("newAvmNodeDAO");
ContentCleanDAO contentCleanDAO = (ContentCleanDAO) ctx.getBean("contentCleanDAO"); ContentCleanDAO contentCleanDAO = (ContentCleanDAO) ctx.getBean("contentCleanDAO");
ContentDataDAO contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); ContentDataDAO contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO");
ApplicationEventPublisher applicationEventPublisher = (ApplicationEventPublisher) ctx
.getBean("applicationEventPublisher");
eagerCleaner = (EagerContentStoreCleaner) ctx.getBean("eagerContentStoreCleaner"); eagerCleaner = (EagerContentStoreCleaner) ctx.getBean("eagerContentStoreCleaner");
eagerCleaner.setEagerOrphanCleanup(false); eagerCleaner.setEagerOrphanCleanup(false);
// we need a store // we need a store
store = new FileContentStore(ctx, TempFileProvider.getTempDir().getAbsolutePath()); store = new FileContentStore(applicationEventPublisher, TempFileProvider.getTempDir().getAbsolutePath());
// and a listener // and a listener
listener = new DummyCleanerListener(); listener = new DummyCleanerListener();
// initialise record of deleted URLs // initialise record of deleted URLs

View File

@@ -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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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.alfresco.util.Pair;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;
/** /**
* Provides a store of node content directly to the file system. The writers * 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 * @author Derek Hulley
*/ */
public class FileContentStore extends AbstractContentStore implements ApplicationContextAware, ApplicationListener public class FileContentStore extends AbstractContentStore
{ {
/** /**
* <b>store</b> is the new prefix for file content URLs * <b>store</b> is the new prefix for file content URLs
@@ -75,7 +70,7 @@ public class FileContentStore extends AbstractContentStore implements Applicatio
private String rootAbsolutePath; private String rootAbsolutePath;
private boolean allowRandomAccess; private boolean allowRandomAccess;
private boolean readOnly; private boolean readOnly;
private ApplicationContext applicationContext; private ApplicationEventPublisher applicationEventPublisher;
/** /**
* Private: for Spring-constructed instances only. * Private: for Spring-constructed instances only.
@@ -113,32 +108,32 @@ public class FileContentStore extends AbstractContentStore implements Applicatio
/** /**
* Public constructor for programmatic use. * Public constructor for programmatic use.
* *
* @param context * @param applicationEventPublisher
* application context through which events can be published * the application event publisher
* @param rootDirectoryStr * @param rootDirectoryStr
* the root under which files will be stored. The directory will be created if it does not exist. * the root under which files will be stored. The directory will be created if it does not exist.
* @see FileContentStore#FileContentStore(File) * @see FileContentStore#FileContentStore(File)
*/ */
public FileContentStore(ConfigurableApplicationContext context, String rootDirectoryStr) public FileContentStore(ApplicationEventPublisher applicationEventPublisher, String rootDirectoryStr)
{ {
this(rootDirectoryStr); this(rootDirectoryStr);
setApplicationContext(context); setApplicationEventPublisher(applicationEventPublisher);
publishEvent(context); publishEvent();
} }
/** /**
* Public constructor for programmatic use. * Public constructor for programmatic use.
* *
* @param context * @param applicationEventPublisher
* application context through which events can be published * the application event publisher
* @param rootDirectory * @param rootDirectory
* the root under which files will be stored. The directory will be created if it does not exist. * 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); this(rootDirectory);
setApplicationContext(context); setApplicationEventPublisher(applicationEventPublisher);
publishEvent(context); publishEvent();
} }
@@ -153,13 +148,16 @@ public class FileContentStore extends AbstractContentStore implements Applicatio
return sb.toString(); 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 * Publishes an event to the application context that will notify any interested parties of the existence of this
* content store. * 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 this.applicationEventPublisher.publishEvent(new ContentStoreCreatedEvent(this));
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));
}
} }
} }

View File

@@ -52,10 +52,8 @@ public class FileContentStoreTest extends AbstractWritableContentStoreTest
// create a store that uses a subdirectory of the temp directory // create a store that uses a subdirectory of the temp directory
File tempDir = TempFileProvider.getTempDir(); File tempDir = TempFileProvider.getTempDir();
store = new FileContentStore(ctx, store = new FileContentStore(applicationEventPublisher, tempDir.getAbsolutePath() + File.separatorChar
tempDir.getAbsolutePath() + + getName());
File.separatorChar +
getName());
} }
@Override @Override

View File

@@ -49,10 +49,8 @@ public class NoRandomAccessFileContentStoreTest extends AbstractWritableContentS
// create a store that uses a subdirectory of the temp directory // create a store that uses a subdirectory of the temp directory
File tempDir = TempFileProvider.getTempDir(); File tempDir = TempFileProvider.getTempDir();
store = new FileContentStore(ctx, store = new FileContentStore(applicationEventPublisher, tempDir.getAbsolutePath() + File.separatorChar
tempDir.getAbsolutePath() + + getName());
File.separatorChar +
getName());
// disallow random access // disallow random access
store.setAllowRandomAccess(false); store.setAllowRandomAccess(false);
} }

View File

@@ -50,10 +50,8 @@ public class ReadOnlyFileContentStoreTest extends AbstractReadOnlyContentStoreTe
// create a store that uses a subdirectory of the temp directory // create a store that uses a subdirectory of the temp directory
File tempDir = TempFileProvider.getTempDir(); File tempDir = TempFileProvider.getTempDir();
store = new FileContentStore(ctx, store = new FileContentStore(applicationEventPublisher, tempDir.getAbsolutePath() + File.separatorChar
tempDir.getAbsolutePath() + + getName());
File.separatorChar +
getName());
// disallow random access // disallow random access
store.setReadOnly(true); store.setReadOnly(true);
} }

View File

@@ -30,6 +30,7 @@ import java.net.URL;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ActionImpl; import org.alfresco.repo.action.ActionImpl;
import org.alfresco.repo.action.executer.ActionExecuter; 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.GUID;
import org.alfresco.util.PropertyMap; import org.alfresco.util.PropertyMap;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* Tests various aspects of XML metadata extraction. * 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 FILE_MALFORMED = "xml-metadata/malformed-sample.xml";
private static final String CTX_LOCATION = "classpath:xml-metadata/xml-metadata-test-context.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 ServiceRegistry serviceRegistry;
private AuthenticationComponent authenticationComponent; private AuthenticationComponent authenticationComponent;

View File

@@ -37,7 +37,7 @@ import org.alfresco.repo.content.filestore.FileContentStore;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.util.GUID; import org.alfresco.util.GUID;
import org.alfresco.util.TempFileProvider; import org.alfresco.util.TempFileProvider;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticApplicationContext;
/** /**

View File

@@ -70,7 +70,7 @@ public class ReplicatingContentStoreTest extends AbstractWritableContentStoreTes
File tempDir = TempFileProvider.getTempDir(); File tempDir = TempFileProvider.getTempDir();
// create a primary file store // create a primary file store
String storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate(); String storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate();
primaryStore = new FileContentStore(ctx, storeDir); primaryStore = new FileContentStore(applicationEventPublisher, storeDir);
// create some secondary file stores // create some secondary file stores
secondaryStores = new ArrayList<ContentStore>(3); secondaryStores = new ArrayList<ContentStore>(3);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)

View File

@@ -42,6 +42,7 @@ import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.Pair; import org.alfresco.util.Pair;
import org.alfresco.util.TempFileProvider; import org.alfresco.util.TempFileProvider;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
/** /**
@@ -65,9 +66,10 @@ public class ContentDataDAOTest extends TestCase
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
transactionService = serviceRegistry.getTransactionService(); transactionService = serviceRegistry.getTransactionService();
txnHelper = transactionService.getRetryingTransactionHelper(); txnHelper = transactionService.getRetryingTransactionHelper();
ApplicationEventPublisher applicationEventPublisher = (ApplicationEventPublisher) ctx.getBean("applicationEventPublisher");
contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO");
contentStore = new FileContentStore(ctx, TempFileProvider.getTempDir()); contentStore = new FileContentStore(applicationEventPublisher, TempFileProvider.getTempDir());
} }
private Pair<Long, ContentData> create(final ContentData contentData) private Pair<Long, ContentData> create(final ContentData contentData)

View File

@@ -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<ApplicationEvent> queuedEvents = new LinkedList<ApplicationEvent>();
/*
* (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);
}
}
}

View File

@@ -27,7 +27,6 @@ package org.alfresco.repo.management.subsystems;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
@@ -36,12 +35,12 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent; 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 * 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. * 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() public DefaultResolver()
{ {
setIgnoreUnresolvablePlaceholders(true); super("${", "}", ":", true);
} }
/** /**
@@ -508,8 +507,8 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/ */
public String resolveValue(String val) public String resolveValue(String val)
{ {
return AbstractPropertyBackedBean.this.propertyDefaults == null ? null : parseStringValue(val, return AbstractPropertyBackedBean.this.propertyDefaults == null ? null : replacePlaceholders(
AbstractPropertyBackedBean.this.propertyDefaults, new HashSet<Object>()); val, AbstractPropertyBackedBean.this.propertyDefaults);
} }
} }

View File

@@ -36,6 +36,7 @@ import java.util.StringTokenizer;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.config.JBossEnabledResourcePatternResolver; import org.alfresco.config.JBossEnabledResourcePatternResolver;
import org.alfresco.config.JndiPropertiesFactoryBean; import org.alfresco.config.JndiPropertiesFactoryBean;
import org.alfresco.util.config.RepositoryPathConfigBean; import org.alfresco.util.config.RepositoryPathConfigBean;
@@ -350,12 +351,12 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
* *
* @author dward * @author dward
*/ */
private class ChildApplicationContext extends ClassPathXmlApplicationContext private class ChildApplicationContext extends FixedClassPathXmlApplicationContext
{ {
/** The composite property values. */ /** The composite property values. */
private Map<String, Map<String, CompositeDataBean>> compositeProperties; private Map<String, Map<String, CompositeDataBean>> compositeProperties;
/** /**
* The Constructor. * The Constructor.
* *
@@ -373,8 +374,14 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
{ {
ChildApplicationContextFactory.CLASSPATH_PREFIX + getCategory() + '/' + getTypeName() ChildApplicationContextFactory.CLASSPATH_PREFIX + getCategory() + '/' + getTypeName()
+ ChildApplicationContextFactory.CONTEXT_SUFFIX, + ChildApplicationContextFactory.CONTEXT_SUFFIX,
ChildApplicationContextFactory.EXTENSION_CLASSPATH_PREFIX + getCategory() + '/' + getTypeName() + '/' ChildApplicationContextFactory.EXTENSION_CLASSPATH_PREFIX
+ getId().get(getId().size() - 1) + '/' + ChildApplicationContextFactory.CONTEXT_SUFFIX + getCategory()
+ '/'
+ getTypeName()
+ '/'
+ ChildApplicationContextFactory.this.getId().get(
ChildApplicationContextFactory.this.getId().size() - 1) + '/'
+ ChildApplicationContextFactory.CONTEXT_SUFFIX
}, false, ChildApplicationContextFactory.this.getParent()); }, false, ChildApplicationContextFactory.this.getParent());
this.compositeProperties = compositeProperties; this.compositeProperties = compositeProperties;

View File

@@ -30,6 +30,7 @@ import javax.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.ServiceRegistry; 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.cmr.search.CategoryService;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* Tests various module components. * Tests various module components.
@@ -52,7 +52,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/ */
public class ComponentsTest extends TestCase 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 ServiceRegistry serviceRegistry;
private AuthenticationComponent authenticationComponent; private AuthenticationComponent authenticationComponent;

View File

@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.repo.search.BackgroundIndexerAware; import org.alfresco.repo.search.BackgroundIndexerAware;
import org.alfresco.repo.search.Indexer; import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.search.IndexerAndSearcher; 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.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* Background index update scheduler * Background index update scheduler
@@ -242,7 +241,7 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
public static void main(String[] args) throws InterruptedException public static void main(String[] args) throws InterruptedException
{ {
@SuppressWarnings("unused") @SuppressWarnings("unused")
ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml"); ApplicationContext ctx = new FixedClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
} }

View File

@@ -101,6 +101,7 @@ import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.store.RAMDirectory;
import org.safehaus.uuid.UUID; import org.safehaus.uuid.UUID;
import org.saxpath.SAXPathException; import org.saxpath.SAXPathException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
@@ -2510,7 +2511,7 @@ public class IndexInfo implements IndexMonitor
static Query getPathQuery(String path) throws SAXPathException static Query getPathQuery(String path) throws SAXPathException
{ {
ConfigurableApplicationContext ac = ApplicationContextHelper.getApplicationContext(); ApplicationContext ac = ApplicationContextHelper.getApplicationContext();
XPathReader reader = new XPathReader(); XPathReader reader = new XPathReader();
LuceneXPathHandler handler = new LuceneXPathHandler(); LuceneXPathHandler handler = new LuceneXPathHandler();
handler.setNamespacePrefixResolver((NamespaceService) ac.getBean("namespaceService")); handler.setNamespacePrefixResolver((NamespaceService) ac.getBean("namespaceService"));

View File

@@ -65,7 +65,7 @@ public class PublicServiceAccessServiceImpl implements PublicServiceAccessServic
{ {
if (method.getParameterTypes().length == args.length) if (method.getParameterTypes().length == args.length)
{ {
methodInvocation = new ReflectiveMethodInvocation(null, null, method, args, null, null); methodInvocation = new ReflectiveMethodInvocation(null, null, method, args, null, null) {};
} }
} }
} }

View File

@@ -39,6 +39,7 @@ import java.util.Set;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.management.subsystems.ChildApplicationContextManager; import org.alfresco.repo.management.subsystems.ChildApplicationContextManager;
import org.alfresco.repo.security.authentication.AuthenticationContext; 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.GUID;
import org.alfresco.util.PropertyMap; import org.alfresco.util.PropertyMap;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticApplicationContext;
/** /**
@@ -70,7 +70,7 @@ public class ChainingUserRegistrySynchronizerTest extends TestCase
}; };
/** The Spring application context. */ /** The Spring application context. */
private static ApplicationContext context = new ClassPathXmlApplicationContext( private static ApplicationContext context = new FixedClassPathXmlApplicationContext(
ChainingUserRegistrySynchronizerTest.CONFIG_LOCATIONS); ChainingUserRegistrySynchronizerTest.CONFIG_LOCATIONS);
/** The synchronizer we are testing. */ /** The synchronizer we are testing. */

View File

@@ -24,12 +24,12 @@
*/ */
package org.alfresco.repo.service; 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.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import junit.framework.TestCase;
public class StoreRedirectorProxyFactoryTest extends TestCase public class StoreRedirectorProxyFactoryTest extends TestCase
{ {
@@ -38,7 +38,7 @@ public class StoreRedirectorProxyFactoryTest extends TestCase
public void setUp() public void setUp()
{ {
factory = new ClassPathXmlApplicationContext("org/alfresco/repo/service/testredirector.xml"); factory = new FixedClassPathXmlApplicationContext("org/alfresco/repo/service/testredirector.xml");
} }
public void testRedirect() public void testRedirect()

View File

@@ -37,6 +37,7 @@ import java.util.Set;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MultiTDemoTest extends TestCase public class MultiTDemoTest extends TestCase
{ {
private static Log logger = LogFactory.getLog(MultiTDemoTest.class); 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"} new String[] {ApplicationContextHelper.CONFIG_LOCATIONS[0], "classpath:tenant/mt-*context.xml"}
); );

View File

@@ -26,7 +26,8 @@ package org.alfresco.util;
import java.util.Arrays; 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; import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
@@ -52,7 +53,7 @@ public class ApplicationContextHelper
* *
* @return Returns an application context for the default Alfresco configuration * @return Returns an application context for the default Alfresco configuration
*/ */
public synchronized static ConfigurableApplicationContext getApplicationContext() public synchronized static ApplicationContext getApplicationContext()
{ {
return getApplicationContext(CONFIG_LOCATIONS); return getApplicationContext(CONFIG_LOCATIONS);
} }
@@ -66,7 +67,7 @@ public class ApplicationContextHelper
* *
* @return Returns an application context for the given configuration * @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) if (configLocations == null)
{ {
@@ -80,7 +81,7 @@ public class ApplicationContextHelper
// The config has changed so close the current context (if any) // The config has changed so close the current context (if any)
closeApplicationContext(); closeApplicationContext();
instance = new ClassPathXmlApplicationContext(configLocations); instance = new FixedClassPathXmlApplicationContext(configLocations);
usedConfiguration = configLocations; usedConfiguration = configLocations;
return instance; return instance;

View File

@@ -24,10 +24,10 @@
*/ */
package org.alfresco.util; package org.alfresco.util;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.SessionFactoryUtils; import org.springframework.orm.hibernate3.SessionFactoryUtils;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
@@ -120,7 +120,7 @@ public abstract class BaseSpringTest extends AbstractTransactionalDataSourceSpri
else else
{ {
String[] configLocations = (String[]) key; String[] configLocations = (String[]) key;
return new ClassPathXmlApplicationContext(configLocations); return new FixedClassPathXmlApplicationContext(configLocations);
} }
} }
} }

View File

@@ -47,6 +47,7 @@ import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.TypeNames; import org.hibernate.dialect.TypeNames;
@@ -101,7 +102,7 @@ public class Main
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Main(final String contextPath) throws Exception public Main(final String contextPath) throws Exception
{ {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] final ClassPathXmlApplicationContext context = new FixedClassPathXmlApplicationContext(new String[]
{ {
"file:" + contextPath "file:" + contextPath
}); });

View File

@@ -28,6 +28,7 @@ import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.config.FixedClassPathXmlApplicationContext;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* Abstract WCM Service implementation unit test * Abstract WCM Service implementation unit test
@@ -65,7 +65,7 @@ public class AbstractWCMServiceImplTest extends TestCase
protected static final int POLL_MAX_ATTEMPTS = 10; protected static final int POLL_MAX_ATTEMPTS = 10;
// note: all tests share same context (when run via WCMTestSuite) // 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 // test data

View File

@@ -25,6 +25,9 @@
<!-- --> <!-- -->
<bean id="tenantFileContentStore" class="org.alfresco.repo.content.TenantRoutingFileContentStore" init-method="init"> <bean id="tenantFileContentStore" class="org.alfresco.repo.content.TenantRoutingFileContentStore" init-method="init">
<property name="applicationEventPublisher">
<ref bean="applicationEventPublisher" />
</property>
<property name="defaultRootDir"> <property name="defaultRootDir">
<value>${dir.contentstore}</value> <value>${dir.contentstore}</value>
</property> </property>