From 7c238af116c2f95e41f23df7df8134145b1bc96d Mon Sep 17 00:00:00 2001 From: Jan Vonka Date: Wed, 29 Aug 2007 14:48:48 +0000 Subject: [PATCH] Fix for AMP init/bootstrap issue found by RW. Also, WebClientConfigBootstrap is now a ConfigDeployer to ensure AMP config is not lost in case of cache invalidation/reset (in preparation for dynamic WebClient config). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6630 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web-client-application-context.xml | 4 +- .../web/config/WebClientConfigBootstrap.java | 48 ++++++++++++++++--- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/config/alfresco/web-client-application-context.xml b/config/alfresco/web-client-application-context.xml index 304cdda285..d715c0988f 100644 --- a/config/alfresco/web-client-application-context.xml +++ b/config/alfresco/web-client-application-context.xml @@ -21,8 +21,8 @@ - - + + diff --git a/source/java/org/alfresco/web/config/WebClientConfigBootstrap.java b/source/java/org/alfresco/web/config/WebClientConfigBootstrap.java index 4591b68893..49547c4015 100644 --- a/source/java/org/alfresco/web/config/WebClientConfigBootstrap.java +++ b/source/java/org/alfresco/web/config/WebClientConfigBootstrap.java @@ -26,11 +26,11 @@ package org.alfresco.web.config; import java.util.List; +import org.alfresco.config.ConfigDeployer; import org.alfresco.config.ConfigService; -import org.alfresco.config.ConfigSource; import org.alfresco.config.source.UrlConfigSource; +import org.alfresco.error.AlfrescoRuntimeException; import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -40,11 +40,14 @@ import org.springframework.context.ApplicationContextAware; * * @author Roy Wetherall */ -public class WebClientConfigBootstrap implements ApplicationContextAware +public class WebClientConfigBootstrap implements ApplicationContextAware, ConfigDeployer { /** The application context */ private ApplicationContext applicationContext; + /** Dependency */ + private ConfigService configService; + /** List of configs */ private List configs; @@ -59,17 +62,21 @@ public class WebClientConfigBootstrap implements ApplicationContextAware } /** - * Initialisation method + * + * @deprecated */ public void init() { + // TODO - see JIRA Task AR-1715 - refactor calling modules to inject webClientConfigService, and use init-method="register" directly + // (instead of init-method="init"). Can then remove applicationContext and no longer implement ApplicationContextAware + if (this.applicationContext.containsBean("webClientConfigService") == true) { ConfigService configService = (ConfigService)this.applicationContext.getBean("webClientConfigService"); - if (configService != null && this.configs != null && this.configs.size() != 0) + if (configService != null) { - UrlConfigSource configSource = new UrlConfigSource(this.configs); - configService.appendConfig(configSource); + setConfigService(configService); + register(); } } } @@ -78,4 +85,31 @@ public class WebClientConfigBootstrap implements ApplicationContextAware { this.applicationContext = applicationContext; } + + public void setConfigService(ConfigService configService) + { + this.configService = configService; + } + + public void register() + { + if (configService == null) + { + throw new AlfrescoRuntimeException("Config service must be provided"); + } + + configService.addDeployer(this); + } + + /** + * Initialisation method + */ + public void initConfig() + { + if (configService != null && this.configs != null && this.configs.size() != 0) + { + UrlConfigSource configSource = new UrlConfigSource(this.configs); + configService.appendConfig(configSource); + } + } }