[jboss-cvs] JBossAS SVN: r100913 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/profile/metadata/plugin and 17 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 12 09:25:00 EST 2010


Author: emuckenhuber
Date: 2010-02-12 09:24:59 -0500 (Fri, 12 Feb 2010)
New Revision: 100913

Added:
   projects/profileservice/trunk/plugins/src/test/java/org/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/NoopManagementProxyFactory.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestComponentMetaData.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestMetaData.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceComponentMetaData.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceMetaData.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/BasicMgtViewUnitTestCase.java
   projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/SimpleViewUnitTestCase.java
   projects/profileservice/trunk/plugins/src/test/resources/log4j.properties
Removed:
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java
Modified:
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerLifeCycleCallback.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java
   projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java
   projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
   projects/profileservice/trunk/plugins/pom.xml
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/ManagementViewWrapper.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/package-info.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/PlatformMBeanView.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java
   projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewProcessingContext.java
   projects/profileservice/trunk/spi/pom.xml
Log:
basic mgtView test cases.

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -25,10 +25,12 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.action.engine.ActionController;
 
 /**
  * The HDScannerFactory represents a HDScanner registry for profiles, having
@@ -43,9 +45,24 @@
    /** The logger. */
    protected static final Logger log = Logger.getLogger(HDScannerFactory.class);
    
-   /** The active scans. */
+   /** The registered scans. */
    private Map<ProfileKey, ScannerWrapper> registeredScans = new ConcurrentHashMap<ProfileKey, ScannerWrapper>(); 
   
+   /** The action controller. */
+   private final ActionController actionController;
+   
+   /** Flag indicating if scanners can be scheduled. */
+   private final AtomicBoolean enabled = new AtomicBoolean(false);
+   
+   protected AbstractHDScannerFactory(ActionController actionController)
+   {
+      if(actionController == null)
+      {
+         throw new IllegalArgumentException("null action controller");
+      }
+      this.actionController = actionController;
+   }
+   
    /**
     * Schedule a HDScanner for execution.
     * 
@@ -62,6 +79,8 @@
     */
    public void stop()
    {
+      // This should have been set already
+      enabled.set(false);
       // Actually all scanners should be unregistered during the profile lifecycle
       for(ProfileKey key : this.registeredScans.keySet())
       {
@@ -93,7 +112,12 @@
          throw new IllegalArgumentException("scanner already registered for profile " + key);
       }
       HDScanner scanner = new HDScanner(profile, null);      
-      return createScannerWrapper(key, scanner, configuration);
+      ScannerWrapper wrapper = createScannerWrapper(key, scanner, configuration);
+      if(wrapper.isStartAutomatically() && enabled.get())
+      {
+         wrapper.start();
+      }
+      return wrapper;
    }
 
    /**
@@ -130,6 +154,42 @@
    }
    
    /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void enableScanning()
+   {
+      if(enabled.getAndSet(true) == false)
+      {
+         synchronized (registeredScans)
+         {
+            for(ScannerWrapper wrapper : registeredScans.values())
+            {
+               if(wrapper.isStartAutomatically())
+               {
+                  wrapper.start();
+               }
+            }  
+         }
+      }
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void disabledScanning()
+   {
+      if(enabled.getAndSet(false))
+      {
+         for(ProfileKey key : registeredScans.keySet())
+         {
+            stopScanner(key);
+         }
+      }
+   }
+   
+   /**
     * Schedule a HDScanner for execution.
     * 
     * @param scanner the hd scanner
@@ -138,6 +198,10 @@
     */
    protected ScheduledFuture<Void> schedule(HDScanner scanner, ScannerConfiguration configuration)
    {
+      if(enabled.get() == false)
+      {
+         throw new IllegalStateException("scanning is disabled");
+      }
       if(this.registeredScans.containsKey(scanner.getKey()) == false)
       {
          throw new IllegalStateException("Scanner unregistered " + scanner.getKey());
@@ -170,7 +234,7 @@
     * @param activeScan the schedule future
     * @return the scanner wrapper
     */
-   protected Scanner createScannerWrapper(ProfileKey key, HDScanner scanner, ScannerConfiguration configuration)
+   protected ScannerWrapper createScannerWrapper(ProfileKey key, HDScanner scanner, ScannerConfiguration configuration)
    {
       ScannerWrapper wrapper = new ScannerWrapper(scanner, configuration);
       this.registeredScans.put(key, wrapper);
@@ -216,6 +280,12 @@
          return configuration.getTimeUnit();
       }
       
+      @Override
+      public boolean isStartAutomatically()
+      {
+         return configuration.isStartAutomatically();
+      }
+      
       /**
        * {@inheritDoc}
        */

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -27,6 +27,8 @@
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 
+import org.jboss.profileservice.spi.action.engine.ActionController;
+
 /**
  * The default HDScanner factory.
  * 
@@ -44,8 +46,12 @@
    
    /** Thread name used when the ScheduledExecutorService is created internally. */
    private String scanThreadName = "HDScanner";
+
+   public DefaultHDScannerFactory(ActionController actionController)
+   {
+      super(actionController);
+   }
    
-
    /**
     * Get the optional thread factory used to create
     * the ScheduledExcecutor.

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -36,6 +36,10 @@
 /**
  * The HDScanner.
  * 
+ * TODO This needs to be redone, since all deployment action should be using
+ * the actionController to get exclusive access to a profile. The checking and
+ * deployment should be part of a ModificationAction...  
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -34,6 +34,27 @@
 {
 
    /**
+    * Enable the scanning. This is used
+    * when the deployment process is complete
+    * and the server is started to signal that
+    * the HDScanner can start.
+    *
+    * Scanners registered with startAutomatically
+    * enabled will be scheduled.
+    * 
+    * Until this point no HDScanner is allowed to
+    * schedule itself using it's lifecycle methods.
+    */
+   void enableScanning();
+   
+   /**
+    * Disable HDScanning. This will stop all
+    * registered scanners and prevent other
+    * HDScanners from starting.
+    */
+   void disabledScanning();
+   
+   /**
     * Register a mutable profile for HDScanning.
     * 
     * @param profile the mutable profile

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerLifeCycleCallback.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerLifeCycleCallback.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerLifeCycleCallback.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -26,7 +26,7 @@
 import org.jboss.profileservice.spi.Profile;
 
 /**
- * Lifecycle callback registering a HDScanner, for mutable 
+ * Lifecycle callback registering a HDScanner, for mutable profiles.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -28,6 +28,7 @@
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementObjectID;
 import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperties;
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.jboss.profileservice.spi.ProfileKey;
 
@@ -36,8 +37,9 @@
  *
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  */
-// TODO scan-period should be configurable through a management interface 
- at ManagementObject(componentType = @ManagementComponent(type="Profile", subtype = "HDScanner"))
+// TODO check how to expose this scanner MO through PS 
+ at ManagementObject(componentType = @ManagementComponent(type="Profile", subtype = "HDScanner"),
+      properties = ManagementProperties.EXPLICIT)
 public interface Scanner extends ScannerConfiguration
 {
    

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -47,6 +47,19 @@
     * @return the time unit
     */
    TimeUnit getTimeUnit();
+
+   /**
+    * Boolean flag indicating if the scanner
+    * should be started automatically, once the 
+    * boostrap deployment process is complete.
+    * 
+    * When the server is started and the flag is
+    * set to true the scanner will be started
+    * as well.
+    * 
+    * @return true if the should be started, false otherwise
+    */
+   boolean isStartAutomatically();
    
 }
 

Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -37,6 +37,15 @@
 /**
  * Hot deployment scanner scan-period configuration.
  * 
+ * The default values are:
+ * 
+ * scanPersion = 5
+ * timeUnit = seconds
+ * startAutomatically = true
+ * disabled = false
+ * 
+ * TODO The default values should maybe come from a different configuration?
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -57,6 +66,10 @@
    /** The time unit. */
    private TimeUnit timeUnit = TimeUnit.SECONDS;
    
+   /** Start the scanner automatically. */
+   // The default is true
+   private boolean startAutomatically = true;
+   
    /** Disable hot deployment. */
    private boolean disabled = false;
    
@@ -82,6 +95,17 @@
       this.scanPeriod = scanPeriod;
    }
    
+   @XmlAttribute(name = "start-automatically")
+   public boolean isStartAutomatically()
+   {
+      return this.startAutomatically;
+   }
+   
+   public void setStartAutomatically(boolean startAutomatically)
+   {
+      this.startAutomatically = startAutomatically;
+   }
+   
    @XmlAttribute(name = "disabled")
    public boolean isDisabled()
    {

Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -29,6 +29,7 @@
 import org.jboss.profileservice.hotdeploy.DefaultHDScannerFactory;
 import org.jboss.profileservice.hotdeploy.Scanner;
 import org.jboss.profileservice.hotdeploy.ScannerConfiguration;
+import org.jboss.profileservice.management.AbstractActionController;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
@@ -37,22 +38,42 @@
 import org.jboss.test.BaseTestCase;
 
 /**
+ * Basic HDScanner testcase.
+ * 
+ * TODO we should be using ByteMan to do more fine grained testing. 
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
 public class HDScannerUnitTestCase extends BaseTestCase
 {
 
+   private DefaultHDScannerFactory scannerFactory;
+   
    public HDScannerUnitTestCase(String name)
    {
       super(name);
    }
    
-   public void test() throws Exception
+   @Override
+   protected void setUp() throws Exception
    {
+      super.setUp();
+      this.scannerFactory = new DefaultHDScannerFactory(new AbstractActionController());
+      this.scannerFactory.start();
+   }
+   
+   @Override
+   protected void tearDown() throws Exception
+   {
+      this.scannerFactory.stop();
+      super.tearDown();
+   }
+   
+   public void testBasic() throws Exception
+   {
       enableTrace("org.jboss.profileservice.hotdeploy");
-      DefaultHDScannerFactory scannerFactory = new DefaultHDScannerFactory();
-      scannerFactory.start();
+      scannerFactory.enableScanning();
       
       Scanner scanner1 = scannerFactory.registerScanner(new TestProfile(new ProfileKey("test1")), new TestConfiguration());
       Scanner scanner2 = scannerFactory.registerScanner(new TestProfile(new ProfileKey("test2")), new TestConfiguration());
@@ -79,7 +100,7 @@
       assertFalse(scanner2.isScheduled());
       
       // Stop
-      scannerFactory.stop();
+      scannerFactory.disabledScanning();
       assertFalse(scanner1.isScheduled());
       try
       {
@@ -92,8 +113,60 @@
       }
    }
  
+   public void testAutomaticActivation() throws Exception
+   {
+      enableTrace("org.jboss.profileservice.hotdeploy");
+      
+      Scanner scanner1 = scannerFactory.registerScanner(new TestProfile(new ProfileKey("test1")), new TestConfiguration(true));
+      Scanner scanner2 = scannerFactory.registerScanner(new TestProfile(new ProfileKey("test2")), new TestConfiguration());
+      
+      assertNotNull(scanner1);
+      assertNotNull(scanner2);
+      assertFalse(scanner1.isScheduled());
+      assertFalse(scanner2.isScheduled());
+      assertEquals(0, scanner1.getScanCount());
+      assertEquals(0, scanner2.getScanCount());
+      
+      scannerFactory.enableScanning();
+
+      Thread.sleep(6);
+      
+      assertTrue(scanner1.isScheduled());
+      assertFalse(scanner2.isScheduled());
+      assertTrue(scanner1.getScanCount() > 1);
+      assertEquals(0, scanner2.getScanCount());
+
+      scanner2.start();
+      
+      Thread.sleep(6);
+
+      assertTrue(scanner1.isScheduled());
+      assertTrue(scanner2.isScheduled());
+      assertTrue(scanner1.getScanCount() > 1);
+      assertTrue(scanner2.getScanCount() > 1);
+      
+      scannerFactory.disabledScanning();
+
+      assertFalse(scanner1.isScheduled());
+      assertFalse(scanner2.isScheduled());
+      
+   }
+   
+   
    static class TestConfiguration implements ScannerConfiguration
    {
+      boolean start = false;
+      
+      public TestConfiguration()
+      {
+         // nothing
+      }
+      
+      public TestConfiguration(boolean start)
+      {
+         this.start = start;
+      }
+      
       @Override
       public int getScanPeriod()
       {
@@ -104,6 +177,11 @@
       {
          return TimeUnit.MILLISECONDS;
       }
+      @Override
+      public boolean isStartAutomatically()
+      {
+         return start;
+      }
    }
    
    static class TestProfile implements MutableProfile

Modified: projects/profileservice/trunk/plugins/pom.xml
===================================================================
--- projects/profileservice/trunk/plugins/pom.xml	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/pom.xml	2010-02-12 14:24:59 UTC (rev 100913)
@@ -14,14 +14,8 @@
   <description>JBoss ProfileService Deployment and Management plugins</description>
 
   <dependencies>
-  
+   
  	<dependency>
-		<groupId>junit</groupId>
-		<artifactId>junit</artifactId>
-		<scope>test</scope>
-	</dependency>
-  
- 	<dependency>
 		<groupId>org.jboss.logging</groupId>
 		<artifactId>jboss-logging-log4j</artifactId>
 		<scope>provided</scope>
@@ -30,9 +24,13 @@
 	<dependency>
 		<groupId>org.jboss.man</groupId>
 		<artifactId>jboss-managed</artifactId>
-		<scope>provided</scope>
 	</dependency>
   
+	<dependency>
+		<groupId>org.jboss</groupId>
+		<artifactId>jboss-mdr</artifactId>
+	</dependency>
+  
  	<dependency>
 		<groupId>org.jboss.profileservice</groupId>
 		<artifactId>jboss-profileservice-spi</artifactId>
@@ -52,6 +50,13 @@
 		<scope>provided</scope>
 	</dependency>
 	
+	<dependency>
+		<groupId>org.jboss.test</groupId>
+		<artifactId>jboss-test</artifactId>
+		<version>${version.jboss.test}</version>
+		<scope>test</scope>
+	</dependency>
+	
   </dependencies>
   
 </project>

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -55,14 +55,14 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-class AggregatingLocalManagementView implements ManagementView
+public class AggregatingLocalManagementView implements ManagementView
 {
 
    /** The logger. */
    private static final Logger log = Logger.getLogger(AggregatingLocalManagementView.class);
    
    /** The bundle name. */
-   private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages";
+   private static final String BUNDLE_NAME = "org.jboss.profileservice.plugins.management.messages";
    
    /** The internationalization resource bundle. */
    private ResourceBundle i18n;

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/ManagementViewWrapper.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/ManagementViewWrapper.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/ManagementViewWrapper.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -139,12 +139,14 @@
       return getDelegateView().load();
    }
 
+   @SuppressWarnings("deprecation")
    @Override
    public void process() throws Exception
    {
       getDelegateView().process();
    }
 
+   @SuppressWarnings("deprecation")
    @Override
    public void reload()
    {

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -141,7 +141,7 @@
     * @param mo the managed object
     * @param md the managed deployment
     */
-   protected void processManagedObject(ManagedObject mo, ManagedDeployment md, ProfileViewProcessingContext context)
+   public void processManagedObject(ManagedObject mo, ManagedDeployment md, ProfileViewProcessingContext context)
       throws Exception
    {
       boolean trace = log.isTraceEnabled(); 
@@ -178,16 +178,20 @@
             runtimeMOs.remove(key);
          }
          // Update the runtime state of any ManagedComponent associated with this runtime mo
-         ManagedComponent comp = md.getComponent(mo.getName());
-         if (comp != null)
+         if(md != null && md.getComponents() != null)
          {
-            RunState state = updateRunState(mo, comp);
-            if(trace)
+            ManagedComponent comp = md.getComponent(mo.getName());
+            if (comp != null)
             {
-               log.trace("Updated component: "+comp+" run state to: "+state);
+               RunState state = updateRunState(mo, comp);
+               if(trace)
+               {
+                  log.trace("Updated component: "+comp+" run state to: "+state);
+               }
+               
             }
-            
          }
+         
          // There is no further processing of runtime ManagedObjects, unless its marked as a component
          if (isMC == false)
             return;
@@ -209,13 +213,16 @@
             mergeRuntimeMO(mo, runtimeMO);
             runtimeMOs.remove(key);
             // Update the runtime state of any ManagedComponent associated with this runtime mo
-            ManagedComponent comp = md.getComponent(mo.getName());
-            if (comp != null)
+            if(md != null && md.getComponents() != null)
             {
-               RunState state = updateRunState(runtimeMO, comp);
-               if(trace)
+               ManagedComponent comp = md.getComponent(mo.getName());
+               if (comp != null)
                {
-                  log.trace("Updated component: "+comp+" run state to: "+state);
+                  RunState state = updateRunState(runtimeMO, comp);
+                  if(trace)
+                  {
+                     log.trace("Updated component: "+comp+" run state to: "+state);
+                  }
                }
             }
          }
@@ -225,27 +232,32 @@
       checkForReferences(key, mo);
 
       // Map any existing ManagedComponent types
-      for(ManagedComponent comp : md.getComponents().values())
+      if(md != null && md.getComponents() != null)
       {
-         if(trace)
+         for(ManagedComponent comp : md.getComponents().values())
          {
-            log.trace("Updating ManagementComponent: "+comp);
+            if(trace)
+            {
+               log.trace("Updating ManagementComponent: "+comp);
+            }
+            context.addManagedComponent(comp);
          }
-         context.addManagedComponent(comp);
       }
 
       // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
       ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
-      if (mc != null && md.getComponent(mo.getName()) == null)
+      if (mc != null)
       {
          ComponentType type = new ComponentType(mc.type(), mc.subtype());
          ManagedComponentImpl comp = new ManagedComponentImpl(type, md, mo);
-         md.addComponent(mo.getName(), comp);
          if(trace)
          {
             log.trace("Processing ManagementComponent("+mo.getName()+"): "+comp);
          }
-         
+         if(md != null && md.getComponent(mo.getName()) == null)
+         {
+            md.addComponent(mo.getName(), comp);
+         }
          context.addManagedComponent(comp);
          updateRunState(null, comp);
       }
@@ -253,7 +265,6 @@
       // Scan for @ManagementObjectRef
       for(ManagedProperty prop : mo.getProperties().values())
       {
-         log.debug("Checking property: "+prop);
          // See if this is a ManagementObjectID
          Map<String, Annotation> pannotations = prop.getAnnotations();
          if (pannotations != null && pannotations.isEmpty() == false)

Deleted: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -1,94 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.profileservice.plugins.management.util;
-
-import java.util.Map;
-
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.util.collection.ConcurrentReferenceHashMap;
-import org.jboss.util.collection.ConcurrentReferenceHashMap.ReferenceType;
-
-/**
- * Registry for runtime ManagedObjects.
- * 
- * TODO we need to change the composition of managed objects.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-class RuntimeManagedObjectRegistry
-{
- 
-   /** The runtime managed objects. */
-   private Map<String, ManagedObject> runtimeMOs = new ConcurrentReferenceHashMap<String, ManagedObject>(ReferenceType.STRONG, ReferenceType.WEAK);
-   
-   /**
-    * Get a registered runtime ManagedObject.
-    * 
-    * @param name the runtime managed object name
-    * @return the runtime managed object, null if not available
-    */
-   public ManagedObject get(String name)
-   {
-      if(name == null)
-      {
-         throw new IllegalArgumentException("null runtime MO name");
-      }
-      return this.runtimeMOs.get(name);
-   }
-   
-   /**
-    * Add a runtime ManagedObject.
-    * 
-    * @param name the runtime managed object name
-    * @param mo the runtime managed object
-    */
-   public void put(String name, ManagedObject mo)
-   {
-      if(name == null)
-      {
-         throw new IllegalArgumentException("null runtime MO name");
-      }
-      if(mo == null)
-      {
-         throw new IllegalArgumentException("null runtime MO");
-      }
-      this.runtimeMOs.put(name, mo);
-   }
-   
-   /**
-    * Remove a runtime ManagedObject from the registry.
-    * 
-    * @param name the runtime managed object name
-    * @return the removed object or null if not registered
-    */
-   public ManagedObject remove(String name)
-   {
-      if(name == null)
-      {
-         throw new IllegalArgumentException("null name");
-      }
-      return this.runtimeMOs.remove(name);
-   }
-   
-}
-

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/package-info.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/package-info.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/package-info.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -20,6 +20,13 @@
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
 /**
+ * TODO 
  * 
+ * Basically most of the additional processing should be moved to
+ * jboss-man. Creating ManagedObject/ManagedComponents should not
+ * need duplicate processing and follow visitor pattern - where
+ * we can apply runtime behavior, composition, ... while generating 
+ * the MOs in the Deployers.
+ * 
  */
 package org.jboss.profileservice.plugins.management.util;
\ No newline at end of file

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -69,7 +69,7 @@
    
    public boolean load()
    {
-      if(this.modified.getAndSet(false))
+      if(this.modified.getAndSet(false) == false)
       {
          return false;
       }
@@ -98,14 +98,15 @@
       {
          for(final ManagedDeployment d : managedDeployments.values())
          {
-            if(name.equals(d.getSimpleName()))
+            // Only check top-level deployments for the simple name
+            if(d.getParent() == null && name.equals(d.getSimpleName()))
             {
                deployment = d;
                break;
             }
          }
       }
-      return null;
+      return deployment;
    }
    
    /**

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/PlatformMBeanView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/PlatformMBeanView.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/PlatformMBeanView.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -21,22 +21,18 @@
 */
 package org.jboss.profileservice.plugins.management.view;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.Collection;
 
 import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.plugins.ManagedDeploymentImpl;
 import org.jboss.managed.plugins.jmx.ManagementFactoryUtils;
 import org.jboss.profileservice.plugins.spi.ProfileView;
 
 /**
  * A ProfileView exposing the Platform MBeans as <code>ManagedComponents</code>.
  * 
- * This view is immutable, it will only get create the first time
+ * This view is immutable, it will only get created the first time
  * the view gets loaded. Therefore all containing <code>ManagedObject</code>s
  * and/or <code>ManagedComponent</code>s need to declare dynamic properties,
  * as <code>ViewUse.STATISTIC</code> and <code>runtime=true</code>.
@@ -55,35 +51,6 @@
    
    /** The profile view. */
    private final AbstractProfileView view;
-   
-   protected static ManagedDeployment getDeployment()
-   {
-      // TODO we need a more flexible way to declare/add ManagedObjects/Components
-      // Creating non-existing deployments to reuse existing code does not make much sense 
-      Map<String, ManagedObject> platformMBeanMOs = ManagementFactoryUtils.getPlatformMBeanMOs(managedObjFactory);
-      ManagedDeploymentImpl platformMBeans = new ManagedDeploymentImpl("JDK PlatformMBeans", "PlatformMBeans", null,
-            platformMBeanMOs);
-      List<ManagedObject> gcMbeans = ManagementFactoryUtils.getGarbageCollectorMXBeans(managedObjFactory);
-      Map<String, ManagedObject> gcMOs = new HashMap<String, ManagedObject>();
-      for (ManagedObject mo : gcMbeans)
-         gcMOs.put(mo.getName(), mo);
-      List<ManagedObject> mmMbeans = ManagementFactoryUtils.getMemoryManagerMXBeans(managedObjFactory);
-      Map<String, ManagedObject> mmMOs = new HashMap<String, ManagedObject>();
-      for (ManagedObject mo : mmMbeans)
-         mmMOs.put(mo.getName(), mo);
-      List<ManagedObject> mpoolMBeans = ManagementFactoryUtils.getMemoryPoolMXBeans(managedObjFactory);
-      Map<String, ManagedObject> mpoolMOs = new HashMap<String, ManagedObject>();
-      for (ManagedObject mo : mpoolMBeans)
-         mpoolMOs.put(mo.getName(), mo);
-      ManagedDeploymentImpl gcMD = new ManagedDeploymentImpl("GarbageCollectorMXBeans", "GarbageCollectorMXBeans",
-            null, gcMOs);
-      platformMBeans.getChildren().add(gcMD);
-      ManagedDeploymentImpl mmMD = new ManagedDeploymentImpl("MemoryManagerMXBeans", "MemoryManagerMXBeans", null, mmMOs);
-      platformMBeans.getChildren().add(mmMD);
-      ManagedDeploymentImpl mpoolMD = new ManagedDeploymentImpl("MemoryPoolMXBeans", "MemoryPoolMXBeans", null, mpoolMOs);
-      platformMBeans.getChildren().add(mpoolMD);
-      return platformMBeans;
-   }
 
    public PlatformMBeanView()
    {
@@ -102,7 +69,14 @@
       {
          try
          {
-            getProcessorHelper().processRootManagedDeployment(getDeployment(), view);
+            // JDK PlatformMBeans
+            process(ManagementFactoryUtils.getPlatformMBeanMOs(managedObjFactory).values());
+            // GarbageCollectorMXBeans
+            process(ManagementFactoryUtils.getGarbageCollectorMXBeans(managedObjFactory));
+            // MemoryManagerMXBeans
+            process(ManagementFactoryUtils.getMemoryManagerMXBeans(managedObjFactory));
+            // MemoryPoolMXBeans
+            process(ManagementFactoryUtils.getMemoryPoolMXBeans(managedObjFactory));
          }
          catch(Exception e)
          {
@@ -113,5 +87,16 @@
       return false;
    }
    
+   protected void process(Collection<ManagedObject> managedObjects) throws Exception
+   {
+      if(managedObjects != null && managedObjects.isEmpty() == false)
+      {
+         for(ManagedObject mo : managedObjects)
+         {
+            getProcessorHelper().processManagedObject(mo, null, view);
+         }
+      }
+   }
+   
 }
 

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -120,6 +120,7 @@
     * @return the possibly null ManagedComponent
     */
    ManagedComponent getComponent(String name, ComponentType type);
+   
    /**
     * Obtain the ManagedComponents for the given name/type and matcher.
     * 

Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewProcessingContext.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewProcessingContext.java	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewProcessingContext.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -33,6 +33,7 @@
  * This will likely be similar, just based on a deployment level - 
  * not on the whole profile.
  * 
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/NoopManagementProxyFactory.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/NoopManagementProxyFactory.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/NoopManagementProxyFactory.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,98 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.plugins.mgt.support;
+
+import org.jboss.deployers.spi.management.ContextStateMapper;
+import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.profileservice.plugins.management.util.AbstractManagementProxyFactory;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NoopManagementProxyFactory extends AbstractManagementProxyFactory
+{
+
+   /** The noop component dispatcher. */
+   private static final RuntimeComponentDispatcher dispatcher = new NoopRuntimeComponentDispatcher();
+   
+   @Override
+   protected ManagedComponent createComponentProxy(ManagedComponent delegate, Object componentName)
+   {
+      return delegate;
+   }
+
+   @Override
+   protected ManagedOperation createOperationProxy(ManagedOperation delegate, Object componentName)
+   {
+      return delegate;
+   }
+
+   @Override
+   protected ManagedProperty createPropertyProxy(ManagedProperty delegate, Object componentName)
+   {
+      return delegate;
+   }
+
+   @Override
+   protected RuntimeComponentDispatcher getDispatcher()
+   {
+      return dispatcher;
+   }
+
+   static class NoopRuntimeComponentDispatcher implements RuntimeComponentDispatcher
+   {
+
+      @Override
+      public MetaValue get(Object componentName, String propertyName)
+      {
+         // FIXME get
+         return null;
+      }
+
+      @Override
+      public Object invoke(Object componentName, String methodName, MetaValue... param)
+      {
+         return null;
+      }
+
+      @Override
+      public <T extends Enum<?>> T mapControllerState(Object name, ContextStateMapper<T> mapper)
+      {
+         return mapper.getErrorState();
+      }
+
+      @Override
+      public void set(Object componentName, String propertyName, MetaValue value)
+      {
+         // FIXME set
+         
+      }
+      
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestComponentMetaData.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestComponentMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestComponentMetaData.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.plugins.mgt.support;
+
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject(componentType = @ManagementComponent(type = "Test", subtype = "1234"))
+public class TestComponentMetaData
+{
+
+   public static final ComponentType componentType = new ComponentType("Test", "1234");
+   
+   /** The component name. */
+   private String name;
+   
+   
+   public TestComponentMetaData()
+   {
+      //
+   }
+   
+   public TestComponentMetaData(String name)
+   {
+      this.name = name;
+   }
+   
+   
+   @ManagementObjectID(type = "Test")
+   @ManagementProperty(name = "name")
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestMetaData.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestMetaData.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.plugins.mgt.support;
+
+import java.util.List;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject
+public class TestMetaData
+{
+
+   /** The components. */
+   private List<TestComponentMetaData> components;
+   
+   @ManagementProperty(managed = true)
+   public List<TestComponentMetaData> getComponents()
+   {
+      return components;
+   }
+   
+   public void setComponents(List<TestComponentMetaData> components)
+   {
+      this.components = components;
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceComponentMetaData.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceComponentMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceComponentMetaData.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,72 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.plugins.mgt.support;
+
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject(isRuntime = true) //, componentType = @ManagementComponent(type = "Test", subtype = "56781"))
+public class TestServiceComponentMetaData
+{
+
+   public static final ComponentType componentType = new ComponentType("Test", "56781");
+   
+   /** The component name. */
+   private String name;
+   
+   public TestServiceComponentMetaData()
+   {
+      //
+   }
+   
+   public TestServiceComponentMetaData(String name)
+   {
+      this.name = name;
+   }
+   
+   @ManagementObjectID(type = "Test")
+   @ManagementProperty(name = "name")
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   @ManagementOperation
+   public void invoke()
+   {
+      
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceMetaData.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceMetaData.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/support/TestServiceMetaData.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,53 @@
+package org.jboss.test.profileservice.plugins.mgt.support;
+
+import java.util.List;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject
+public class TestServiceMetaData
+{
+   
+   /** The services. */
+   private List<TestServiceComponentMetaData> services;
+   
+   @ManagementProperty(managed = true)
+   public List<TestServiceComponentMetaData> getServices()
+   {
+      return services;
+   }
+   
+   public void setServices(List<TestServiceComponentMetaData> services)
+   {
+      this.services = services;
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,121 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.plugins.mgt.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
+import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
+import org.jboss.profileservice.plugins.management.util.ProfileViewProcessorHelper;
+import org.jboss.test.BaseTestCase;
+import org.jboss.test.profileservice.plugins.mgt.support.NoopManagementProxyFactory;
+import org.jboss.test.profileservice.plugins.mgt.support.TestComponentMetaData;
+import org.jboss.test.profileservice.plugins.mgt.support.TestMetaData;
+import org.jboss.test.profileservice.plugins.mgt.support.TestServiceComponentMetaData;
+import org.jboss.test.profileservice.plugins.mgt.support.TestServiceMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractViewTestBase extends BaseTestCase
+{
+   
+   /** The managed object factory. */
+   private static final ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
+   
+   /** A noop proxy factory. */
+   private static final NoopManagementProxyFactory proxyFactory = new NoopManagementProxyFactory();
+   
+   /** The helper. */
+   private ProfileViewProcessorHelper helper;
+
+   public AbstractViewTestBase(String name)
+   {
+      super(name);
+   }
+   
+   public static ManagedObjectFactory getMof()
+   {
+      return mof;
+   }
+   
+   public static NoopManagementProxyFactory getProxyfactory()
+   {
+      return proxyFactory;
+   }
+   
+   public ProfileViewProcessorHelper getHelper()
+   {
+      return helper;
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      this.helper = new ProfileViewProcessorHelper(proxyFactory);
+   }
+
+   protected ManagedDeployment createDeployment(String name, Object... objects)
+   {
+      Map<String, ManagedObject> managedObjects = new HashMap<String, ManagedObject>();
+      for(Object object : objects)
+      {
+         ManagedObject mo = getMof().initManagedObject(object, null);
+         assertNotNull(mo);
+         managedObjects.put(mo.getName(), mo);
+      }
+      return new ManagedDeploymentImpl(name, name, null, managedObjects);
+   }
+   
+   protected TestMetaData createTestMetaData(String... names)
+   {
+      TestMetaData testMetaData = new TestMetaData();
+      List<TestComponentMetaData> components = new ArrayList<TestComponentMetaData>();
+      for(String name : names)
+      {
+         components.add(new TestComponentMetaData(name));
+      }
+      testMetaData.setComponents(components);
+      return testMetaData;
+   }
+ 
+   protected TestServiceMetaData createServiceMetaData(String... names)
+   {
+      TestServiceMetaData testServiceMetaData = new TestServiceMetaData();
+      List<TestServiceComponentMetaData> services = new ArrayList<TestServiceComponentMetaData>();
+      for(String name : names)
+      {
+         services.add(new TestServiceComponentMetaData(name));
+      }
+      testServiceMetaData.setServices(services);
+      return testServiceMetaData;
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/BasicMgtViewUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/BasicMgtViewUnitTestCase.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/BasicMgtViewUnitTestCase.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,79 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.plugins.mgt.test;
+
+import java.lang.management.ManagementFactory;
+import java.util.Set;
+
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.plugins.management.AggregatingLocalManagementView;
+import org.jboss.profileservice.plugins.management.view.PlatformMBeanView;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicMgtViewUnitTestCase extends AbstractViewTestBase
+{
+
+   /** The management view. */
+   private AggregatingLocalManagementView mgtView;
+   
+   public BasicMgtViewUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   @Override
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      this.mgtView = new AggregatingLocalManagementView();
+      this.mgtView.setProxyFactory(getProxyfactory());
+      this.mgtView.start();
+   }
+   
+   
+   public void testPlatformMBeanView() throws Exception
+   {
+      final ComponentType type = new ComponentType("MBean", "Platform");
+      
+      this.mgtView.addProfileView(new PlatformMBeanView());
+      
+      assertTrue(this.mgtView.load());
+      
+      Set<ManagedComponent> components = this.mgtView.getComponentsForType(type);
+      assertTrue(components.size() > 0);
+    
+      ManagedComponent component = this.mgtView.getComponent(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, type);
+      assertNotNull(component);
+      SimpleValue loadedClassCount = (SimpleValue) component.getProperty("totalLoadedClassCount").getValue();
+      assertNotNull(loadedClassCount);
+      assertTrue(loadedClassCount.compareTo(SimpleValueSupport.wrap((long) 0)) > 0);
+      
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/SimpleViewUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/SimpleViewUnitTestCase.java	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/SimpleViewUnitTestCase.java	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.profileservice.plugins.mgt.test;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.plugins.management.view.AbstractProfileView;
+import org.jboss.test.profileservice.plugins.mgt.support.TestComponentMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class SimpleViewUnitTestCase extends AbstractViewTestBase
+{
+
+   public SimpleViewUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testSimple() throws Exception
+   {
+      AbstractProfileView view = new AbstractProfileView();
+     
+      // Create the deployment
+      ManagedDeployment md = createDeployment("test.1", createTestMetaData("one", "two", "three"));
+      // Process
+      getHelper().processRootManagedDeployment(md, view);
+      
+      assertNotNull("one", view.getComponent("one", TestComponentMetaData.componentType));
+      assertNotNull("two", view.getComponent("two", TestComponentMetaData.componentType));
+      assertNotNull("three", view.getComponent("three", TestComponentMetaData.componentType));
+   }
+
+//   public void testSimpleService() throws Exception
+//   {
+//      AbstractProfileView view = new AbstractProfileView();
+//     
+//      // Create the deployment
+//      ManagedDeployment md = createDeployment("test.1", createServiceMetaData("one", "two", "three"));
+//      // Process
+//      getHelper().processRootManagedDeployment(md, view);
+//      
+//      assertNotNull("one", view.getComponent("one", TestServiceComponentMetaData.componentType));
+//      assertNotNull("two", view.getComponent("two", TestServiceComponentMetaData.componentType));
+//      assertNotNull("three", view.getComponent("three", TestServiceComponentMetaData.componentType));      
+//   }
+
+   
+   public void testSimpleMerge() throws Exception
+   {
+      AbstractProfileView view = new AbstractProfileView();
+      
+      // Create the deployment
+      String[] names = new String[] {"one", "two", "three"};
+      
+      getHelper().processRootManagedDeployment(createDeployment("test.1", createTestMetaData(names)), view);
+      getHelper().processRootManagedDeployment(createDeployment("test.2", createServiceMetaData(names)), view);
+
+      assertNotNull("one", view.getComponent("one", TestComponentMetaData.componentType));
+      assertNotNull("two", view.getComponent("two", TestComponentMetaData.componentType));
+      assertNotNull("three", view.getComponent("three", TestComponentMetaData.componentType));
+      
+      ManagedComponent one = view.getComponent("one", TestComponentMetaData.componentType);
+      assertNotNull(one.getOperations());
+      assertTrue(one.getOperations().size() > 0);
+      
+   }
+   
+}
+

Added: projects/profileservice/trunk/plugins/src/test/resources/log4j.properties
===================================================================
--- projects/profileservice/trunk/plugins/src/test/resources/log4j.properties	                        (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/resources/log4j.properties	2010-02-12 14:24:59 UTC (rev 100913)
@@ -0,0 +1,18 @@
+### ====================================================================== ###
+##                                                                          ##
+##  JBoss Bootstrap Log4j Configuration                                     ##
+##                                                                          ##
+### ====================================================================== ###
+
+### $Id: log4j.properties 71868 2008-04-10 02:14:32Z scott.stark at jboss.org $ ###
+
+log4j.rootCategory=DEBUG, CONSOLE
+log4j.org.jboss.util=TRACE
+log4j.org.jboss.profileservice=TRACE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=TRACE
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+log4j.appender.CONSOLE.org.jboss.xb.binding.parser.sax=INFO

Modified: projects/profileservice/trunk/spi/pom.xml
===================================================================
--- projects/profileservice/trunk/spi/pom.xml	2010-02-12 12:03:55 UTC (rev 100912)
+++ projects/profileservice/trunk/spi/pom.xml	2010-02-12 14:24:59 UTC (rev 100913)
@@ -43,19 +43,23 @@
 		<dependency>
 			<groupId>org.jboss.man</groupId>
 			<artifactId>jboss-managed</artifactId>
+			<scope>provided</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.jboss.man</groupId>
 			<artifactId>jboss-metatype</artifactId>
+			<scope>provided</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.jboss</groupId>
 			<artifactId>jboss-vfs</artifactId>
+			<scope>provided</scope>
 		</dependency>
 		<!-- jboss-man depends on reflect, so we can depend on it as well -->
 		<dependency>
 			<groupId>org.jboss</groupId>
 			<artifactId>jboss-reflect</artifactId>
+			<scope>provided</scope>
 		</dependency>
 	</dependencies>
 




More information about the jboss-cvs-commits mailing list