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); + } + } }