Author: kkolinko
Date: Thu Jun 5 12:42:13 2014
New Revision: 1600638
URL: http://svn.apache.org/r1600638
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56588
Update according to the changes in Tomcat 8:
Un-deprecate Context.addApplicationListener(String)
Deprecate Context.addApplicationListener(ApplicationListener)
Replace calls to addApplicationListener(new ApplicationListener(x, false)) with
addApplicationListener(x).
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/Context.java
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELInterpreterFactory.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/Context.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/Context.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/Context.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/Context.java Thu Jun 5
12:42:13 2014
@@ -780,11 +780,29 @@ public interface Context extends Contain
// --------------------------------------------------------- Public Methods
/**
- * Add a new Listener class name to the set of Listeners
- * configured for this application.
+ * Add a new Listener class name to the set of Listeners configured for
this
+ * application.
*
- * @param listener Java class name of a listener class
+ * <p>
+ * The {@link ApplicationListener} class is used to pass an additional
+ * parameter that allows to differentiate listeners to Web Application
added
+ * via configuration (web.xml or annotations) vs. ones added by frameworks,
+ * such as listeners declared in JSP tag libraries (TLD files) that are
+ * added by Jasper JSP Engine.
+ *
+ * <p>
+ * The recommended method to call for the first use case is
+ * {@link #addApplicationListener(String)}. The recommended replacement for
+ * the second use case is to use {@code addListener(...)} methods in
+ * {@link javax.servlet.ServletContext}.
+ *
+ * @param listener
+ * Definition of a listener, including its java class name.
+ * @deprecated This method is removed from Tomcat 8.0.9 onwards. Use
+ * {@link #addApplicationListener(String)} or
+ * {@link javax.servlet.ServletContext#addListener(String)}.
*/
+ @Deprecated
public void addApplicationListener(ApplicationListener listener);
@@ -793,10 +811,7 @@ public interface Context extends Contain
* configured for this application.
*
* @param listener Java class name of a listener class
- *
- * @deprecated Use {@link #addApplicationListener(ApplicationListener)}
*/
- @Deprecated
public void addApplicationListener(String listener);
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Thu
Jun 5 12:42:13 2014
@@ -2849,14 +2849,7 @@ public class StandardContext extends Con
public void addApplicationListener(String listener) {
addApplicationListener(new ApplicationListener(listener, false));
}
-
-
- /**
- * Add a new Listener class name to the set of Listeners
- * configured for this application.
- *
- * @param listener Java class name of a listener class
- */
+
@Override
public void addApplicationListener(ApplicationListener listener) {
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/WebXml.java Thu Jun 5
12:42:13 2014
@@ -1340,8 +1340,7 @@ public class WebXml {
descriptor);
}
for (String listener : listeners) {
- context.addApplicationListener(
- new ApplicationListener(listener, false));
+ context.addApplicationListener(listener);
}
for (Entry<String, String> entry : localeEncodingMappings.entrySet()) {
context.addLocaleEncodingMappingParameter(entry.getKey(),
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java Thu
Jun 5 12:42:13 2014
@@ -244,6 +244,7 @@ public final class TldConfig implements
* the <tt>noTldJars</tt> class variable, which contains the names of JARs
* that are known not to contain any TLDs.
*/
+ @SuppressWarnings("deprecation") //
Context.addApplicationListener(ApplicationListener) is deprecated.
public void execute() {
long t1=System.currentTimeMillis();
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java
Thu Jun 5 12:42:13 2014
@@ -52,7 +52,6 @@ import org.junit.Test;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
-import org.apache.catalina.deploy.ApplicationListener;
import org.apache.catalina.deploy.ErrorPage;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
@@ -493,8 +492,7 @@ public class TestAsyncContextImpl extend
}
}
- ctx.addApplicationListener(new ApplicationListener(
- TrackingRequestListener.class.getName(), false));
+ ctx.addApplicationListener(TrackingRequestListener.class.getName());
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
@@ -641,8 +639,7 @@ public class TestAsyncContextImpl extend
wrapper2.setAsyncSupported(true);
ctx.addServletMapping("/stage2", "nonasync");
- ctx.addApplicationListener(new ApplicationListener(
- TrackingRequestListener.class.getName(), false));
+ ctx.addApplicationListener(TrackingRequestListener.class.getName());
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
@@ -972,8 +969,7 @@ public class TestAsyncContextImpl extend
Tomcat.addServlet(ctx, "error", error);
ctx.addServletMapping("/stage2", "error");
- ctx.addApplicationListener(new ApplicationListener(
- TrackingRequestListener.class.getName(), false));
+ ctx.addApplicationListener(TrackingRequestListener.class.getName());
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
@@ -1599,8 +1595,7 @@ public class TestAsyncContextImpl extend
ctx.addErrorPage(ep);
}
- ctx.addApplicationListener(new ApplicationListener(
- TrackingRequestListener.class.getName(), false));
+ ctx.addApplicationListener(TrackingRequestListener.class.getName());
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestNamingContextListener.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
Thu Jun 5 12:42:13 2014
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertEqu
import org.junit.Test;
import org.apache.catalina.LifecycleState;
-import org.apache.catalina.deploy.ApplicationListener;
import org.apache.catalina.deploy.ContextEnvironment;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
@@ -62,8 +61,7 @@ public class TestNamingContextListener e
environment.setValue(BUG49132_VALUE);
ctx.getNamingResources().addEnvironment(environment);
- ctx.addApplicationListener(new ApplicationListener(
- Bug49132Listener.class.getName(), false));
+ ctx.addApplicationListener(Bug49132Listener.class.getName());
tomcat.start();
@@ -117,8 +115,7 @@ public class TestNamingContextListener e
environmentB.setValue(BUG54096_ValueB);
ctx.getNamingResources().addEnvironment(environmentB);
- ctx.addApplicationListener(new ApplicationListener(
- Bug54096Listener.class.getName(), false));
+ ctx.addApplicationListener(Bug54096Listener.class.getName());
tomcat.start();
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java Thu
Jun 5 12:42:13 2014
@@ -30,7 +30,6 @@ import static org.junit.Assert.assertTru
import org.junit.Test;
import org.apache.catalina.Context;
-import org.apache.catalina.deploy.ApplicationListener;
public class TestListener extends TomcatBaseTest {
@@ -65,8 +64,7 @@ public class TestListener extends Tomcat
// SCL2 pretends to be in web.xml, and tries to install a
// ServletContainerInitializer.
- context.addApplicationListener(new ApplicationListener(
- SCL2.class.getName(), false));
+ context.addApplicationListener(SCL2.class.getName());
tomcat.start();
//check that the ServletContainerInitializer wasn't initialized.
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELInterpreterFactory.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELInterpreterFactory.java?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELInterpreterFactory.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELInterpreterFactory.java
Thu Jun 5 12:42:13 2014
@@ -26,7 +26,6 @@ import org.junit.Assert;
import org.junit.Test;
import org.apache.catalina.Context;
-import org.apache.catalina.deploy.ApplicationListener;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
import org.apache.jasper.JspCompilationContext;
@@ -79,8 +78,7 @@ public class TestELInterpreterFactory ex
context.removeAttribute(ELInterpreter.class.getName());
ctx.stop();
- ctx.addApplicationListener((new ApplicationListener(
- Bug54239Listener.class.getName(), false)));
+ ctx.addApplicationListener(Bug54239Listener.class.getName());
ctx.start();
interpreter =
ELInterpreterFactory.getELInterpreter(ctx.getServletContext());
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1600638&r1=1600637&r2=1600638&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Jun 5 12:42:13 2014
@@ -77,6 +77,10 @@
may otherwise be triggered by a web application which in turn would
trigger an exception when running under a security manager. (kkolinko)
</fix>
+ <scode>
+ <bug>56588</bug>: Update deprecation of
Context.addApplicationListener()
+ methods according to changes in Tomcat 8. (kkolinko)
+ </scode>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]