@Override
 public void setSessionTrackingModes(final Set<SessionTrackingMode> sessionTrackingModes) {
   ensureNotProgramaticListener();
   ensureNotInitialized();
   if (sessionTrackingModes.size() > 1 && sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
     throw UndertowServletMessages.MESSAGES.sslCannotBeCombinedWithAnyOtherMethod();
   }
   this.sessionTrackingModes = new HashSet<SessionTrackingMode>(sessionTrackingModes);
   // TODO: actually make this work
 }
 @Override
 public <T extends EventListener> void addListener(final T t) {
   ensureNotInitialized();
   ensureNotProgramaticListener();
   if (ApplicationListeners.listenerState() != NO_LISTENER
       && ServletContextListener.class.isAssignableFrom(t.getClass())) {
     throw UndertowServletMessages.MESSAGES.cannotAddServletContextListener();
   }
   ListenerInfo listener =
       new ListenerInfo(t.getClass(), new ImmediateInstanceFactory<EventListener>(t));
   deploymentInfo.addListener(listener);
   deployment.getApplicationListeners().addListener(new ManagedListener(listener, true));
 }
 @Override
 public FilterRegistration.Dynamic addFilter(
     final String filterName, final Class<? extends Filter> filterClass) {
   ensureNotProgramaticListener();
   ensureNotInitialized();
   if (deploymentInfo.getFilters().containsKey(filterName)) {
     return null;
   }
   FilterInfo filter = new FilterInfo(filterName, filterClass);
   deploymentInfo.addFilter(filter);
   deployment.getFilters().addFilter(filter);
   return new FilterRegistrationImpl(filter, deployment);
 }
 @Override
 public ServletRegistration.Dynamic addServlet(
     final String servletName, final Class<? extends Servlet> servletClass) {
   ensureNotProgramaticListener();
   ensureNotInitialized();
   if (deploymentInfo.getServlets().containsKey(servletName)) {
     return null;
   }
   ServletInfo servlet = new ServletInfo(servletName, servletClass);
   deploymentInfo.addServlet(servlet);
   deployment.getServlets().addServlet(servlet);
   return new ServletRegistrationImpl(servlet, deployment);
 }
  @Override
  public FilterRegistration.Dynamic addFilter(final String filterName, final Filter filter) {
    ensureNotProgramaticListener();
    ensureNotInitialized();

    if (deploymentInfo.getFilters().containsKey(filterName)) {
      return null;
    }
    FilterInfo f =
        new FilterInfo(filterName, filter.getClass(), new ImmediateInstanceFactory<Filter>(filter));
    deploymentInfo.addFilter(f);
    deployment.getFilters().addFilter(f);
    return new FilterRegistrationImpl(f, deployment);
  }
 @Override
 public ServletRegistration.Dynamic addServlet(final String servletName, final Servlet servlet) {
   ensureNotProgramaticListener();
   ensureNotInitialized();
   if (deploymentInfo.getServlets().containsKey(servletName)) {
     return null;
   }
   ServletInfo s =
       new ServletInfo(
           servletName, servlet.getClass(), new ImmediateInstanceFactory<Servlet>(servlet));
   deploymentInfo.addServlet(s);
   deployment.getServlets().addServlet(s);
   return new ServletRegistrationImpl(s, deployment);
 }
 @Override
 public void addListener(final Class<? extends EventListener> listenerClass) {
   ensureNotInitialized();
   ensureNotProgramaticListener();
   if (ApplicationListeners.listenerState() != NO_LISTENER
       && ServletContextListener.class.isAssignableFrom(listenerClass)) {
     throw UndertowServletMessages.MESSAGES.cannotAddServletContextListener();
   }
   InstanceFactory<? extends EventListener> factory = null;
   try {
     factory = deploymentInfo.getClassIntrospecter().createInstanceFactory(listenerClass);
   } catch (Exception e) {
     throw new IllegalArgumentException(e);
   }
   final ListenerInfo listener = new ListenerInfo(listenerClass, factory);
   deploymentInfo.addListener(listener);
   deployment.getApplicationListeners().addListener(new ManagedListener(listener, true));
 }
 @Override
 public FilterRegistration.Dynamic addFilter(final String filterName, final String className) {
   ensureNotProgramaticListener();
   ensureNotInitialized();
   if (deploymentInfo.getFilters().containsKey(filterName)) {
     return null;
   }
   try {
     FilterInfo filter =
         new FilterInfo(
             filterName,
             (Class<? extends Filter>) deploymentInfo.getClassLoader().loadClass(className));
     deploymentInfo.addFilter(filter);
     deployment.getFilters().addFilter(filter);
     return new FilterRegistrationImpl(filter, deployment);
   } catch (ClassNotFoundException e) {
     throw UndertowServletMessages.MESSAGES.cannotLoadClass(className, e);
   }
 }
 @Override
 public ServletRegistration.Dynamic addServlet(final String servletName, final String className) {
   ensureNotProgramaticListener();
   ensureNotInitialized();
   try {
     if (deploymentInfo.getServlets().containsKey(servletName)) {
       return null;
     }
     ServletInfo servlet =
         new ServletInfo(
             servletName,
             (Class<? extends Servlet>) deploymentInfo.getClassLoader().loadClass(className));
     deploymentInfo.addServlet(servlet);
     deployment.getServlets().addServlet(servlet);
     return new ServletRegistrationImpl(servlet, deployment);
   } catch (ClassNotFoundException e) {
     throw UndertowServletMessages.MESSAGES.cannotLoadClass(className, e);
   }
 }