Avoid scoped destruction callbacks in case of no post-processor actually applying

Issue: SPR-13744
master
Juergen Hoeller 9 years ago
parent fca5365cf1
commit 2e6eb614b5
  1. 10
      spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java
  2. 27
      spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/handler/SimplePortletPostProcessor.java
  3. 7
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletPostProcessor.java

@ -172,6 +172,11 @@ public class SessionScopeTests {
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
}
@Override
public boolean requiresDestruction(Object bean) {
return true;
}
}
@ -195,6 +200,11 @@ public class SessionScopeTests {
((BeanNameAware) bean).setBeanName(null);
}
}
@Override
public boolean requiresDestruction(Object bean) {
return true;
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@ -36,8 +36,9 @@ import org.springframework.web.portlet.context.PortletConfigAware;
import org.springframework.web.portlet.context.PortletContextAware;
/**
* Bean post-processor that applies initialization and destruction callbacks
* to beans that implement the Portlet interface.
* {@link org.springframework.beans.factory.config.BeanPostProcessor}
* that applies initialization and destruction callbacks to beans that
* implement the {@link javax.portlet.Portlet} interface.
*
* <p>After initialization of the bean instance, the Portlet {@code init}
* method will be called with a PortletConfig that contains the bean name
@ -51,15 +52,16 @@ import org.springframework.web.portlet.context.PortletContextAware;
* supposed to be configured like any other Spring bean, that is, through
* constructor arguments or bean properties.
*
* <p>For reuse of a Portlet implementation in a plain Portlet container and as
* a bean in a Spring context, consider deriving from Spring's GenericPortletBean
* base class that applies Portlet initialization parameters as bean properties,
* supporting both initialization styles.
* <p>For reuse of a Portlet implementation in a plain Portlet container
* and as a bean in a Spring context, consider deriving from Spring's
* {@link org.springframework.web.portlet.GenericPortletBean} base class that
* applies Portlet initialization parameters as bean properties, supporting
* both the standard Portlet and the Spring bean initialization style.
*
* <p><b>Alternatively, consider wrapping a Portlet with Spring's
* PortletWrappingController.</b> This is particularly appropriate for
* existing Portlet classes, allowing to specify Portlet initialization
* parameters etc.
* {@link org.springframework.web.portlet.mvc.PortletWrappingController}.</b>
* This is particularly appropriate for existing Portlet classes,
* allowing to specify Portlet initialization parameters etc.
*
* @author Juergen Hoeller
* @author John A. Lewis
@ -132,6 +134,11 @@ public class SimplePortletPostProcessor
}
}
@Override
public boolean requiresDestruction(Object bean) {
return (bean instanceof Portlet);
}
/**
* Internal implementation of the PortletConfig interface, to be passed

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@ -126,6 +126,11 @@ public class SimpleServletPostProcessor implements
}
}
@Override
public boolean requiresDestruction(Object bean) {
return (bean instanceof Servlet);
}
/**
* Internal implementation of the {@link ServletConfig} interface,

Loading…
Cancel
Save