From 71cf67b6fee056874c6021a5fb8505a11efe7266 Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Wed, 25 Sep 2013 07:01:30 +0000 Subject: [PATCH] Merged DEV to HEAD (4.2) 55905: ALF-20066 : Changes made on any page of admin system-summary are not synchronised between nodes The DefaultPropertyBackedBeanRegistry was made transaction aware if the transaction is present, to ensure the transaction modifications to be replicated to other nodes in the cluster before the node restart signal is sent to them. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55934 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../DefaultPropertyBackedBeanRegistry.java | 65 +++++++++++++++++-- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/source/java/org/alfresco/repo/management/subsystems/DefaultPropertyBackedBeanRegistry.java b/source/java/org/alfresco/repo/management/subsystems/DefaultPropertyBackedBeanRegistry.java index 4af5cc84d5..33c98b8e12 100644 --- a/source/java/org/alfresco/repo/management/subsystems/DefaultPropertyBackedBeanRegistry.java +++ b/source/java/org/alfresco/repo/management/subsystems/DefaultPropertyBackedBeanRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2012 Alfresco Software Limited. + * Copyright (C) 2005-2013 Alfresco Software Limited. * * This file is part of Alfresco * @@ -25,6 +25,8 @@ import java.util.Map; import org.alfresco.repo.dictionary.DictionaryRepositoryBootstrappedEvent; import org.alfresco.repo.domain.schema.SchemaAvailableEvent; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.repo.transaction.TransactionListener; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; @@ -36,7 +38,7 @@ import org.springframework.context.ApplicationListener; * * @author dward */ -public class DefaultPropertyBackedBeanRegistry implements PropertyBackedBeanRegistry, ApplicationListener +public class DefaultPropertyBackedBeanRegistry implements PropertyBackedBeanRegistry, ApplicationListener, TransactionListener { /** Is the database schema available yet? */ private boolean isSchemaAvailable; @@ -46,6 +48,9 @@ public class DefaultPropertyBackedBeanRegistry implements PropertyBackedBeanRegi /** Events deferred until the database schema is available. */ private List deferredEvents = new LinkedList(); + /** Events to be broadcasted after the transaction finished. */ + private List afterTransactionEvents = new LinkedList(); + /** Registered listeners. */ private List listeners = new LinkedList(); @@ -144,9 +149,22 @@ public class DefaultPropertyBackedBeanRegistry implements PropertyBackedBeanRegi // If the system is up and running, broadcast the event immediately if (this.isSchemaAvailable && this.wasDictionaryBootstrapped) { - for (ApplicationListener listener : this.listeners) + // If we have a transaction, the changed properties in it should be updated earlier, + // then the bean restart message will be sent to other node + // see ALF-20066 + if (AlfrescoTransactionSupport.getTransactionId() != null && + (event instanceof PropertyBackedBeanStartedEvent || + event instanceof PropertyBackedBeanStoppedEvent)) { - listener.onApplicationEvent(event); + this.afterTransactionEvents.add(event); + AlfrescoTransactionSupport.bindListener(this); + } + else + { + for (ApplicationListener listener : this.listeners) + { + listener.onApplicationEvent(event); + } } } // Otherwise, defer broadcasting until the schema available event is handled @@ -193,7 +211,42 @@ public class DefaultPropertyBackedBeanRegistry implements PropertyBackedBeanRegi this.deferredEvents.clear(); } } - - + } + + @Override + public void beforeCommit(boolean readOnly) + { + // No-op + } + + @Override + public void afterCommit() + { + for (ApplicationEvent event : this.afterTransactionEvents) + { + for (ApplicationListener listener : this.listeners) + { + listener.onApplicationEvent(event); + } + } + this.afterTransactionEvents.clear(); + } + + @Override + public void beforeCompletion() + { + // No-op + } + + @Override + public void afterRollback() + { + // No-op + } + + @Override + public void flush() + { + // No-op } }