1 package com.atlassian.plugin.spring.scanner.dynamic.contexts;
2
3 import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;
4 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
5 import org.springframework.context.ApplicationContext;
6
7 /**
8 * This is a copy of the NonValidatingOsgiBundleXmlApplicationContext that is in atlassian-osgi-spring-extender. Speaking
9 * to Don Brown about it he said the non validating version is faster for plugin startup which is why it was created.
10 * <p>
11 * It had to be copied since it hid the constructor that allows you to specify a parent context which is what we
12 * need if we are to have child-parent context relationships. This can be fixed upstream but for now it really such
13 * little code.
14 * <p>
15 * Original comments follow :
16 * <p>
17 * Application context that initializes the bean definition reader to not validate via XML Schema. Note that by
18 * turning this off, certain defaults won't be populated like expected. For example, XML Schema provides the default
19 * autowire value of "default", but without this validation, that value is not set so autowiring will be turned off.
20 * <p>
21 * This class exists in the same package as the parent so the log messages won't get confused as the parent class
22 * logs against the instance class.
23 *
24 * @since 2.5.0
25 */
26 public class GeminiOsgiBundleXmlApplicationContext extends OsgiBundleXmlApplicationContext {
27 public GeminiOsgiBundleXmlApplicationContext(String[] configLocations, ApplicationContext parent) {
28 super(configLocations, parent);
29 }
30
31 @Override
32 protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
33 super.initBeanDefinitionReader(beanDefinitionReader);
34 beanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
35 beanDefinitionReader.setNamespaceAware(true);
36 }
37 }