Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * JBoss, Home of Professional Open Source
  * Copyright 2008, Red Hat Middleware LLC, and individual contributors
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.jboss.weld.environment.servlet;
import  javax.servlet.ServletContext;
import  javax.servlet.ServletContextEvent;
This is the original listener which had to be defined in web.xml. It's not necessary to register this listener in Servlet 3.0 compliant containers unless there are listener ordering conflicts. E.g. if a user provides a custom listener the request context will not be active during its notifications. In this case place this listener before any other listener definitions in web.xml. ServletContext notifications are no-op in case of the EnhancedListener is registered as well.

Pete Muir
Ales Justin
See also:
public class Listener extends ForwardingServletListener {
    public static final String LISTENER_USED_ATTRIBUTE_NAME = EnhancedListener.class.getPackage().getName() + ".listenerUsed";
    private boolean isEnhancedListenerUsed;
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext context = sce.getServletContext();
        if( != null) {
             = true;
        if () {
         = new WeldServletLifecycle();
    public void contextDestroyed(ServletContextEvent sce) {
        if ( ||  == null) {
    protected ServletListener delegate() {
        return .getWeldListener();
New to GrepCode? Check out our FAQ X