示例#1
0
 @Override
 public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
   ensureNotProgramaticListener();
   final Map<String, FilterRegistration> ret = new HashMap<String, FilterRegistration>();
   for (Map.Entry<String, FilterInfo> entry : deploymentInfo.getFilters().entrySet()) {
     ret.put(entry.getKey(), new FilterRegistrationImpl(entry.getValue(), deployment));
   }
   return ret;
 }
示例#2
0
 @Override
 public ServletRegistration getServletRegistration(final String servletName) {
   ensureNotProgramaticListener();
   final ServletInfo servlet = deploymentInfo.getServlets().get(servletName);
   if (servlet == null) {
     return null;
   }
   return new ServletRegistrationImpl(servlet, deployment);
 }
示例#3
0
 @Override
 public FilterRegistration getFilterRegistration(final String filterName) {
   ensureNotProgramaticListener();
   final FilterInfo filterInfo = deploymentInfo.getFilters().get(filterName);
   if (filterInfo == null) {
     return null;
   }
   return new FilterRegistrationImpl(filterInfo, deployment);
 }
示例#4
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
 }
示例#5
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));
 }
示例#6
0
 @Override
 public <T extends Filter> T createFilter(final Class<T> clazz) throws ServletException {
   ensureNotProgramaticListener();
   try {
     return deploymentInfo
         .getClassIntrospecter()
         .createInstanceFactory(clazz)
         .createInstance()
         .getInstance();
   } catch (Exception e) {
     throw UndertowServletMessages.MESSAGES.couldNotInstantiateComponent(clazz.getName(), e);
   }
 }
示例#7
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);
 }
示例#8
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);
 }
示例#9
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);
  }
示例#10
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);
 }
示例#11
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));
 }
示例#12
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);
   }
 }
示例#13
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);
   }
 }
示例#14
0
 @Override
 public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
   ensureNotProgramaticListener();
   return Collections.unmodifiableSet(sessionTrackingModes);
 }
示例#15
0
 @Override
 public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
   ensureNotProgramaticListener();
   return defaultSessionTrackingModes;
 }
示例#16
0
 @Override
 public SessionCookieConfigImpl getSessionCookieConfig() {
   ensureNotProgramaticListener();
   return sessionCookieConfig;
 }