Package org.gatein.wci

Examples of org.gatein.wci.ServletContainer


         startConsumers();

         // listen for web app events so that we can inject services into WSRP admin UI "cleanly"
         // todo: this service injection should really be done using CDI... :/
         ServletContainerFactory factory = DefaultServletContainerFactory.getInstance();
         ServletContainer servletContainer = factory.getServletContainer();
         servletContainer.addWebAppListener(this);

         log.info("WSRP Service version '" + WSRPConstants.WSRP_SERVICE_VERSION + "' started");
      }
   }
View Full Code Here


   {
      if (!bypass)
      {
         // stop listening to web app events
         ServletContainerFactory factory = DefaultServletContainerFactory.getInstance();
         ServletContainer servletContainer = factory.getServletContainer();
         servletContainer.removeWebAppListener(this);

         stopProducer();
         stopConsumers();
      }
   }
View Full Code Here

    }

    @Override
    public void dispatch(ServletContext target, HttpServletRequest request, HttpServletResponse response,
            final Callable callable) throws Exception {
        ServletContainer container = ServletContainerFactory.getServletContainer();
        container.include(target, request, response, new RequestDispatchCallback() {
            @Override
            public Object doCallback(ServletContext dispatchedServletContext, HttpServletRequest dispatchedRequest,
                    HttpServletResponse dispatchedResponse, Object handback) throws ServletException, IOException {
                callable.call(dispatchedServletContext, dispatchedRequest, dispatchedResponse);
View Full Code Here

      ServletContext target,
      HttpServletRequest request,
      HttpServletResponse response,
      final Callable callable) throws Exception
   {
      ServletContainer container = ServletContainerFactory.getServletContainer();
      container.include(target, request, response, new RequestDispatchCallback()
      {
         @Override
         public Object doCallback(
            ServletContext dispatchedServletContext,
            HttpServletRequest dispatchedRequest,
View Full Code Here

{

   @Test
   public void testContextRegistrationLifeCycle()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();

      //
      container.register(scc);

      // Assert we got registration
      assertNotNull(scc.registration);

      // Keep a ref on registration
View Full Code Here

   }

   @Test
   public void testConcurrentContextRegistrations()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc1 = new ServletContainerContextImpl();
      ServletContainerContextImpl scc2 = new ServletContainerContextImpl();

      // We register
      container.register(scc1);

      // Registration was done
      assertNotNull(scc1.registration);

      // Try register
      container.register(scc2);

      // Registration failed
      assertNull(scc2.registration);

      // Cancel
      scc1.registration.cancel();

      // Try register again
      container.register(scc2);

      // Registration should have worked now
      assertNotNull(scc2.registration);
   }
View Full Code Here

   }

   @Test
   public void testContextRegistrationCancellationUnregistersWebApps()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();
      WebAppRegistry registry = new WebAppRegistry();

      //
      container.register(scc);

      //
      container.addWebAppListener(registry);

      //
      scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
      scc.registration.registerWebApp(new WebAppContextImpl("/bar"));
      assertEquals(Tools.toSet("/foo", "/bar"), registry.getKeys());
View Full Code Here

   }

   @Test
   public void testListenerDoubleRegistration()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();
      WebAppRegistry registry = new WebAppRegistry();

      //
      container.addWebAppListener(registry);
      container.addWebAppListener(registry);

      //
      container.register(scc);
      scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
      assertEquals(Tools.toSet("/foo"), registry.getKeys());

      //
      container.addWebAppListener(registry);
      assertEquals(Tools.toSet("/foo"), registry.getKeys());

      //
      container.removeWebAppListener(registry);
      assertEquals(Tools.toSet(), registry.getKeys());

      //
      container.removeWebAppListener(registry);
      assertEquals(Tools.toSet(), registry.getKeys());
   }
View Full Code Here

   }

   @Test
   public void testListenerIsNotified()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();
      WebAppRegistry registry = new WebAppRegistry();

      //
      container.register(scc);

      // Add 2 web apps
      scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
      scc.registration.registerWebApp(new WebAppContextImpl("/bar"));

      // Add listener
      container.addWebAppListener(registry);

      // Assert we received events during the registration
      assertEquals(Tools.toSet("/foo", "/bar"), registry.getKeys());

      // Add a new web app
      scc.registration.registerWebApp(new WebAppContextImpl("/juu"));

      // Assert we now have 3 web apps
      assertEquals(Tools.toSet("/foo", "/bar", "/juu"), registry.getKeys());

      // Remove one web app
      scc.registration.unregisterWebApp("/foo");

      // Assert we have 2 web apps
      assertEquals(Tools.toSet("/bar", "/juu"), registry.getKeys());

      // Remove registration
      container.removeWebAppListener(registry);

      // Assert we receveived events during removal
      assertEquals(Tools.toSet(), registry.getKeys());

      // W Add a new web app
View Full Code Here

   }

   @Test
   public void testServletContainerThrowsIAE()
   {
      ServletContainer container = new DefaultServletContainer();
      try
      {
         container.register(null);
         fail("Was expecting an IAE");
      }
      catch (IllegalArgumentException ignore)
      {
      }
      try
      {
         container.addWebAppListener(null);
         fail("Was expecting an IAE");
      }
      catch (IllegalArgumentException ignore)
      {
      }
      try
      {
         container.removeWebAppListener(null);
         fail("Was expecting an IAE");
      }
      catch (IllegalArgumentException ignore)
      {
      }
View Full Code Here

TOP

Related Classes of org.gatein.wci.ServletContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.