Package org.jboss.ejb3.pool

Examples of org.jboss.ejb3.pool.ThreadlocalPool


    * </p>
    *
    */
   protected void initMetaDataBasedAnnotationRepository()
   {
      this.metadataBasedAnnotationRepo = new AnnotationRepositoryToMetaData(this.beanClass, this.xml, name, this.classloader);
      List<MetaDataBridge<InterceptorMetaData>> interceptorBridges = new ArrayList<MetaDataBridge<InterceptorMetaData>>();
      interceptorBridges.add(new InterceptorMetaDataBridge());
      this.metadataBasedAnnotationRepo.addComponentMetaDataLoaderFactory(new InterceptorComponentMetaDataLoaderFactory(interceptorBridges));
      this.metadataBasedAnnotationRepo.addMetaDataBridge(new AdditiveBeanInterceptorMetaDataBridge(this.beanClass, this.classloader, this.xml));
     
View Full Code Here


         registeredPoolName = PoolDefaults.POOL_IMPLEMENTATION_THREADLOCAL;
      }
      int maxSize = poolAnnotation.maxSize();
      long timeout = poolAnnotation.timeout();
      PoolFactoryRegistry registry = deployment.getPoolFactoryRegistry();
      PoolFactory factory = registry.getPoolFactory(registeredPoolName);
      pool = factory.createPool();
      pool.initialize(this, maxSize, timeout);

      resolveInjectors();
      pool.setInjectors(injectors.toArray(new Injector[injectors.size()]));
   }
View Full Code Here

         // Default the Pool Implementation
         registeredPoolName = PoolDefaults.POOL_IMPLEMENTATION_THREADLOCAL;
      }
      int maxSize = poolAnnotation.maxSize();
      long timeout = poolAnnotation.timeout();
      PoolFactoryRegistry registry = deployment.getPoolFactoryRegistry();
      PoolFactory factory = registry.getPoolFactory(registeredPoolName);
      pool = factory.createPool();
      pool.initialize(this, maxSize, timeout);

      resolveInjectors();
      pool.setInjectors(injectors.toArray(new Injector[injectors.size()]));
View Full Code Here

      }
   }
  
   public void test1()
   {
      ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
      BeanContext ctx = pool.get();
      pool.release(ctx);
     
      ctx = null;
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(1, pool.getRemoveCount());
      assertEquals(1, MockBean.finalizers);
   }
View Full Code Here

      assertEquals(1, MockBean.finalizers);
   }

   public void testInUse1()
   {
      ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);

      assertEquals(0, pool.getAvailableCount());
     
      BeanContext ctx = pool.get();

      assertEquals(0, pool.getAvailableCount());

      pool.release(ctx);
      ctx = null;

      assertEquals(1, pool.getAvailableCount());

      pool.destroy();

      gc();
   }
View Full Code Here

      gc();
   }

   public void testWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            BeanContext ctx = pool.get();
            pool.release(ctx);
           
            ctx = null;
            used++;
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(20, pool.getRemoveCount());
      assertEquals(20, MockBean.finalizers);
     
      assertEquals(20, used);
   }
View Full Code Here

      assertEquals(20, used);
   }
  
   public void testMultipleWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            for(int i = 0; i < 10; i++)
            {
               BeanContext ctx = pool.get();
               pool.release(ctx);
              
               ctx = null;
               used++;
            }
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(20, pool.getRemoveCount());
      assertEquals(20, MockBean.finalizers);
     
      assertEquals(200, used);
   }
View Full Code Here

      assertEquals(200, used);
   }
  
   public void testMultipleRecursiveWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            for(int i = 0; i < 10; i++)
            {
               BeanContext ctx = pool.get();
               BeanContext ctx2 = pool.get();
              
               pool.release(ctx2);
               ctx2 = null;
               used ++;
              
               pool.release(ctx);
               ctx = null;
               used ++;
            }
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(200, pool.getRemoveCount());
      assertEquals(200, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(220, pool.getRemoveCount());
      assertEquals(220, MockBean.finalizers);
     
      assertEquals(400, used);
   }
View Full Code Here

      }
   }
  
   public void test1()
   {
      ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
      BeanContext ctx = pool.get();
      pool.release(ctx);
     
      ctx = null;
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(1, pool.getRemoveCount());
      assertEquals(1, MockBean.finalizers);
   }
View Full Code Here

      assertEquals(1, MockBean.finalizers);
   }
  
   public void testWithThreads() throws Exception
   {
      final ThreadlocalPool pool = new ThreadlocalPool();
      Container container = new MockContainer();
      int maxSize = -1;
      int timeout = -1;
      pool.initialize(container, maxSize, timeout);
     
      Runnable r = new Runnable()
      {
         public void run()
         {
            BeanContext ctx = pool.get();
            pool.release(ctx);
           
            ctx = null;
            used++;
         }
      };
     
      Thread threads[] = new Thread[20];
      for(int i = 0; i < threads.length; i++)
      {
         threads[i] = new Thread(r);
         threads[i].start();
      }
     
      for(Thread t : threads)
      {
         t.join(1000);
      }
     
      gc();
      assertEquals(0, pool.getRemoveCount());
      assertEquals(0, MockBean.finalizers);
     
      pool.destroy();
     
      gc();
      assertEquals(20, pool.getRemoveCount());
      assertEquals(20, MockBean.finalizers);
     
      assertEquals(20, used);
   }
View Full Code Here

TOP

Related Classes of org.jboss.ejb3.pool.ThreadlocalPool

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.