Commit a7378ac0fcbbe9c788f29987b50d299a44da92cf
1 parent
4b3930e124
Exists in
master
MNT-16541: "Cache update for custom workflow model fails"
Showing
4 changed files
with
48 additions
and
13 deletions
Show diff stats
src/main/java/org/alfresco/opencmis/dictionary/CMISDictionaryRegistryImpl.java
... | ... | @@ -33,7 +33,6 @@ import java.util.LinkedList; |
33 | 33 | import java.util.List; |
34 | 34 | import java.util.Map; |
35 | 35 | |
36 | -import org.alfresco.error.AlfrescoRuntimeException; | |
37 | 36 | import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryInitializer; |
38 | 37 | import org.alfresco.opencmis.mapping.CMISMapping; |
39 | 38 | import org.alfresco.repo.dictionary.CompiledModel; | ... | ... |
src/main/java/org/alfresco/repo/dictionary/CompiledModelsCache.java
... | ... | @@ -29,6 +29,9 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; |
29 | 29 | import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; |
30 | 30 | import org.alfresco.repo.tenant.TenantService; |
31 | 31 | import org.alfresco.util.cache.AbstractAsynchronouslyRefreshedCache; |
32 | +import org.alfresco.util.cache.RefreshableCacheEvent; | |
33 | +import org.alfresco.util.cache.RefreshableCacheListener; | |
34 | +import org.alfresco.util.cache.RefreshableCacheRefreshedEvent; | |
32 | 35 | import org.apache.commons.logging.Log; |
33 | 36 | import org.apache.commons.logging.LogFactory; |
34 | 37 | |
... | ... | @@ -103,4 +106,49 @@ public class CompiledModelsCache extends AbstractAsynchronouslyRefreshedCache<Di |
103 | 106 | { |
104 | 107 | this.tenantService = tenantService; |
105 | 108 | } |
109 | + | |
110 | + @Override | |
111 | + public void afterPropertiesSet() throws Exception | |
112 | + { | |
113 | + super.afterPropertiesSet(); | |
114 | + // RefreshableCacheListener as anonymous class since CompileModelsCache already | |
115 | + // implements this interface, but expects to be invoked in different circumstances. | |
116 | + register(new RefreshableCacheListener() | |
117 | + { | |
118 | + @Override | |
119 | + public void onRefreshableCacheEvent(RefreshableCacheEvent event) | |
120 | + { | |
121 | + if (logger.isDebugEnabled()) | |
122 | + { | |
123 | + logger.debug("Handling "+event.getClass().getSimpleName()+ | |
124 | + ", cache="+event.getCacheId()+ | |
125 | + ", key="+event.getKey()); | |
126 | + } | |
127 | + | |
128 | + if (event instanceof RefreshableCacheRefreshedEvent && | |
129 | + event.getCacheId().equals(getCacheId())) | |
130 | + { | |
131 | + // notify registered listeners that dictionary has been initialised (population is complete). | |
132 | + // Note we do that here to ensure that the dictionary registry has been added to the cache, | |
133 | + // so that any dependencies (like the CMIS dictionary) will use the new dictionary. | |
134 | + for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners()) | |
135 | + { | |
136 | + logger.debug("Calling afterDIctionaryInit ["+event.getClass().getSimpleName()+ | |
137 | + ", cache="+event.getCacheId()+ | |
138 | + ", key="+event.getKey()+ | |
139 | + "] on "+ | |
140 | + dictionaryListener.getClass().getSimpleName()); | |
141 | + | |
142 | + dictionaryListener.afterDictionaryInit(); | |
143 | + } | |
144 | + } | |
145 | + } | |
146 | + | |
147 | + @Override | |
148 | + public String getCacheId() | |
149 | + { | |
150 | + return CompiledModelsCache.this.getCacheId(); | |
151 | + } | |
152 | + }); | |
153 | + } | |
106 | 154 | } | ... | ... |
src/main/java/org/alfresco/repo/dictionary/CoreDictionaryRegistryImpl.java
... | ... | @@ -59,12 +59,6 @@ public class CoreDictionaryRegistryImpl extends AbstractDictionaryRegistry |
59 | 59 | dictionaryDeployer.onDictionaryInit(); |
60 | 60 | } |
61 | 61 | |
62 | - // notify registered listeners that dictionary has been initialised (population is complete) | |
63 | - for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners()) | |
64 | - { | |
65 | - dictionaryListener.afterDictionaryInit(); | |
66 | - } | |
67 | - | |
68 | 62 | // Done |
69 | 63 | if (logger.isInfoEnabled()) |
70 | 64 | { | ... | ... |
src/main/java/org/alfresco/repo/dictionary/TenantDictionaryRegistryImpl.java
... | ... | @@ -221,12 +221,6 @@ public class TenantDictionaryRegistryImpl extends AbstractDictionaryRegistry |
221 | 221 | dictionaryDeployer.onDictionaryInit(); |
222 | 222 | } |
223 | 223 | |
224 | - // notify registered listeners that dictionary has been initialised (population is complete) | |
225 | - for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners()) | |
226 | - { | |
227 | - dictionaryListener.afterDictionaryInit(); | |
228 | - } | |
229 | - | |
230 | 224 | // Done |
231 | 225 | if (logger.isInfoEnabled()) |
232 | 226 | { | ... | ... |