From f05d0885ef4076b6430f144ddb8e47627e5eee80 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 21 Feb 2013 16:26:10 -0800 Subject: [PATCH] Add AnnotationConfigApplicationContext constructor Add AnnotationConfigApplicationContext constructor allow use of a custom DefaultListableBeanFactory. Issue: SPR-10529 --- .../AnnotationConfigApplicationContext.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java index 4576ab3bba1..f09664f204c 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.context.annotation; import org.springframework.beans.factory.support.BeanNameGenerator; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.util.Assert; @@ -61,6 +62,16 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex this.scanner = new ClassPathBeanDefinitionScanner(this); } + /** + * Create a new AnnotationConfigApplicationContext with the given DefaultListableBeanFactory. + * @param beanFactory the DefaultListableBeanFactory instance to use for this context + */ + public AnnotationConfigApplicationContext(DefaultListableBeanFactory beanFactory) { + super(beanFactory); + this.reader = new AnnotatedBeanDefinitionReader(this); + this.scanner = new ClassPathBeanDefinitionScanner(this); + } + /** * Create a new AnnotationConfigApplicationContext, deriving bean definitions * from the given annotated classes and automatically refreshing the context.