[jboss-cvs] JBossAS SVN: r73599 - projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 22 16:44:31 EDT 2008


Author: alesj
Date: 2008-05-22 16:44:31 -0400 (Thu, 22 May 2008)
New Revision: 73599

Modified:
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanScanningDeployer.java
Log:
Remove added bean components.
Perhaps a hack by keeping the set of names as attachment?

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanScanningDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanScanningDeployer.java	2008-05-22 20:35:17 UTC (rev 73598)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/BeanScanningDeployer.java	2008-05-22 20:44:31 UTC (rev 73599)
@@ -75,11 +75,13 @@
    public void deploy(DeploymentUnit unit, AnnotationEnvironment env) throws DeploymentException
    {
       Map<String, DeploymentUnit> components = null;
+      Set<String> beanNames = null;
 
       Set<Class<?>> beans = env.classIsAnnotatedWith(Bean.class);
       if (beans != null && beans.isEmpty() == false)
       {
          components = new HashMap<String, DeploymentUnit>();
+         beanNames = new HashSet<String>();
          mapComponents(unit, components);
 
          for (Class<?> beanClass : beans)
@@ -107,6 +109,7 @@
                       .setAutowireCandidate(bean.autowireCandidate());
 
                KernelDeploymentDeployer.addBeanComponent(unit, builder.getBeanMetaData());
+               beanNames.add(name);
             }
             else
             {
@@ -123,6 +126,7 @@
          {
             components = new HashMap<String, DeploymentUnit>();
             mapComponents(unit, components);
+            beanNames = new HashSet<String>();
          }
 
          for (Class<?> beanFactoryClass : beanFactories)
@@ -157,7 +161,10 @@
 
                List<BeanMetaData> bfBeans = gbfmd.getBeans();
                for (BeanMetaData bfb : bfBeans)
+               {
                   KernelDeploymentDeployer.addBeanComponent(unit, bfb);
+                  beanNames.add(name);
+               }
             }
             else
             {
@@ -165,10 +172,22 @@
                log.info("BeanMetaData with such name already exists: " + bmd + ", scanned: " + beanFactoryClass);
             }
          }
+
+         if (beanNames != null && beanNames.isEmpty() == false)
+            unit.addAttachment(getClass() + ".Beans", beanNames);
       }
    }
 
-   // TODO - undeploy!!
+   public void undeploy(DeploymentUnit unit, AnnotationEnvironment deployment)
+   {
+      @SuppressWarnings("unchecked")
+      Set<String> beanNames = unit.getAttachment(getClass() + ".Beans", Set.class);
+      if (beanNames != null)
+      {
+         for(String name : beanNames)
+            unit.removeComponent(name);
+      }
+   }
 
    /**
     * Map components.




More information about the jboss-cvs-commits mailing list