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
cccf5e6d
Commit
cccf5e6d
authored
Nov 15, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
d84421b7
3baf7828
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
12 deletions
+60
-12
AnnotationsPropertySource.java
...t/autoconfigure/properties/AnnotationsPropertySource.java
+5
-2
custom-layout.apt
...boot-maven-plugin/src/site/apt/examples/custom-layout.apt
+1
-1
ServletWebServerApplicationContext.java
...b/servlet/context/ServletWebServerApplicationContext.java
+12
-8
ServletWebServerApplicationContextTests.java
...vlet/context/ServletWebServerApplicationContextTests.java
+42
-1
No files found.
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java
View file @
cccf5e6d
...
@@ -90,8 +90,11 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
...
@@ -90,8 +90,11 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
if
(
annotations
!=
null
)
{
if
(
annotations
!=
null
)
{
for
(
Annotation
annotation
:
annotations
)
{
for
(
Annotation
annotation
:
annotations
)
{
if
(!
AnnotationUtils
.
isInJavaLangAnnotationPackage
(
annotation
))
{
if
(!
AnnotationUtils
.
isInJavaLangAnnotationPackage
(
annotation
))
{
mergedAnnotations
Annotation
mergedAnnotation
=
findMergedAnnotation
(
root
,
.
add
(
findMergedAnnotation
(
root
,
annotation
.
annotationType
()));
annotation
.
annotationType
());
if
(
mergedAnnotation
!=
null
)
{
mergedAnnotations
.
add
(
mergedAnnotation
);
}
}
}
}
}
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/custom-layout.apt
View file @
cccf5e6d
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
</executions>
</executions>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>com.example</group
i
d>
<groupId>com.example</group
I
d>
<artifactId>custom-layout</artifactId>
<artifactId>custom-layout</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
<version>0.0.1.BUILD-SNAPSHOT</version>
</dependency>
</dependency>
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java
View file @
cccf5e6d
...
@@ -132,6 +132,7 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon
...
@@ -132,6 +132,7 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon
beanFactory
.
addBeanPostProcessor
(
beanFactory
.
addBeanPostProcessor
(
new
WebApplicationContextServletContextAwareProcessor
(
this
));
new
WebApplicationContextServletContextAwareProcessor
(
this
));
beanFactory
.
ignoreDependencyInterface
(
ServletContextAware
.
class
);
beanFactory
.
ignoreDependencyInterface
(
ServletContextAware
.
class
);
registerWebApplicationScopes
(
null
);
}
}
@Override
@Override
...
@@ -226,19 +227,22 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon
...
@@ -226,19 +227,22 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon
private
void
selfInitialize
(
ServletContext
servletContext
)
throws
ServletException
{
private
void
selfInitialize
(
ServletContext
servletContext
)
throws
ServletException
{
prepareWebApplicationContext
(
servletContext
);
prepareWebApplicationContext
(
servletContext
);
ConfigurableListableBeanFactory
beanFactory
=
getBeanFactory
();
registerWebApplicationScopes
(
servletContext
);
ExistingWebApplicationScopes
existingScopes
=
new
ExistingWebApplicationScopes
(
WebApplicationContextUtils
.
registerEnvironmentBeans
(
getBeanFactory
(),
beanFactory
);
servletContext
);
WebApplicationContextUtils
.
registerWebApplicationScopes
(
beanFactory
,
getServletContext
());
existingScopes
.
restore
();
WebApplicationContextUtils
.
registerEnvironmentBeans
(
beanFactory
,
getServletContext
());
for
(
ServletContextInitializer
beans
:
getServletContextInitializerBeans
())
{
for
(
ServletContextInitializer
beans
:
getServletContextInitializerBeans
())
{
beans
.
onStartup
(
servletContext
);
beans
.
onStartup
(
servletContext
);
}
}
}
}
private
void
registerWebApplicationScopes
(
ServletContext
servletContext
)
{
ExistingWebApplicationScopes
existingScopes
=
new
ExistingWebApplicationScopes
(
getBeanFactory
());
WebApplicationContextUtils
.
registerWebApplicationScopes
(
getBeanFactory
(),
servletContext
);
existingScopes
.
restore
();
}
/**
/**
* Returns {@link ServletContextInitializer}s that should be used with the embedded
* Returns {@link ServletContextInitializer}s that should be used with the embedded
* web server. By default this method will first attempt to find
* web server. By default this method will first attempt to find
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java
View file @
cccf5e6d
...
@@ -37,12 +37,15 @@ import org.mockito.Captor;
...
@@ -37,12 +37,15 @@ import org.mockito.Captor;
import
org.mockito.InOrder
;
import
org.mockito.InOrder
;
import
org.mockito.MockitoAnnotations
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.MutablePropertyValues
;
import
org.springframework.beans.MutablePropertyValues
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.BeanFactoryPostProcessor
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.ConstructorArgumentValues
;
import
org.springframework.beans.factory.config.ConstructorArgumentValues
;
import
org.springframework.beans.factory.config.Scope
;
import
org.springframework.beans.factory.config.Scope
;
import
org.springframework.beans.factory.support.AbstractBeanDefinition
;
import
org.springframework.beans.factory.support.RootBeanDefinition
;
import
org.springframework.beans.factory.support.RootBeanDefinition
;
import
org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer
;
import
org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer
;
import
org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean
;
import
org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean
;
...
@@ -443,7 +446,8 @@ public class ServletWebServerApplicationContextTests {
...
@@ -443,7 +446,8 @@ public class ServletWebServerApplicationContextTests {
}
}
@Test
@Test
public
void
doesNotReplaceExistingScopes
()
{
// gh-2082
public
void
doesNotReplaceExistingScopes
()
{
// gh-2082
Scope
scope
=
mock
(
Scope
.
class
);
Scope
scope
=
mock
(
Scope
.
class
);
ConfigurableListableBeanFactory
factory
=
this
.
context
.
getBeanFactory
();
ConfigurableListableBeanFactory
factory
=
this
.
context
.
getBeanFactory
();
factory
.
registerScope
(
WebApplicationContext
.
SCOPE_REQUEST
,
scope
);
factory
.
registerScope
(
WebApplicationContext
.
SCOPE_REQUEST
,
scope
);
...
@@ -456,6 +460,29 @@ public class ServletWebServerApplicationContextTests {
...
@@ -456,6 +460,29 @@ public class ServletWebServerApplicationContextTests {
.
isSameAs
(
scope
);
.
isSameAs
(
scope
);
}
}
@Test
public
void
servletRequestCanBeInjectedEarly
()
throws
Exception
{
// gh-14990
addWebServerFactoryBean
();
RootBeanDefinition
beanDefinition
=
new
RootBeanDefinition
(
WithAutowiredServletRequest
.
class
);
beanDefinition
.
setAutowireMode
(
AbstractBeanDefinition
.
AUTOWIRE_CONSTRUCTOR
);
this
.
context
.
registerBeanDefinition
(
"withAutowiredServletRequest"
,
beanDefinition
);
this
.
context
.
addBeanFactoryPostProcessor
(
new
BeanFactoryPostProcessor
()
{
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
throws
BeansException
{
WithAutowiredServletRequest
bean
=
beanFactory
.
getBean
(
WithAutowiredServletRequest
.
class
);
assertThat
(
bean
.
getRequest
()).
isNotNull
();
}
});
this
.
context
.
refresh
();
}
private
void
addWebServerFactoryBean
()
{
private
void
addWebServerFactoryBean
()
{
this
.
context
.
registerBeanDefinition
(
"webServerFactory"
,
this
.
context
.
registerBeanDefinition
(
"webServerFactory"
,
new
RootBeanDefinition
(
MockServletWebServerFactory
.
class
));
new
RootBeanDefinition
(
MockServletWebServerFactory
.
class
));
...
@@ -508,4 +535,18 @@ public class ServletWebServerApplicationContextTests {
...
@@ -508,4 +535,18 @@ public class ServletWebServerApplicationContextTests {
}
}
protected
static
class
WithAutowiredServletRequest
{
private
final
ServletRequest
request
;
public
WithAutowiredServletRequest
(
ServletRequest
request
)
{
this
.
request
=
request
;
}
public
ServletRequest
getRequest
()
{
return
this
.
request
;
}
}
}
}
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