On 7/25/12 4:58 PM, Shing Wai Chan wrote:
> On 7/25/12 3:41 PM, Shing Wai Chan wrote:
>> I am looking at issue http://java.net/jira/browse/SERVLET_SPEC-35 ,
>> "Clarification on section 4.4 Servlet Context Configuration Methods".
>>
>> Servlet 3.0:
>> ----------
>> In 4.4 (p.30), we have:
>> If the ServletContext passed to the ServletContextListener’s
>> contextInitialized method was neither declared in web.xml or web-
>> fragment.xml nor annotated with @WebListener then an
>> UnsupportedOperationException MUST be thrown for all the methods
>> defined for programmatic configuration of servlets, filters and
>> listeners.
>>
>> In javadoc of ServletContext of the following method
>> #getEffectiveMajorVersion
>> #getEffectiveMinorVersion
>> #setInitParameter
>> #addServlet(String, String), #addServlet(String, Servlet),
>> #addServlet(String, Class<? extends Servlet>)
>> #createServlet(Class<T>)
>> #getServletRegistration
>> #getServletRegistrations
>> #addFilter(String, String), #addFilter(String, Filter),
>> #addFilter(String, Class<? extends Filter>)
>> #createFilter(Class<T>)
>> #getFilterRegistration
>> #getFilterRegistrations
>> #getSessionCookieConfig
>> #setSessionTrackingModes
>> #getDefaultSessionTrackingModes
>> #getEffectiveSessionTrackingModes
>> #addListener(String), #addListener(T), #addListener(Class<? extends
>> EventListener>)
>> #createListener(Class<T>)
>> #getJspConfigDescriptor
>> #getClassLoader
>> #declareRoles
>> they have the following:
>> Throws:
>> UnsupportedOperationException - if this ServletContext was passed to
>> the ServletContextListener#contextInitialized method of a
>> ServletContextListener that was neither declared in web.xml or
>> web-fragment.xml, nor annotated with WebListener
>>
>> -----
>>
>> The above seems to be related to blocking ServletContextListeners
>> declared in TLD to access the 3.0 programmatic API as discussed in
>> jsr 315 expert group with emails title - "Special treatment of
>> ServletContextListeners declared in TLD resources of web fragments
>> excluded from absolute ordering".
>>
>> The 3.0 javadoc seems to be more general compared with those
>> mentioned in the email.
>> We should clarify this.
>>
>> Shing Wai Chan
>
> In p86 of Servlet 3.0 spec, we have the following:
> Any ServletContextListeners that were discovered in a TLD and
> registered programmatically are limited in the functionality they
> provide. Any attempt to call a ServletContext API method on them that
> was added in Servlet 3.0 will result in an UnsupportedOperationException.
>
> This seems to be align with the email threads in jsr 315.
The following is from p.67 of Servlet 3.0 spec:
"ServletContextListeners discovered in TLD files of excluded jars are
not able to configure filters and servlets using the programmatic APIs.
Any attempt to do so will result in an IllegalStateException."
In other words, there is an inconsistency here
(UnsupportedOperationException vs IllegalStateException).
Shing Wai Chan
>
> Shing Wai Chan
>