Author: remy.maucherat(a)jboss.com
Date: 2009-07-17 11:18:55 -0400 (Fri, 17 Jul 2009)
New Revision: 1137
Modified:
trunk/java/javax/servlet/ServletContext.java
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
trunk/webapps/docs/changelog.xml
Log:
- Today's spec update (sigh).
Modified: trunk/java/javax/servlet/ServletContext.java
===================================================================
--- trunk/java/javax/servlet/ServletContext.java 2009-07-16 17:05:56 UTC (rev 1136)
+++ trunk/java/javax/servlet/ServletContext.java 2009-07-17 15:18:55 UTC (rev 1137)
@@ -787,7 +787,7 @@
* is registered with this ServletContext via a call to
* {@link #addServlet(String,Servlet)}.
*
- * @param c the Servlet class to instantiate
+ * @param clazz the Servlet class to instantiate
*
* @return the new Servlet instance
*
@@ -802,10 +802,9 @@
*
* @since Servlet 3.0
*/
- public <T extends Servlet> T createServlet(Class<T> c)
+ public <T extends Servlet> T createServlet(Class<T> clazz)
throws ServletException;
-
/**
* Gets the ServletRegistration corresponding to the servlet with the
* given <tt>servletName</tt>.
@@ -947,7 +946,7 @@
* is registered with this ServletContext via a call to
* {@link #addFilter(String,Filter)}.
*
- * @param c the Filter class to instantiate
+ * @param clazz the Filter class to instantiate
*
* @return the new Filter instance
*
@@ -962,7 +961,7 @@
*
* @since Servlet 3.0
*/
- public <T extends Filter> T createFilter(Class<T> c)
+ public <T extends Filter> T createFilter(Class<T> clazz)
throws ServletException;
@@ -1245,7 +1244,55 @@
*/
public void addListener(Class <? extends EventListener> listenerClass);
+
/**
+ * Instantiates the given EventListener class and performs any
+ * required resource injection into the new EventListener instance
+ * before returning it.
+ *
+ * <p>The specified EventListener class must implement at least one of
+ * the <code>{@link ServletContextListener}</code>,
+ * <code>{@link ServletContextAttributeListener}</code>,
+ * <code>{@link ServletRequestListener}</code>,
+ * <code>{@link ServletRequestAttributeListener}</code>,
+ * <code>{@link javax.servlet.http.HttpSessionListener}</code>, or
+ * <code>{@link javax.servlet.http.HttpSessionAttributeListener}</code>
+ * interfaces.
+ *
+ * <p>The returned EventListener instance may be further customized
+ * before it is registered with this ServletContext via a call to
+ * {@link #addListener(EventListener)}.
+ *
+ * @param clazz the EventListener class to instantiate
+ *
+ * @return the new EventListener instance
+ *
+ * @throws ServletException if an error occurs during the instantiation
+ * of, or resource injection into the new EventListener
+ *
+ * @throws IllegalStateException if this ServletContext was passed to the
+ * {@link ServletContextListener#contextInitialized} method of a
+ * {@link ServletContextListener} that was not declared in
+ * <code>web.xml</code> or <code>web-fragment.xml</code>, or
annotated
+ * with {@link javax.servlet.annotation.WebListener}
+ *
+ * @throws IllegalArgumentException if the specified EventListener class
+ * does not implement any of the
+ * <code>{@link ServletContextListener}</code>,
+ * <code>{@link ServletContextAttributeListener}</code>,
+ * <code>{@link ServletRequestListener}</code>,
+ * <code>{@link ServletRequestAttributeListener}</code>,
+ * <code>{@link javax.servlet.http.HttpSessionListener}</code>, or
+ * <code>{@link javax.servlet.http.HttpSessionAttributeListener}</code>
+ * interfaces.
+ *
+ * @since Servlet 3.0
+ */
+ public <T extends EventListener> T createListener(Class<T> clazz)
+ throws ServletException;
+
+
+ /**
* Gets the <code><jsp-config></code> related
configuration
* that was aggregated from the <code>web.xml</code> and
* <code>web-fragment.xml</code> descriptor files of the web application
@@ -1263,6 +1310,17 @@
*/
public JspConfigDescriptor getJspConfigDescriptor();
+
+ /**
+ * Gets the classloader of the web application represented by this
+ * ServletContext.
+ *
+ * @return the classloader of the web application represented by this
+ * ServletContext
+ *
+ * @since Servlet 3.0
+ */
+ public ClassLoader getClassLoader();
}
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-07-16 17:05:56 UTC
(rev 1136)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-07-17 15:18:55 UTC
(rev 1137)
@@ -1082,7 +1082,9 @@
}
// FIXME: forbidden if the listener is from a TLD
try {
- context.addApplicationListenerInstance(listenerClass.newInstance());
+ EventListener listenerInstance =
+ (EventListener) context.getInstanceManager().newInstance(listenerClass);
+ context.addApplicationListenerInstance(listenerInstance);
} catch (Exception e) {
// FIXME: better error
throw new IllegalStateException(e);
@@ -1090,6 +1092,28 @@
}
+ public <T extends EventListener> T createListener(Class<T> clazz)
+ throws ServletException {
+ if (context.isInitialized()) {
+ throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
+ getContextPath()));
+ }
+ T listenerInstance = null;
+ try {
+ listenerInstance = (T) context.getInstanceManager().newInstance(clazz);
+ } catch (Exception e) {
+ // FIXME: better error
+ throw new ServletException(e);
+ }
+ return listenerInstance;
+ }
+
+
+ public ClassLoader getClassLoader() {
+ return context.getLoader().getClassLoader();
+ }
+
+
public JspConfigDescriptor getJspConfigDescriptor() {
ArrayList<TaglibDescriptor> taglibDescriptors = new
ArrayList<TaglibDescriptor>();
String[] taglibURIs = context.findTaglibs();
Modified: trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-07-16 17:05:56
UTC (rev 1136)
+++ trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-07-17 15:18:55
UTC (rev 1137)
@@ -607,6 +607,25 @@
}
+ public <T extends EventListener> T createListener(Class<T> clazz)
+ throws ServletException {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (T) doPrivileged("createListener", new Object[]{clazz});
+ } else {
+ return context.createListener(clazz);
+ }
+ }
+
+
+ public ClassLoader getClassLoader() {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (ClassLoader) doPrivileged("getClassLoader", null);
+ } else {
+ return context.getClassLoader();
+ }
+ }
+
+
public JspConfigDescriptor getJspConfigDescriptor() {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (JspConfigDescriptor) doPrivileged("getJspConfigDescriptor",
null);
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-07-16 17:05:56 UTC (rev 1136)
+++ trunk/webapps/docs/changelog.xml 2009-07-17 15:18:55 UTC (rev 1137)
@@ -20,7 +20,7 @@
<subsection name="General">
<changelog>
<update>
- Servlet 3.0 API. (markt, remm)
+ Servlet 3.0 API. (remm)
</update>
<update>
Commons Pool 1.5.2. (markt)
@@ -72,7 +72,7 @@
<bug>46562</bug>: In SSI, close the reader when done. (markt)
</fix>
<add>
- AsyncContext implementation. (remm)
+ AsyncContext implementation, internally built on top of the event API. (remm)
</add>
<add>
Multipart implementation. (remm)
@@ -120,6 +120,9 @@
<fix>
<bug>37984</bug>: Strip {MD5} as well as {SHA} from digested
passwords. (markt)
</fix>
+ <add>
+ All other Servlet 3.0 features. (remm)
+ </add>
</changelog>
</subsection>
<subsection name="Coyote">
@@ -128,7 +131,7 @@
Remove useless instanceof in the HTTP protocol. (markt)
</fix>
<update>
- Add support for non IO events in all connectors. (remm)
+ Add support for non IO based events in all AJP and HTTP connectors. (remm)
</update>
<fix>
Fix handling of timeout values <= 0 with the poller refactoring. (remm)