Skip to content

Commit 2e6eb61

Browse files
committed
Avoid scoped destruction callbacks in case of no post-processor actually applying
Issue: SPR-13744
1 parent fca5365 commit 2e6eb61

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
172172
@Override
173173
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
174174
}
175+
176+
@Override
177+
public boolean requiresDestruction(Object bean) {
178+
return true;
179+
}
175180
}
176181

177182

@@ -195,6 +200,11 @@ public void postProcessBeforeDestruction(Object bean, String beanName) throws Be
195200
((BeanNameAware) bean).setBeanName(null);
196201
}
197202
}
203+
204+
@Override
205+
public boolean requiresDestruction(Object bean) {
206+
return true;
207+
}
198208
}
199209

200210
}

spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/handler/SimplePortletPostProcessor.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,8 +36,9 @@
3636
import org.springframework.web.portlet.context.PortletContextAware;
3737

3838
/**
39-
* Bean post-processor that applies initialization and destruction callbacks
40-
* to beans that implement the Portlet interface.
39+
* {@link org.springframework.beans.factory.config.BeanPostProcessor}
40+
* that applies initialization and destruction callbacks to beans that
41+
* implement the {@link javax.portlet.Portlet} interface.
4142
*
4243
* <p>After initialization of the bean instance, the Portlet {@code init}
4344
* method will be called with a PortletConfig that contains the bean name
@@ -51,15 +52,16 @@
5152
* supposed to be configured like any other Spring bean, that is, through
5253
* constructor arguments or bean properties.
5354
*
54-
* <p>For reuse of a Portlet implementation in a plain Portlet container and as
55-
* a bean in a Spring context, consider deriving from Spring's GenericPortletBean
56-
* base class that applies Portlet initialization parameters as bean properties,
57-
* supporting both initialization styles.
55+
* <p>For reuse of a Portlet implementation in a plain Portlet container
56+
* and as a bean in a Spring context, consider deriving from Spring's
57+
* {@link org.springframework.web.portlet.GenericPortletBean} base class that
58+
* applies Portlet initialization parameters as bean properties, supporting
59+
* both the standard Portlet and the Spring bean initialization style.
5860
*
5961
* <p><b>Alternatively, consider wrapping a Portlet with Spring's
60-
* PortletWrappingController.</b> This is particularly appropriate for
61-
* existing Portlet classes, allowing to specify Portlet initialization
62-
* parameters etc.
62+
* {@link org.springframework.web.portlet.mvc.PortletWrappingController}.</b>
63+
* This is particularly appropriate for existing Portlet classes,
64+
* allowing to specify Portlet initialization parameters etc.
6365
*
6466
* @author Juergen Hoeller
6567
* @author John A. Lewis
@@ -132,6 +134,11 @@ public void postProcessBeforeDestruction(Object bean, String beanName) throws Be
132134
}
133135
}
134136

137+
@Override
138+
public boolean requiresDestruction(Object bean) {
139+
return (bean instanceof Portlet);
140+
}
141+
135142

136143
/**
137144
* Internal implementation of the PortletConfig interface, to be passed

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletPostProcessor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -126,6 +126,11 @@ public void postProcessBeforeDestruction(Object bean, String beanName) throws Be
126126
}
127127
}
128128

129+
@Override
130+
public boolean requiresDestruction(Object bean) {
131+
return (bean instanceof Servlet);
132+
}
133+
129134

130135
/**
131136
* Internal implementation of the {@link ServletConfig} interface,

0 commit comments

Comments
 (0)