package org.jboss.webbeans.contexts;

import java.util.concurrent.atomic.AtomicBoolean;

import javax.webbeans.ContextNotActiveException;
import javax.webbeans.Dependent;
import javax.webbeans.manager.Bean;

public class DependentContext extends AbstractContext
{
   private BeanMap beans;
   private AtomicBoolean active;
   
   public DependentContext()
   {
      super(Dependent.class);
      beans = new BeanMap();
      active = new AtomicBoolean(false);
   }

   @Override
   public <T> T get(Bean<T> bean, boolean create)
   {
      if (!isActive())
      {
         throw new ContextNotActiveException();
      }

      return create == false ? null : bean.create();
   }   

   @Override
   protected AtomicBoolean getActive()
   {
      return active;
   }

   @Override
   protected BeanMap getBeanMap()
   {
      return beans;
   }
   
   @Override
   public String toString()
   {
      return "Dependent context";
   }   
}

@@ -37,61 +37,8 @@
 %0D%0A%0D%0A
-import java.util.concurrent.atomic.AtomicBoolean;%0D%0A%0D%0A
 impo
@@ -198,16 +198,15 @@
 nds 
-Abstract
+Private
 Cont
@@ -217,72 +217,8 @@
 %0A%7B%0D%0A
-   private BeanMap beans;%0D%0A   private AtomicBoolean active;%0D%0A   
 %0D%0A  
@@ -292,64 +292,17 @@
     
-beans = new BeanMap();%0D%0A      active = new AtomicBoolean
+setActive
 (fal
@@ -545,182 +545,8 @@
    %0D
-%0A%0D%0A   @Override%0D%0A   protected AtomicBoolean getActive()%0D%0A   %7B%0D%0A      return active;%0D%0A   %7D%0D%0A%0D%0A   @Override%0D%0A   protected BeanMap getBeanMap()%0D%0A   %7B%0D%0A      return beans;%0D%0A   %7D%0D
 %0A   

oops, forgot to fix the dependent context