[jboss-cvs] JBossAS SVN: r64337 - in projects/microcontainer/trunk: deployers-core/src/tests/org/jboss/test/deployers/structure/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jul 28 17:18:17 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-07-28 17:18:17 -0400 (Sat, 28 Jul 2007)
New Revision: 64337

Modified:
   projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java
   projects/microcontainer/trunk/deployers-core/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java
   projects/microcontainer/trunk/deployers-core/src/tests/org/jboss/test/deployers/structure/test/ContextInfoImplUnitTestCase.java
   projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java
Log:
JBMICROCONT-199, add support for TransientManagedObjects to the structure deployers ContextInfo that can be propagated to the DeploymentContexts

Modified: projects/microcontainer/trunk/deployers-core/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-core/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java	2007-07-27 22:14:13 UTC (rev 64336)
+++ projects/microcontainer/trunk/deployers-core/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java	2007-07-28 21:18:17 UTC (rev 64337)
@@ -28,7 +28,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jboss.deployers.spi.attachments.helpers.PredeterminedManagedObjectAttachmentsImpl;
+import org.jboss.deployers.spi.attachments.helpers.ManagedObjectAttachmentsImpl;
 import org.jboss.deployers.spi.structure.ClassPathEntry;
 import org.jboss.deployers.spi.structure.ContextInfo;
 
@@ -36,12 +36,14 @@
  * ContextInfoImpl.
  * 
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
-public class ContextInfoImpl extends PredeterminedManagedObjectAttachmentsImpl implements ContextInfo, Externalizable
+public class ContextInfoImpl extends ManagedObjectAttachmentsImpl
+   implements ContextInfo, Externalizable
 {
    /** The serialVersionUID */
-   private static final long serialVersionUID = -4384869824260284607L;
+   private static final long serialVersionUID = 2;
 
    /** The logical path */
    private String path;

Modified: projects/microcontainer/trunk/deployers-core/src/tests/org/jboss/test/deployers/structure/test/ContextInfoImplUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-core/src/tests/org/jboss/test/deployers/structure/test/ContextInfoImplUnitTestCase.java	2007-07-27 22:14:13 UTC (rev 64336)
+++ projects/microcontainer/trunk/deployers-core/src/tests/org/jboss/test/deployers/structure/test/ContextInfoImplUnitTestCase.java	2007-07-28 21:18:17 UTC (rev 64337)
@@ -26,8 +26,10 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.jboss.deployers.plugins.attachments.AttachmentsImpl;
 import org.jboss.deployers.plugins.structure.ClassPathEntryImpl;
 import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
 import org.jboss.deployers.spi.structure.ClassPathEntry;
 import org.jboss.deployers.spi.structure.ContextInfo;
 import org.jboss.test.deployers.structure.AbstractContextInfoTest;
@@ -168,4 +170,25 @@
       assertDefaultMetaDataPath(context);
       assertEquals(classPath, context.getClassPath());
    }
+
+   public void testPredeterminedManagedObjectAttachments()
+   {
+      ContextInfoImpl context = createDefault();
+      assertEquals("", context.getPath());
+      AttachmentsImpl ai = new AttachmentsImpl();
+      ai.addAttachment("key1", "testPredeterminedManagedObjectAttachments");
+      context.setPredeterminedManagedObjects(ai);
+      String a1 = context.getPredeterminedManagedObjects().getAttachment("key1", String.class);
+      assertEquals("key1 attachment", "testPredeterminedManagedObjectAttachments", a1);
+   }
+
+   public void testTransientManagedObjects()
+   {
+      ContextInfoImpl context = createDefault();
+      assertEquals("", context.getPath());
+      MutableAttachments ma = context.getTransientManagedObjects();
+      ma.addAttachment("key1", "testTransientManagedObjects", String.class);
+      String a1 = context.getTransientManagedObjects().getAttachment("key1", String.class);
+      assertEquals("key1 attachment", "testTransientManagedObjects", a1);
+   }
 }

Modified: projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java
===================================================================
--- projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java	2007-07-27 22:14:13 UTC (rev 64336)
+++ projects/microcontainer/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ContextInfo.java	2007-07-28 21:18:17 UTC (rev 64337)
@@ -24,6 +24,7 @@
 import java.io.Serializable;
 import java.util.List;
 
+import org.jboss.deployers.spi.attachments.ManagedObjectAttachments;
 import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
 
 /**
@@ -33,7 +34,7 @@
  * @author adrian at jboss.org
  * @version $Revision: 1.1$
  */
-public interface ContextInfo extends PredeterminedManagedObjectAttachments, Serializable
+public interface ContextInfo extends ManagedObjectAttachments, Serializable
 {
    /** The default metadata path */
    String DEFAULT_METADATA_PATH = "META-INF";

Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java	2007-07-27 22:14:13 UTC (rev 64336)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java	2007-07-28 21:18:17 UTC (rev 64337)
@@ -22,11 +22,13 @@
 package org.jboss.deployers.structure.spi.helpers;
 
 import java.util.List;
+import java.util.Map.Entry;
 
 import org.jboss.deployers.client.spi.Deployment;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.DeploymentState;
 import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
 import org.jboss.deployers.spi.structure.ContextInfo;
 import org.jboss.deployers.spi.structure.StructureMetaData;
 import org.jboss.deployers.spi.structure.StructureMetaDataFactory;
@@ -145,7 +147,8 @@
    }
 
    /**
-    * Apply the context info
+    * Apply the context info. This transfers the PredeterminedManagedObjects
+    * and TransientManagedObjects from the ContextInfo the DeploymentContext.
     * 
     * @param context the context
     * @param contextInfo the contextInfo
@@ -156,8 +159,17 @@
       Attachments attachments = contextInfo.getPredeterminedManagedObjects();
       if (attachments != null)
          context.setPredeterminedManagedObjects(attachments);
+      attachments = contextInfo.getTransientManagedObjects();
+      if (attachments != null)
+      {
+         MutableAttachments ma = context.getTransientAttachments();
+         for(Entry<String, Object> entry : attachments.getAttachments().entrySet())
+         {
+            ma.addAttachment(entry.getKey(), entry.getValue());
+         }
+      }
    }
-   
+
    /**
     * Create the root deployment context
     * 




More information about the jboss-cvs-commits mailing list