示例#1
0
 @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
 }
示例#2
0
 @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));
 }
示例#3
0
 @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);
 }
示例#4
0
 @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);
 }
示例#5
0
  @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);
  }
示例#6
0
 @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);
 }
示例#7
0
 @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));
 }
示例#8
0
 @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);
   }
 }
示例#9
0
 @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);
   }
 }