[jboss-cvs] JBossAS SVN: r88869 - in branches/Branch_5_x: system/src/main/org/jboss/system/server/profileservice/repository and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 14 10:29:03 EDT 2009


Author: emuckenhuber
Date: 2009-05-14 10:29:02 -0400 (Thu, 14 May 2009)
New Revision: 88869

Modified:
   branches/Branch_5_x/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
   branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java
   branches/Branch_5_x/testsuite/src/resources/profileservice/override/profileservice-remove-ds.xml
   branches/Branch_5_x/testsuite/src/resources/profileservice/override/testQueue-service.xml
   branches/Branch_5_x/testsuite/src/resources/profileservice/override/testTopic-service.xml
Log:
[JBAS-6227] more test on removeComponent

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java	2009-05-14 14:29:02 UTC (rev 88869)
@@ -155,7 +155,7 @@
          
          if(persistedProperty == null)
          {
-            // Create a new peristed property
+            // Create a new persisted property
             persistedProperty = createPersistedProperty(property);
          }
          

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java	2009-05-14 14:29:02 UTC (rev 88869)
@@ -118,6 +118,8 @@
    @Override
    public PersistenceRoot addComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component)
    {
+      if(root == null)
+         throw new IllegalArgumentException("null persistence root");
       ComponentMapper mapper = getComponentMapper(parent);
       PersistedComponent persistedComponent = mapper.addComponent(parent.getAttachment(), component);
       return addPersistedComponent(root, persistedComponent);
@@ -134,6 +136,9 @@
    @Override
    public PersistenceRoot removeComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component)
    {
+      if(root == null)
+         throw new IllegalArgumentException("null persistence root");
+      
       ComponentMapper mapper = getComponentMapper(parent);
       PersistedComponent persistedComponent = mapper.removeComponent(parent.getAttachment(), component);
       return addPersistedComponent(root, persistedComponent);
@@ -150,6 +155,9 @@
    @Override
    public PersistenceRoot updateComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component)
    {
+      if(root == null)
+         throw new IllegalArgumentException("null persistence root");
+      
       ComponentMapper mapper = getComponentMapper(parent);
       PersistedComponent persistedComponent = mapper.updateComponent(parent.getAttachment(), component);
       return addPersistedComponent(root, persistedComponent);

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java	2009-05-14 14:29:02 UTC (rev 88869)
@@ -440,17 +440,16 @@
          // Is attachmentName the same as the className ?
          attachment.setName(attachmentName);
          attachment.setClassName(managedObject.getAttachment().getClass().getName());
+
+         // Add the comp as transient attachment
+         attachment.setAttachment(comp);
          
-         // Create the persistence information and add it as a transient attachment
-         PersistenceRoot persistedMO = createPersistedMetaData(managedObject, comp, remove);
-         attachment.setAttachment(persistedMO);
-         
          // Update lastModified
          currentContextMetaData.setLastModified(lastModified);
       }
       
       // Save the attachment for the root
-      saveAttachmentMetaData(deploymentPath, savedMetaData);
+      saveAttachmentMetaData(deploymentPath, savedMetaData, remove);
 
       // Set the last modified on the root metadata
       savedMetaData.setLastModified(lastModified);
@@ -517,7 +516,7 @@
     * @param metaData the repository meta data.
     * @throws Exception
     */
-   private void saveAttachmentMetaData(String deploymentPath, RepositoryAttachmentMetaData metaData)
+   private void saveAttachmentMetaData(String deploymentPath, RepositoryAttachmentMetaData metaData, boolean remove)
       throws Exception
    {
       boolean trace = log.isTraceEnabled();
@@ -530,11 +529,13 @@
             // Only save attachment if the attachment is present :)
             if(attachment.getAttachment() == null)
                continue;
-            
-            // Get the xml for the persisted attachment
-            PersistenceRoot root = (PersistenceRoot) attachment.getAttachment();
-            
+
             String attachmentPath = deploymentPath + attachment.getName();
+            // Get the previous attachment
+            PersistenceRoot root = serializer.loadAttachment(attachmentPath, PersistenceRoot.class);
+            ManagedComponent component = (ManagedComponent) attachment.getAttachment();
+            root = createPersistedMetaData(root, component, remove);
+
             // Serialize the attachment
             serializer.saveAttachment(attachmentPath, root);
             
@@ -549,7 +550,7 @@
          for(RepositoryAttachmentMetaData child : metaData.getChildren())
          {
             String childDeploymentPath = deploymentPath + File.separator + child.getDeploymentName() + File.separator;
-            saveAttachmentMetaData(childDeploymentPath, child);
+            saveAttachmentMetaData(childDeploymentPath, child, remove);
          }
       }
    }
@@ -562,15 +563,24 @@
     * @param handler the persistence handler
     * @return the xml metadata.
     */
-   protected PersistenceRoot createPersistedMetaData(ManagedObject parent, ManagedComponent component, boolean remove)
+   protected PersistenceRoot createPersistedMetaData(PersistenceRoot root, ManagedComponent component, boolean remove)
    {
+      if(root == null)
+         root = new PersistenceRoot();
+      // Get the parent ManagedCommon
+      ManagedCommon parent = component;
+      while(parent.getParent() != null)
+         parent = parent.getParent();
+
+      // Get the managed object, as a component can also be a child of a managedObject
+      ManagedObject managedObject = component.getDeployment().getManagedObject(parent.getName());
       if(remove)
       {
-         return this.persistenceFactory.removeComponent(parent, component);
+         return this.persistenceFactory.removeComponent(root, managedObject, component);
       }
       else
       {
-         return this.persistenceFactory.updateComponent(parent, component);
+         return this.persistenceFactory.updateComponent(root, managedObject, component);
       }
    }
    

Modified: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java	2009-05-14 14:29:02 UTC (rev 88869)
@@ -21,7 +21,6 @@
  */
 package org.jboss.test.server.profileservice.persistence.support;
 
-import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
@@ -34,9 +33,10 @@
  * @version $Revision$
  */
 @ManagementObject
-public class TestMetaData implements Serializable
+public class TestMetaData
 {
 
+   /** The name. */
    String name;
    
    /** The primitive */

Modified: branches/Branch_5_x/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java
===================================================================
--- branches/Branch_5_x/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java	2009-05-14 14:29:02 UTC (rev 88869)
@@ -100,10 +100,11 @@
    protected void removeComponent(Object attachment, PersistedComponent component)
    {
       ServiceDeployment deployment = (ServiceDeployment) attachment;
-      List<ServiceMetaData> services = deployment.getServices();
-      if(services != null && services.isEmpty() == false)
+      List<ServiceMetaData> deploymentServices = deployment.getServices();
+      List<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+      if(deploymentServices != null && deploymentServices.isEmpty() == false)
       {
-         for(ServiceMetaData metaData : services)
+         for(ServiceMetaData metaData : deploymentServices)
          {
             // Ignore the removed bean
             if(metaData.getObjectName().getCanonicalName().

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java	2009-05-14 14:29:02 UTC (rev 88869)
@@ -26,6 +26,7 @@
 
 import org.jboss.deployers.spi.management.KnownComponentTypes;
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedComponent;
@@ -49,6 +50,11 @@
 public class JmsDestinationOverrideTestCase extends AbstractProfileServiceTest
 {
    
+   /** The queue type. */
+   public static final ComponentType QueueType = KnownComponentTypes.JMSDestination.Queue.getType();
+   /** The topic type. */
+   public static final ComponentType TopicType = KnownComponentTypes.JMSDestination.Topic.getType();
+   
    /** The meta type. */
    protected static final MapCompositeMetaType securityConfType;
    
@@ -82,6 +88,7 @@
          ManagedDeployment md = mgtView.getDeployment(deploymentName);
          assertNotNull(md);
 
+         // Modify 
          ManagedComponent component = md.getComponent("testQueue");
          assertNotNull(component);
          
@@ -93,6 +100,27 @@
          
          mgtView.updateComponent(component);
 
+         // Remove
+         component = md.getComponent("testRemoveQueue");
+         assertNotNull(component);
+         
+         //
+         mgtView.removeComponent(component);
+         redeploy(component.getDeployment().getName());
+         
+         // Check removed
+         mgtView = getManagementView();
+         component = mgtView.getComponent("testRemoveQueue", QueueType);
+         assertNull("component removed", component);
+         
+         // Check updated 
+         component = md.getComponent("testQueue");
+         assertNotNull(component);
+         
+         property = component.getProperty("downCacheSize");
+         assertNotNull(property);
+         assertEquals(property.getValue(), SimpleValueSupport.wrap(3000));
+         
       }
       catch(Throwable e)
       {
@@ -177,6 +205,7 @@
          ManagedDeployment md = mgtView.getDeployment(deploymentName);
          assertNotNull(md);
 
+         // Update
          ManagedComponent component = md.getComponent("testTopic");
          assertNotNull(component);
 
@@ -188,6 +217,17 @@
          
          mgtView.updateComponent(component);
          
+         // Remove
+         component = md.getComponent("testRemoveTopic");
+         assertNotNull(component);
+         
+         //
+         mgtView.removeComponent(component);
+         redeploy(component.getDeployment().getName());
+         
+         mgtView = getManagementView();
+         component = mgtView.getComponent("testRemoveTopic", TopicType);
+         assertNull("topic removed", component);
       }
       catch(Throwable e)
       {
@@ -207,5 +247,15 @@
       return new CompositeValueSupport(composite, map);
    }
 
+   protected void redeploy(String name) throws Exception
+   {
+      DeploymentProgress progress = getDeploymentManager().redeploy(name);
+      progress.run();
+      if(progress.getDeploymentStatus().isFailed())
+      {
+         throw new IllegalStateException("Redeployment failed ", progress.getDeploymentStatus().getFailure());
+      }
+   }
+   
 }
 

Modified: branches/Branch_5_x/testsuite/src/resources/profileservice/override/profileservice-remove-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/profileservice/override/profileservice-remove-ds.xml	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/testsuite/src/resources/profileservice/override/profileservice-remove-ds.xml	2009-05-14 14:29:02 UTC (rev 88869)
@@ -47,5 +47,40 @@
          <type-mapping>Hypersonic SQL</type-mapping>
       </metadata>
    </local-tx-datasource>
+   
+    <local-tx-datasource>
+        <jndi-name>OtherLocalRemoveDS</jndi-name>
+        <rar-name>jboss-local-jdbc.rar</rar-name>
+        <use-java-context>true</use-java-context>
+        <connection-definition>javax.sql.DataSource</connection-definition>
+        <jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
+        <min-pool-size>0</min-pool-size>
+        <max-pool-size>10</max-pool-size>
+        <blocking-timeout-millis>30000</blocking-timeout-millis>
+        <idle-timeout-minutes>30</idle-timeout-minutes>
+        <prefill>false</prefill>
+        <background-validation>false</background-validation>
+        <background-validation-millis>0</background-validation-millis>
+        <validate-on-match>true</validate-on-match>
+        <statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
+        <isSameRM-override-value>false</isSameRM-override-value>
+        <allocation-retry>0</allocation-retry>
+        <allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
+        <security-domain xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+        <metadata>
+            <type-mapping>Oracle9i</type-mapping>
+        </metadata>
+        <type-mapping>Oracle9i</type-mapping>
+        <local-transaction/>
+        <check-valid-connection-sql>SELECT * FROM DUAL</check-valid-connection-sql>
+        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+        <prepared-statement-cache-size>0</prepared-statement-cache-size>
+        <share-prepared-statements>false</share-prepared-statements>
+        <set-tx-query-timeout>false</set-tx-query-timeout>
+        <query-timeout>0</query-timeout>
+        <use-try-lock>60000</use-try-lock>
+        <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
+        <connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
+    </local-tx-datasource>
 
 </datasources>
\ No newline at end of file

Modified: branches/Branch_5_x/testsuite/src/resources/profileservice/override/testQueue-service.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/profileservice/override/testQueue-service.xml	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/testsuite/src/resources/profileservice/override/testQueue-service.xml	2009-05-14 14:29:02 UTC (rev 88869)
@@ -8,4 +8,14 @@
         <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
         <depends>jboss.messaging:service=PostOffice</depends>
     </mbean>
+    
+     <mbean	xmbean-dd="xmdesc/Queue-xmbean.xml"
+    		name="jboss.messaging.destination:service=Queue,name=testRemoveQueue"
+    		code="org.jboss.jms.server.destination.QueueService">
+    		
+        <attribute name="JNDIName">testRemoveQueue</attribute>
+        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+        <depends>jboss.messaging:service=PostOffice</depends>
+    </mbean>
+    
 </server>

Modified: branches/Branch_5_x/testsuite/src/resources/profileservice/override/testTopic-service.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/profileservice/override/testTopic-service.xml	2009-05-14 14:28:47 UTC (rev 88868)
+++ branches/Branch_5_x/testsuite/src/resources/profileservice/override/testTopic-service.xml	2009-05-14 14:29:02 UTC (rev 88869)
@@ -8,4 +8,14 @@
         <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
         <depends>jboss.messaging:service=PostOffice</depends>
     </mbean>
+    
+    <mbean	xmbean-dd="xmdesc/Topic-xmbean.xml"
+    		name="jboss.messaging.destination:service=Topic,name=testRemoveTopic"
+    		code="org.jboss.jms.server.destination.TopicService">
+
+        <attribute name="JNDIName">testRemoveTopic</attribute>
+        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+        <depends>jboss.messaging:service=PostOffice</depends>
+    </mbean>
+    
 </server>




More information about the jboss-cvs-commits mailing list