Пример #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;
 }