Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
57cad53e
Commit
57cad53e
authored
Apr 02, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt to latest API change
parent
3c21ade4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
476 deletions
+0
-476
AnnotationConfigReactiveWebApplicationContext.java
...ontext/AnnotationConfigReactiveWebApplicationContext.java
+0
-75
AnnotationConfigReactiveWebServerApplicationContext.java
.../AnnotationConfigReactiveWebServerApplicationContext.java
+0
-98
AnnotationConfigServletWebServerApplicationContext.java
...t/AnnotationConfigServletWebServerApplicationContext.java
+0
-103
AnnotationConfigReactiveWebApplicationContextTests.java
...t/AnnotationConfigReactiveWebApplicationContextTests.java
+0
-86
AnnotationConfigReactiveWebServerApplicationContextTests.java
...tationConfigReactiveWebServerApplicationContextTests.java
+0
-61
AnnotationConfigServletWebServerApplicationContextTests.java
...otationConfigServletWebServerApplicationContextTests.java
+0
-53
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebApplicationContext.java
View file @
57cad53e
...
@@ -16,11 +16,9 @@
...
@@ -16,11 +16,9 @@
package
org
.
springframework
.
boot
.
web
.
reactive
.
context
;
package
org
.
springframework
.
boot
.
web
.
reactive
.
context
;
import
java.lang.annotation.Annotation
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.function.Supplier
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
...
@@ -67,8 +65,6 @@ public class AnnotationConfigReactiveWebApplicationContext
...
@@ -67,8 +65,6 @@ public class AnnotationConfigReactiveWebApplicationContext
private
final
Set
<
String
>
basePackages
=
new
LinkedHashSet
<>();
private
final
Set
<
String
>
basePackages
=
new
LinkedHashSet
<>();
private
final
Set
<
BeanRegistration
>
registeredBeans
=
new
LinkedHashSet
<>();
@Override
@Override
protected
ConfigurableEnvironment
createEnvironment
()
{
protected
ConfigurableEnvironment
createEnvironment
()
{
return
new
StandardReactiveWebEnvironment
();
return
new
StandardReactiveWebEnvironment
();
...
@@ -143,23 +139,6 @@ public class AnnotationConfigReactiveWebApplicationContext
...
@@ -143,23 +139,6 @@ public class AnnotationConfigReactiveWebApplicationContext
this
.
annotatedClasses
.
addAll
(
Arrays
.
asList
(
annotatedClasses
));
this
.
annotatedClasses
.
addAll
(
Arrays
.
asList
(
annotatedClasses
));
}
}
@Override
@SafeVarargs
@SuppressWarnings
(
"varargs"
)
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Class
<?
extends
Annotation
>...
qualifiers
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
null
,
qualifiers
));
}
@Override
@SafeVarargs
@SuppressWarnings
(
"varargs"
)
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Supplier
<
T
>
supplier
,
Class
<?
extends
Annotation
>...
qualifiers
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
supplier
,
qualifiers
));
}
/**
/**
* Perform a scan within the specified base packages.
* Perform a scan within the specified base packages.
* <p>
* <p>
...
@@ -242,9 +221,6 @@ public class AnnotationConfigReactiveWebApplicationContext
...
@@ -242,9 +221,6 @@ public class AnnotationConfigReactiveWebApplicationContext
if
(!
this
.
basePackages
.
isEmpty
())
{
if
(!
this
.
basePackages
.
isEmpty
())
{
scanBasePackages
(
scanner
);
scanBasePackages
(
scanner
);
}
}
if
(!
this
.
registeredBeans
.
isEmpty
())
{
registerBeans
(
reader
);
}
String
[]
configLocations
=
getConfigLocations
();
String
[]
configLocations
=
getConfigLocations
();
if
(
configLocations
!=
null
)
{
if
(
configLocations
!=
null
)
{
registerConfigLocations
(
reader
,
scanner
,
configLocations
);
registerConfigLocations
(
reader
,
scanner
,
configLocations
);
...
@@ -269,16 +245,6 @@ public class AnnotationConfigReactiveWebApplicationContext
...
@@ -269,16 +245,6 @@ public class AnnotationConfigReactiveWebApplicationContext
scanner
.
scan
(
StringUtils
.
toStringArray
(
this
.
basePackages
));
scanner
.
scan
(
StringUtils
.
toStringArray
(
this
.
basePackages
));
}
}
private
void
registerBeans
(
AnnotatedBeanDefinitionReader
reader
)
{
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Registering supplied beans: ["
+
StringUtils
.
collectionToCommaDelimitedString
(
this
.
registeredBeans
)
+
"]"
);
}
this
.
registeredBeans
.
forEach
((
reg
)
->
reader
.
registerBean
(
reg
.
getAnnotatedClass
(),
reg
.
getSupplier
(),
reg
.
getQualifiers
()));
}
private
void
registerConfigLocations
(
AnnotatedBeanDefinitionReader
reader
,
private
void
registerConfigLocations
(
AnnotatedBeanDefinitionReader
reader
,
ClassPathBeanDefinitionScanner
scanner
,
String
[]
configLocations
)
ClassPathBeanDefinitionScanner
scanner
,
String
[]
configLocations
)
throws
LinkageError
{
throws
LinkageError
{
...
@@ -357,45 +323,4 @@ public class AnnotationConfigReactiveWebApplicationContext
...
@@ -357,45 +323,4 @@ public class AnnotationConfigReactiveWebApplicationContext
return
new
FilteredReactiveWebContextResource
(
path
);
return
new
FilteredReactiveWebContextResource
(
path
);
}
}
/**
* Holder for a programmatic bean registration.
*
* @see #registerBean(Class, Class[])
* @see #registerBean(Class, Supplier, Class[])
*/
private
static
class
BeanRegistration
{
private
final
Class
<?>
annotatedClass
;
private
final
Supplier
<?>
supplier
;
private
final
Class
<?
extends
Annotation
>[]
qualifiers
;
BeanRegistration
(
Class
<?>
annotatedClass
,
Supplier
<?>
supplier
,
Class
<?
extends
Annotation
>[]
qualifiers
)
{
this
.
annotatedClass
=
annotatedClass
;
this
.
supplier
=
supplier
;
this
.
qualifiers
=
qualifiers
;
}
public
Class
<?>
getAnnotatedClass
()
{
return
this
.
annotatedClass
;
}
@SuppressWarnings
(
"rawtypes"
)
public
Supplier
getSupplier
()
{
return
this
.
supplier
;
}
public
Class
<?
extends
Annotation
>[]
getQualifiers
()
{
return
this
.
qualifiers
;
}
@Override
public
String
toString
()
{
return
this
.
annotatedClass
.
getName
();
}
}
}
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebServerApplicationContext.java
View file @
57cad53e
...
@@ -16,11 +16,9 @@
...
@@ -16,11 +16,9 @@
package
org
.
springframework
.
boot
.
web
.
reactive
.
context
;
package
org
.
springframework
.
boot
.
web
.
reactive
.
context
;
import
java.lang.annotation.Annotation
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.function.Supplier
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
...
@@ -37,7 +35,6 @@ import org.springframework.stereotype.Component;
...
@@ -37,7 +35,6 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
/**
/**
* {@link ReactiveWebServerApplicationContext} that accepts annotated classes as input -
* {@link ReactiveWebServerApplicationContext} that accepts annotated classes as input -
...
@@ -70,8 +67,6 @@ public class AnnotationConfigReactiveWebServerApplicationContext
...
@@ -70,8 +67,6 @@ public class AnnotationConfigReactiveWebServerApplicationContext
private
String
[]
basePackages
;
private
String
[]
basePackages
;
private
final
Set
<
BeanRegistration
>
registeredBeans
=
new
LinkedHashSet
<>();
/**
/**
* Create a new {@link AnnotationConfigReactiveWebServerApplicationContext} that needs
* Create a new {@link AnnotationConfigReactiveWebServerApplicationContext} that needs
* to be populated through {@link #register} calls and then manually
* to be populated through {@link #register} calls and then manually
...
@@ -202,45 +197,6 @@ public class AnnotationConfigReactiveWebServerApplicationContext
...
@@ -202,45 +197,6 @@ public class AnnotationConfigReactiveWebServerApplicationContext
this
.
basePackages
=
basePackages
;
this
.
basePackages
=
basePackages
;
}
}
/**
* Register a bean from the given bean class.
* @param annotatedClass the class of the bean
* @param <T> the type of the bean
* @since 2.2.0
*/
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
null
,
null
));
}
/**
* Register a bean from the given bean class, using the given supplier for obtaining a
* new instance (typically declared as a lambda expression or method reference).
* @param annotatedClass the class of the bean
* @param supplier a callback for creating an instance of the bean
* @param <T> the type of the bean
* @since 2.2.0
*/
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Supplier
<
T
>
supplier
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
supplier
,
null
));
}
@Override
@SafeVarargs
@SuppressWarnings
(
"varargs"
)
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Class
<?
extends
Annotation
>...
qualifiers
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
null
,
qualifiers
));
}
@Override
@SafeVarargs
@SuppressWarnings
(
"varargs"
)
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Supplier
<
T
>
supplier
,
Class
<?
extends
Annotation
>...
qualifiers
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
supplier
,
qualifiers
));
}
@Override
@Override
protected
void
prepareRefresh
()
{
protected
void
prepareRefresh
()
{
this
.
scanner
.
clearCache
();
this
.
scanner
.
clearCache
();
...
@@ -256,60 +212,6 @@ public class AnnotationConfigReactiveWebServerApplicationContext
...
@@ -256,60 +212,6 @@ public class AnnotationConfigReactiveWebServerApplicationContext
if
(!
this
.
annotatedClasses
.
isEmpty
())
{
if
(!
this
.
annotatedClasses
.
isEmpty
())
{
this
.
reader
.
register
(
ClassUtils
.
toClassArray
(
this
.
annotatedClasses
));
this
.
reader
.
register
(
ClassUtils
.
toClassArray
(
this
.
annotatedClasses
));
}
}
if
(!
this
.
registeredBeans
.
isEmpty
())
{
registerBeans
(
this
.
reader
);
}
}
private
void
registerBeans
(
AnnotatedBeanDefinitionReader
reader
)
{
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Registering supplied beans: ["
+
StringUtils
.
collectionToCommaDelimitedString
(
this
.
registeredBeans
)
+
"]"
);
}
this
.
registeredBeans
.
forEach
((
reg
)
->
reader
.
registerBean
(
reg
.
getAnnotatedClass
(),
reg
.
getSupplier
(),
reg
.
getQualifiers
()));
}
/**
* Holder for a programmatic bean registration.
*
* @see #registerBean(Class, Class[])
* @see #registerBean(Class, Supplier, Class[])
*/
private
static
class
BeanRegistration
{
private
final
Class
<?>
annotatedClass
;
private
final
Supplier
<?>
supplier
;
private
final
Class
<?
extends
Annotation
>[]
qualifiers
;
BeanRegistration
(
Class
<?>
annotatedClass
,
Supplier
<?>
supplier
,
Class
<?
extends
Annotation
>[]
qualifiers
)
{
this
.
annotatedClass
=
annotatedClass
;
this
.
supplier
=
supplier
;
this
.
qualifiers
=
qualifiers
;
}
public
Class
<?>
getAnnotatedClass
()
{
return
this
.
annotatedClass
;
}
@SuppressWarnings
(
"rawtypes"
)
public
Supplier
getSupplier
()
{
return
this
.
supplier
;
}
public
Class
<?
extends
Annotation
>[]
getQualifiers
()
{
return
this
.
qualifiers
;
}
@Override
public
String
toString
()
{
return
this
.
annotatedClass
.
getName
();
}
}
}
}
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContext.java
View file @
57cad53e
...
@@ -16,14 +16,9 @@
...
@@ -16,14 +16,9 @@
package
org
.
springframework
.
boot
.
web
.
servlet
.
context
;
package
org
.
springframework
.
boot
.
web
.
servlet
.
context
;
import
java.lang.annotation.Annotation
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.function.Supplier
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
...
@@ -38,7 +33,6 @@ import org.springframework.core.env.ConfigurableEnvironment;
...
@@ -38,7 +33,6 @@ import org.springframework.core.env.ConfigurableEnvironment;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
/**
/**
...
@@ -62,8 +56,6 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
...
@@ -62,8 +56,6 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
public
class
AnnotationConfigServletWebServerApplicationContext
public
class
AnnotationConfigServletWebServerApplicationContext
extends
ServletWebServerApplicationContext
implements
AnnotationConfigRegistry
{
extends
ServletWebServerApplicationContext
implements
AnnotationConfigRegistry
{
private
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
private
final
AnnotatedBeanDefinitionReader
reader
;
private
final
AnnotatedBeanDefinitionReader
reader
;
private
final
ClassPathBeanDefinitionScanner
scanner
;
private
final
ClassPathBeanDefinitionScanner
scanner
;
...
@@ -72,8 +64,6 @@ public class AnnotationConfigServletWebServerApplicationContext
...
@@ -72,8 +64,6 @@ public class AnnotationConfigServletWebServerApplicationContext
private
String
[]
basePackages
;
private
String
[]
basePackages
;
private
final
Set
<
BeanRegistration
>
registeredBeans
=
new
LinkedHashSet
<>();
/**
/**
* Create a new {@link AnnotationConfigServletWebServerApplicationContext} that needs
* Create a new {@link AnnotationConfigServletWebServerApplicationContext} that needs
* to be populated through {@link #register} calls and then manually
* to be populated through {@link #register} calls and then manually
...
@@ -204,45 +194,6 @@ public class AnnotationConfigServletWebServerApplicationContext
...
@@ -204,45 +194,6 @@ public class AnnotationConfigServletWebServerApplicationContext
this
.
basePackages
=
basePackages
;
this
.
basePackages
=
basePackages
;
}
}
/**
* Register a bean from the given bean class.
* @param annotatedClass the class of the bean
* @param <T> the type of the bean
* @since 2.2.0
*/
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
null
,
null
));
}
/**
* Register a bean from the given bean class, using the given supplier for obtaining a
* new instance (typically declared as a lambda expression or method reference).
* @param annotatedClass the class of the bean
* @param supplier a callback for creating an instance of the bean
* @param <T> the type of the bean
* @since 2.2.0
*/
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Supplier
<
T
>
supplier
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
supplier
,
null
));
}
@Override
@SafeVarargs
@SuppressWarnings
(
"varargs"
)
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Class
<?
extends
Annotation
>...
qualifiers
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
null
,
qualifiers
));
}
@Override
@SafeVarargs
@SuppressWarnings
(
"varargs"
)
public
final
<
T
>
void
registerBean
(
Class
<
T
>
annotatedClass
,
Supplier
<
T
>
supplier
,
Class
<?
extends
Annotation
>...
qualifiers
)
{
this
.
registeredBeans
.
add
(
new
BeanRegistration
(
annotatedClass
,
supplier
,
qualifiers
));
}
@Override
@Override
protected
void
prepareRefresh
()
{
protected
void
prepareRefresh
()
{
this
.
scanner
.
clearCache
();
this
.
scanner
.
clearCache
();
...
@@ -258,60 +209,6 @@ public class AnnotationConfigServletWebServerApplicationContext
...
@@ -258,60 +209,6 @@ public class AnnotationConfigServletWebServerApplicationContext
if
(!
this
.
annotatedClasses
.
isEmpty
())
{
if
(!
this
.
annotatedClasses
.
isEmpty
())
{
this
.
reader
.
register
(
ClassUtils
.
toClassArray
(
this
.
annotatedClasses
));
this
.
reader
.
register
(
ClassUtils
.
toClassArray
(
this
.
annotatedClasses
));
}
}
if
(!
this
.
registeredBeans
.
isEmpty
())
{
registerBeans
(
this
.
reader
);
}
}
private
void
registerBeans
(
AnnotatedBeanDefinitionReader
reader
)
{
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Registering supplied beans: ["
+
StringUtils
.
collectionToCommaDelimitedString
(
this
.
registeredBeans
)
+
"]"
);
}
this
.
registeredBeans
.
forEach
((
reg
)
->
reader
.
registerBean
(
reg
.
getAnnotatedClass
(),
reg
.
getSupplier
(),
reg
.
getQualifiers
()));
}
/**
* Holder for a programmatic bean registration.
*
* @see #registerBean(Class, Class[])
* @see #registerBean(Class, Supplier, Class[])
*/
private
static
class
BeanRegistration
{
private
final
Class
<?>
annotatedClass
;
private
final
Supplier
<?>
supplier
;
private
final
Class
<?
extends
Annotation
>[]
qualifiers
;
BeanRegistration
(
Class
<?>
annotatedClass
,
Supplier
<?>
supplier
,
Class
<?
extends
Annotation
>[]
qualifiers
)
{
this
.
annotatedClass
=
annotatedClass
;
this
.
supplier
=
supplier
;
this
.
qualifiers
=
qualifiers
;
}
public
Class
<?>
getAnnotatedClass
()
{
return
this
.
annotatedClass
;
}
@SuppressWarnings
(
"rawtypes"
)
public
Supplier
getSupplier
()
{
return
this
.
supplier
;
}
public
Class
<?
extends
Annotation
>[]
getQualifiers
()
{
return
this
.
qualifiers
;
}
@Override
public
String
toString
()
{
return
this
.
annotatedClass
.
getName
();
}
}
}
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebApplicationContextTests.java
deleted
100644 → 0
View file @
3c21ade4
/*
* Copyright 2012-2019 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
reactive
.
context
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.springframework.context.annotation.Lazy
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link AnnotationConfigReactiveWebApplicationContext}
*
* @author Stephane Nicoll
*/
public
class
AnnotationConfigReactiveWebApplicationContextTests
{
private
AnnotationConfigReactiveWebApplicationContext
context
;
@After
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
public
void
registerBean
()
{
this
.
context
=
new
AnnotationConfigReactiveWebApplicationContext
();
this
.
context
.
registerBean
(
TestBean
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebApplicationContextTests.TestBean"
)).
isTrue
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithLazy
()
{
this
.
context
=
new
AnnotationConfigReactiveWebApplicationContext
();
this
.
context
.
registerBean
(
TestBean
.
class
,
Lazy
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebApplicationContextTests.TestBean"
)).
isFalse
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithSupplier
()
{
this
.
context
=
new
AnnotationConfigReactiveWebApplicationContext
();
this
.
context
.
registerBean
(
TestBean
.
class
,
TestBean:
:
new
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebApplicationContextTests.TestBean"
)).
isTrue
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithSupplierAndLazy
()
{
this
.
context
=
new
AnnotationConfigReactiveWebApplicationContext
();
this
.
context
.
registerBean
(
TestBean
.
class
,
TestBean:
:
new
,
Lazy
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebApplicationContextTests.TestBean"
)).
isFalse
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
private
static
class
TestBean
{
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebServerApplicationContextTests.java
View file @
57cad53e
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
web
.
reactive
.
context
;
package
org
.
springframework
.
boot
.
web
.
reactive
.
context
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.ServerManager
;
import
org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.ServerManager
;
...
@@ -26,7 +25,6 @@ import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
...
@@ -26,7 +25,6 @@ import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.event.ApplicationEventMulticaster
;
import
org.springframework.context.event.ApplicationEventMulticaster
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.context.event.SimpleApplicationEventMulticaster
;
import
org.springframework.context.event.SimpleApplicationEventMulticaster
;
...
@@ -44,13 +42,6 @@ public class AnnotationConfigReactiveWebServerApplicationContextTests {
...
@@ -44,13 +42,6 @@ public class AnnotationConfigReactiveWebServerApplicationContextTests {
private
AnnotationConfigReactiveWebServerApplicationContext
context
;
private
AnnotationConfigReactiveWebServerApplicationContext
context
;
@After
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
@Test
public
void
createFromScan
()
{
public
void
createFromScan
()
{
this
.
context
=
new
AnnotationConfigReactiveWebServerApplicationContext
(
this
.
context
=
new
AnnotationConfigReactiveWebServerApplicationContext
(
...
@@ -102,54 +93,6 @@ public class AnnotationConfigReactiveWebServerApplicationContextTests {
...
@@ -102,54 +93,6 @@ public class AnnotationConfigReactiveWebServerApplicationContextTests {
verifyContext
();
verifyContext
();
}
}
@Test
public
void
registerBean
()
{
this
.
context
=
new
AnnotationConfigReactiveWebServerApplicationContext
();
this
.
context
.
register
(
ExampleReactiveWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebServerApplicationContextTests.TestBean"
))
.
isTrue
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithLazy
()
{
this
.
context
=
new
AnnotationConfigReactiveWebServerApplicationContext
();
this
.
context
.
register
(
ExampleReactiveWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
,
Lazy
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebServerApplicationContextTests.TestBean"
))
.
isFalse
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithSupplier
()
{
this
.
context
=
new
AnnotationConfigReactiveWebServerApplicationContext
();
this
.
context
.
register
(
ExampleReactiveWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
,
TestBean:
:
new
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebServerApplicationContextTests.TestBean"
))
.
isTrue
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithSupplierAndLazy
()
{
this
.
context
=
new
AnnotationConfigReactiveWebServerApplicationContext
();
this
.
context
.
register
(
ExampleReactiveWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
,
TestBean:
:
new
,
Lazy
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigReactiveWebServerApplicationContextTests.TestBean"
))
.
isFalse
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
private
void
verifyContext
()
{
private
void
verifyContext
()
{
MockReactiveWebServerFactory
factory
=
this
.
context
MockReactiveWebServerFactory
factory
=
this
.
context
.
getBean
(
MockReactiveWebServerFactory
.
class
);
.
getBean
(
MockReactiveWebServerFactory
.
class
);
...
@@ -231,8 +174,4 @@ public class AnnotationConfigReactiveWebServerApplicationContextTests {
...
@@ -231,8 +174,4 @@ public class AnnotationConfigReactiveWebServerApplicationContextTests {
}
}
private
static
class
TestBean
{
}
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java
View file @
57cad53e
...
@@ -32,7 +32,6 @@ import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
...
@@ -32,7 +32,6 @@ import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import
org.springframework.boot.web.servlet.server.ServletWebServerFactory
;
import
org.springframework.boot.web.servlet.server.ServletWebServerFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.context.annotation.ScopedProxyMode
;
import
org.springframework.context.annotation.ScopedProxyMode
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -142,54 +141,6 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
...
@@ -142,54 +141,6 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
.
getServletContext
()).
isNotNull
();
.
getServletContext
()).
isNotNull
();
}
}
@Test
public
void
registerBean
()
{
this
.
context
=
new
AnnotationConfigServletWebServerApplicationContext
();
this
.
context
.
register
(
ExampleServletWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigServletWebServerApplicationContextTests.TestBean"
))
.
isTrue
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithLazy
()
{
this
.
context
=
new
AnnotationConfigServletWebServerApplicationContext
();
this
.
context
.
register
(
ExampleServletWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
,
Lazy
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigServletWebServerApplicationContextTests.TestBean"
))
.
isFalse
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithSupplier
()
{
this
.
context
=
new
AnnotationConfigServletWebServerApplicationContext
();
this
.
context
.
register
(
ExampleServletWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
,
TestBean:
:
new
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigServletWebServerApplicationContextTests.TestBean"
))
.
isTrue
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
@Test
public
void
registerBeanWithSupplierAndLazy
()
{
this
.
context
=
new
AnnotationConfigServletWebServerApplicationContext
();
this
.
context
.
register
(
ExampleServletWebServerApplicationConfiguration
.
class
);
this
.
context
.
registerBean
(
TestBean
.
class
,
TestBean:
:
new
,
Lazy
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBeanFactory
().
containsSingleton
(
"annotationConfigServletWebServerApplicationContextTests.TestBean"
))
.
isFalse
();
assertThat
(
this
.
context
.
getBean
(
TestBean
.
class
)).
isNotNull
();
}
private
void
verifyContext
()
{
private
void
verifyContext
()
{
MockServletWebServerFactory
factory
=
this
.
context
MockServletWebServerFactory
factory
=
this
.
context
.
getBean
(
MockServletWebServerFactory
.
class
);
.
getBean
(
MockServletWebServerFactory
.
class
);
...
@@ -277,8 +228,4 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
...
@@ -277,8 +228,4 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
}
}
private
static
class
TestBean
{
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment