[jboss-cvs] JBossAS SVN: r87885 - in trunk: profileservice/src/main/org/jboss/profileservice/management and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 27 13:57:18 EDT 2009


Author: emuckenhuber
Date: 2009-04-27 13:57:18 -0400 (Mon, 27 Apr 2009)
New Revision: 87885

Modified:
   trunk/component-matrix/pom.xml
   trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
   trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
   trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
   trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
   trunk/system/src/main/org/jboss/system/server/ServerInfo.java
   trunk/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java
   trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
Log:
merge with r87850 and other missing changes from 5_x branch.

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/component-matrix/pom.xml	2009-04-27 17:57:18 UTC (rev 87885)
@@ -75,7 +75,7 @@
     <version.org.jboss.jpa>1.0.0-CR1</version.org.jboss.jpa>
     <version.org.jboss.logbridge>1.0.0.CR3</version.org.jboss.logbridge>
     <version.org.jboss.logmanager>1.0.0.CR3</version.org.jboss.logmanager>
-    <version.org.jboss.man>2.1.0.CR7</version.org.jboss.man>
+    <version.org.jboss.man>2.1.0.CR8</version.org.jboss.man>
     <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
     <version.org.jboss.metadata>1.0.0.CR16</version.org.jboss.metadata>
     <version.org.jboss.microcontainer>2.0.4.GA</version.org.jboss.microcontainer>

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -72,6 +72,9 @@
          throw new IllegalArgumentException("Null deployment template.");
       if(deploymentBaseName == null)
          throw new IllegalArgumentException("Null deployment name.");
+      deploymentBaseName = deploymentBaseName.trim();
+      if(deploymentBaseName.length() == 0)
+         throw new IllegalArgumentException("emtpy deployment base name");
       if(info == null)
          throw new IllegalArgumentException("Null deployment template info.");
 

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -21,10 +21,6 @@
  */
 package org.jboss.profileservice.management;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.WeakHashMap;
-
 import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
 import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
 import org.jboss.managed.api.ManagedOperation;
@@ -42,37 +38,31 @@
 public class DelegatingComponentDispatcherImpl
    implements DelegatingComponentDispatcher
 {
-   private static Map<Long, ManagedProperty> properties = new HashMap<Long, ManagedProperty>();
-   private static Map<Long, ManagedOperation> operations = new HashMap<Long, ManagedOperation>();
-   
+  
    private RuntimeComponentDispatcher dispatcher;
+   private ProxyRegistry registry;
 
-   public static void addManagedProperty(Long id, ManagedProperty mp)
+   public DelegatingComponentDispatcherImpl(ProxyRegistry registry, RuntimeComponentDispatcher dispatcher)
    {
-      properties.put(id, mp);
-   }
-   public static void addManagedOperation(Long id, ManagedOperation op)
-   {
-      operations.put(id, op);
-   }
-
-   public DelegatingComponentDispatcherImpl(RuntimeComponentDispatcher dispatcher)
-   {
+      this.registry = registry;
       this.dispatcher = dispatcher;
    }
 
    public MetaValue get(Long propID, Object componentName, String propertyName)
    {
-      ManagedProperty mp = properties.get(propID);
+      ManagedProperty mp = this.registry.getManagedProperty(propID);
       AbstractRuntimeComponentDispatcher.setActiveProperty(mp);
       return dispatcher.get(componentName, propertyName);
    }
 
    public MetaValue invoke(Long opID, Object componentName, String methodName, MetaValue... param)
    {
-      ManagedOperation op = operations.get(opID);
+      ManagedOperation op = this.registry.getManagedOperation(opID);
       AbstractRuntimeComponentDispatcher.setActiveOperation(op);
 
+      if(param == null)
+         param = new MetaValue[0];
+      
       MetaValue result = null;
       if (componentName != null)
       {
@@ -81,4 +71,12 @@
       return result; 
    }
 
+   public static interface ProxyRegistry
+   {
+    
+      ManagedProperty getManagedProperty(Long propID);
+      ManagedOperation getManagedOperation(Long opID);
+
+   }
+   
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -21,8 +21,8 @@
  */
 package org.jboss.profileservice.management;
 
+import java.lang.reflect.UndeclaredThrowableException;
 import java.util.Arrays;
-import java.lang.reflect.UndeclaredThrowableException;
 
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerState;
@@ -32,9 +32,11 @@
 import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedParameter;
 import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.EnumValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
 import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.profileservice.spi.types.ControllerStateMetaType;
 
 /**
  * Microcontainer KernelBus runtime component dispatcher.
@@ -76,9 +78,9 @@
 
    public MetaValue get(Object componentName, String propertyName)
    {
+      ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
       try
       {
-         ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
          Object value = bus.get(componentName, propertyName);
          MetaValue mvalue = null;
          if(value != null)
@@ -88,7 +90,8 @@
                MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
                if(mapper != null)
                   mvalue = mapper.createMetaValue(prop.getMetaType(), value);
-               mvalue = create(value);                  
+               else
+                  mvalue = create(value);                  
             }
             else
             {
@@ -99,7 +102,16 @@
       }
       catch (Throwable t)
       {
-         throw new UndeclaredThrowableException(t, "Failed to get property '" + propertyName + "' on component '" + componentName + "'.");
+         if(propertyName.equals("state") && prop.getMetaType().equals(ControllerStateMetaType.TYPE))
+         {
+            String stateString = getState(componentName);
+            EnumValueSupport state = new EnumValueSupport(ControllerStateMetaType.TYPE, stateString);
+            return state;
+         }
+         else
+         {
+            throw new UndeclaredThrowableException(t, "Failed to get property '" + propertyName + "' on component '" + componentName + "'.");
+         }
       }
    }
 
@@ -134,23 +146,38 @@
       try
       {
          ManagedOperation op = AbstractRuntimeComponentDispatcher.getActiveOperation();
-         ManagedParameter[] params = op.getParameters();
-         String[] sig;
+         String[] sig = new String[param.length];
          Object[] args = new Object[param.length];
-         for(int i=0; i < param.length; i++)
+         if(op != null)
          {
-            if(params != null && params.length < i)
+            ManagedParameter[] params = op.getParameters();
+            if(params != null &&  params.length == param.length)
             {
-               ManagedParameter mp = params[i];
-               MetaMapper mapper = mp.getTransientAttachment(MetaMapper.class);
-               if(mapper != null)
-                  args[i] = mapper.unwrapMetaValue(param[i]);
+               for(int i=0; i < param.length; i++)
+               {
+                  ManagedParameter mp = params[i];
+                  MetaMapper<?> mapper = mp.getTransientAttachment(MetaMapper.class);
+                  if(mapper != null)
+                     args[i] = mapper.unwrapMetaValue(param[i]);
+                  else
+                     args[i] = unwrap(param[i]);
+                  //
+                  sig[i] = mp.getMetaType().getTypeName();
+               }               
             }
             else
-               args[i] = unwrap(param[i]);
+            {
+               args = toArguments(param);
+               sig = toSignature(param);
+            }
          }
-
-         Object value = bus.invoke(componentName, methodName, toArguments(param), toSignature(param));
+         else
+         {
+            args = toArguments(param);
+            sig = toSignature(param);
+         }
+         // Invoke
+         Object value = bus.invoke(componentName, methodName, args, sig);
          MetaValue mvalue = null;
          if (value != null)
          {

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -54,6 +54,11 @@
       this.dispatcherProxy = dispatcherProxy;
    }
 
+   public long getOpID()
+   {
+      return opID;
+   }
+
    public MetaValue invoke(MetaValue... metaValues)
    {
       MetaValue mvalue = dispatcherProxy.invoke(opID, componentName, delegate.getName(), metaValues);

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -24,7 +24,9 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.jboss.aop.Dispatcher;
@@ -36,12 +38,8 @@
 import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
 import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
 import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
 import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.profileservice.management.DelegatingComponentDispatcherImpl.ProxyRegistry;
 import org.jboss.remoting.InvokerLocator;
 
 /**
@@ -51,15 +49,16 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class ManagedOperationProxyFactory implements Serializable
+public class ManagedOperationProxyFactory implements Serializable, ProxyRegistry
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = 1343224268002757169L;
    private AtomicLong operationID = new AtomicLong(0);
    private AtomicLong propertyID = new AtomicLong(0);
    private transient RuntimeComponentDispatcher dispatcher;
-   private transient MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
    private transient InvokerLocator locator;
+   private transient Map<Long, ManagedProperty> properties = new ConcurrentHashMap<Long, ManagedProperty>();
+   private transient Map<Long, ManagedOperation> operations = new ConcurrentHashMap<Long, ManagedOperation>();
 
    /** The runtime component dispatcher proxy. */
    private DelegatingComponentDispatcher dispatcherProxy;
@@ -97,6 +96,28 @@
       
       this.dispatcherProxy = createDispatcherProxy();
    }
+   
+   public synchronized void clear()
+   {
+      this.properties.clear();
+      this.operations.clear();
+   }
+   
+   public ManagedOperation getManagedOperation(Long opID)
+   {
+      ManagedOperation op = this.operations.get(opID);
+      if(op == null)
+         throw new IllegalStateException("operation not found for id " + opID);
+      return op;
+   }
+   
+   public ManagedProperty getManagedProperty(Long propID)
+   {
+      ManagedProperty prop = this.properties.get(propID);
+      if(prop == null)
+         throw new IllegalStateException("property not found for id " + propID);
+      return prop;
+   }
 
    /**
     * Create a delegating managed property. This is used for ViewUse.STATISTIC properties,
@@ -110,7 +131,7 @@
    {
       long propID = propertyID.incrementAndGet();
       ManagedPropertyDelegate proxy = new ManagedPropertyDelegate(propID, delegate, componentName, dispatcherProxy);
-      DelegatingComponentDispatcherImpl.addManagedProperty(propID, proxy);
+      this.properties.put(propID, proxy);
       return proxy;
    }
 
@@ -129,9 +150,19 @@
       HashSet<ManagedOperation> opProxies = new HashSet<ManagedOperation>();
       for (ManagedOperation op : ops)
       {
+         // If this is already oa delegage just use it
+         if(op instanceof ManagedOperationDelegate)
+         {
+            opProxies.add(op);
+            ManagedOperationDelegate proxy = (ManagedOperationDelegate) op;
+            // Make sure the proxy is in the operations map since clear() may have removed it
+            long opID = proxy.getOpID();
+            this.operations.put(opID, proxy);
+            continue;
+         }
          long opID = operationID.incrementAndGet();
          ManagedOperationDelegate proxy = new ManagedOperationDelegate(opID, op, componentName, dispatcherProxy);
-         DelegatingComponentDispatcherImpl.addManagedOperation(opID, proxy);
+         this.operations.put(opID, proxy);
          opProxies.add(proxy);
       }
       return opProxies;
@@ -154,10 +185,10 @@
       String dispatchName = "ProfileService.DelegatingComponentDispatcher";
       Class<?>[] ifaces = {DelegatingComponentDispatcher.class};
       
-      DelegatingComponentDispatcher delegate = new DelegatingComponentDispatcherImpl(this.dispatcher);
+      DelegatingComponentDispatcher delegate = new DelegatingComponentDispatcherImpl(this, this.dispatcher);
       Dispatcher.singleton.registerTarget(dispatchName, delegate);
       return (DelegatingComponentDispatcher) Remoting.createRemoteProxy(dispatchName,
             getClass().getClassLoader(), ifaces, locator, interceptors, "ProfileService");
    }
-   
+
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -96,6 +96,11 @@
       return delegate.getLegalValues();
    }
 
+   public MetaValue getDefaultValue()
+   {
+      return delegate.getDefaultValue();
+   }
+
    public ManagedObject getManagedObject()
    {
       return delegate.getManagedObject();

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -22,7 +22,6 @@
 package org.jboss.profileservice.management;
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -72,16 +71,13 @@
 import org.jboss.managed.plugins.jmx.ManagementFactoryUtils;
 import org.jboss.metatype.api.types.ArrayMetaType;
 import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.GenericMetaType;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.values.ArrayValue;
 import org.jboss.metatype.api.values.CollectionValue;
 import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.GenericValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
 import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.spi.values.MetaMapper;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
@@ -265,7 +261,7 @@
       }
       catch(Exception e)
       {
-         log.warn("Failed to process ManagedDeployments for the platform beans");
+         log.warn("Failed to process ManagedDeployments for the platform beans", e);
       }
 
       if(wasInterrupted)
@@ -292,6 +288,9 @@
       this.unresolvedRefs.clear();
       this.lastModified.clear();
       this.rootDeployments.clear();
+      // Cleanup delegate operations
+      this.proxyFactory.clear();
+      
    }
    
    protected void loadProfiles(boolean trace)
@@ -456,7 +455,7 @@
       // See if this is a runtime ManagedObject
       Map<String, Annotation> moAnns = mo.getAnnotations();
       ManagementObject managementObject = (ManagementObject) moAnns.get(ManagementObject.class.getName());
-      if (managementObject.isRuntime())
+      if (managementObject != null && managementObject.isRuntime())
       {
          boolean merged = false;
          ManagementComponent mc = managementObject.componentType();
@@ -1057,6 +1056,8 @@
    public void applyTemplate(String deploymentBaseName, DeploymentTemplateInfo info)
       throws Exception
    {
+      if(deploymentBaseName == null)
+         throw new IllegalArgumentException("Null deployment base name.");
       if(info == null)
          throw new IllegalArgumentException("Null template info.");
       
@@ -1092,6 +1093,8 @@
    public void updateComponent(ManagedComponent comp)
       throws Exception
    {
+      if(comp == null)
+         throw new IllegalArgumentException("Null managed component.");
       // Find the comp deployment
       ManagedDeployment md = comp.getDeployment();
 
@@ -1195,17 +1198,7 @@
          
          if (componentName != null && policy.equals(ActivationPolicy.IMMEDIATE))
          {
-            // FIXME
-            MetaMapper mapper = ctxProp.getTransientAttachment(MetaMapper.class);
-            if(mapper != null)
-            {
-               Object o = mapper.unwrapMetaValue(metaValue);
-               if(o instanceof Serializable)
-               {
-                  GenericMetaType generic = new GenericMetaType(metaValue.getMetaType().getTypeName(), "generic value wrapper");
-                  metaValue = new GenericValueSupport(generic, (Serializable) o);
-               }
-            }
+            AbstractRuntimeComponentDispatcher.setActiveProperty(ctxProp);
             dispatcher.set(componentName, ctxProp.getName(), metaValue);
          }
       }
@@ -1218,6 +1211,8 @@
    
    public void removeComponent(ManagedComponent comp) throws Exception
    {
+      if(comp == null)
+         throw new IllegalArgumentException("null managed component.");
       //
       ManagedDeployment md = comp.getDeployment();
 
@@ -1355,39 +1350,30 @@
          // We need to pull the runtime values for stats
          for(ManagedProperty prop : runtimeProps.values())
          {
-            Map<String, Annotation> pannotations = prop.getAnnotations();
-            if(pannotations != null)
+            if(prop.hasViewUse(ViewUse.STATISTIC))
             {
-               ManagementProperty mpa = (ManagementProperty) pannotations.get(ManagementProperty.class.getName());
-               ViewUse[] uses = mpa.use();
-               for(ViewUse use : uses)
+               String propName = prop.getMappedName();
+               try
                {
-                  if(use == ViewUse.STATISTIC)
-                  {
-                     String propName = prop.getMappedName();
-                     try
-                     {
-                        AbstractRuntimeComponentDispatcher.setActiveProperty(prop);
-                        MetaValue propValue = dispatcher.get(componentName, propName);
-                        if(propValue != null)
-                           prop.setValue(propValue);
-                     }
-                     catch(Throwable t)
-                     {
-                        log.debug("Failed to get stat value, "+componentName+":"+propName);
-                     }
-                     ManagedProperty proxiedProp = createPropertyProxy(prop);
-                     props.put(prop.getName(), proxiedProp);
-                  }
-                  else
-                  {
-                     props.put(prop.getName(), prop);
-                  }
+                  AbstractRuntimeComponentDispatcher.setActiveProperty(prop);
+                  MetaValue propValue = dispatcher.get(componentName, propName);
+                  if(propValue != null)
+                     prop.setValue(propValue);
                }
-               // Keep the property associated with the runtime MO for invocations/updates
-               if (prop.getTargetManagedObject() == null)
-                  prop.setTargetManagedObject(runtimeMO);
+               catch(Throwable t)
+               {
+                  log.debug("Failed to get stat value, "+componentName+":"+propName);
+               }
+               ManagedProperty proxiedProp = createPropertyProxy(prop);
+               props.put(prop.getName(), proxiedProp);
             }
+            else
+            {
+               props.put(prop.getName(), prop);
+            }
+            // Keep the property associated with the runtime MO for invocations/updates
+            if (prop.getTargetManagedObject() == null)
+               prop.setTargetManagedObject(runtimeMO);
          }
          
          log.debug("Properties after:"+props);

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -177,22 +177,33 @@
       Map<String, ManagedProperty> properties = info.getProperties();
       for(ManagedProperty p : properties.values())
       {
-         boolean skip = p.getValue() == null
-            || p.hasViewUse(ViewUse.CONFIGURATION) == false
+         // Get the value
+         MetaValue v = p.getValue();
+         String name = p.getName();
+         
+         // Check if we need to skip a property
+         boolean skip = p.hasViewUse(ViewUse.CONFIGURATION) == false
             || p.isReadOnly()
             || p.isRemoved();
           
+         // Don't skip clustered, which is a read
          if(skip)
+         {
+            if(name.equals("clustered"))
+               skip = false;
+         }
+
+         if(skip)
             continue;
          
-         MetaValue v = p.getValue();
+         // Skip null values
          if(v == null)
             continue;
+         
          // Skip the destinationType
          if(p == destTypeMP)
             continue;
-         
-         String name = p.getName();
+
          char c = name.charAt(0);
          if(Character.isLowerCase(c))
             name = Character.toUpperCase(c) + name.substring(1);
@@ -217,7 +228,8 @@
             else if(name.equals("SecurityConfig"))
             {
                Element e = unwrapMetaValue((MapCompositeValueSupport) v);
-               attribute = new JmsElementMetaData("SecurityConfig", e);
+               if(e != null)
+                  attribute = new JmsElementMetaData("SecurityConfig", e);
             }
          }
          if(attribute != null)
@@ -307,6 +319,10 @@
       
       MapCompositeValueSupport value = (MapCompositeValueSupport) metaValue;
       CompositeMetaType metaType = value.getMetaType();
+      // Don't create a empty set
+      if(metaType.itemSet().isEmpty())
+         return null;
+      
       // Create the dom document
       Document d = createDocument();
       // Security
@@ -316,6 +332,8 @@
       {
          // Role
          CompositeValue row = (CompositeValue) value.get(name);
+         if(row == null)
+            continue;
          Element role = d.createElement("role");
          role.setAttribute("name", name);
          

Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -45,13 +45,15 @@
  * interfaces.
  * 
  * @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
  */
 public class ProxyFactory
 {
    private static final Logger log = Logger.getLogger(ProxyFactory.class);
    private String dispatchName = "ProfileService";
    private String jndiName = "ProfileService";
+   private String mgtViewJndiName = "java:ManagementView";
+   private String deployMgrJndiName = "java:DeploymentManager";
    private InvokerLocator locator;
    private ProfileService ps;
    private ManagementView mgtView;
@@ -81,6 +83,27 @@
       this.jndiName = jndiName;
    }
 
+   
+   public String getMgtViewJndiName()
+   {
+      return mgtViewJndiName;
+   }
+
+   public void setMgtViewJndiName(String mgtViewJndiName)
+   {
+      this.mgtViewJndiName = mgtViewJndiName;
+   }
+
+   public String getDeployMgrJndiName()
+   {
+      return deployMgrJndiName;
+   }
+
+   public void setDeployMgrJndiName(String deployMgrJndiName)
+   {
+      this.deployMgrJndiName = deployMgrJndiName;
+   }
+
    public InvokerLocator getLocator()
    {
       return locator;
@@ -164,7 +187,7 @@
       psProxy = Remoting.createRemoteProxy(dispatchName, loader, ifaces, locator, proxyInterceptors, "ProfileService");
       InitialContext ctx = new InitialContext();
       Util.bind(ctx, jndiName, psProxy);
-      log.debug("Bound ProfileService proxy");
+      log.debug("Bound ProfileService proxy under: "+jndiName);
 
       // Create the ManagementView proxy
       Class[] mvIfaces = {ManagementView.class};
@@ -172,6 +195,11 @@
       Dispatcher.singleton.registerTarget(mvDispatchName, mgtView);
       mgtViewProxy = Remoting.createRemoteProxy(mvDispatchName, loader, mvIfaces, locator, proxyInterceptors, "ProfileService");
       log.debug("Created ManagementView proxy");
+      if(mgtViewJndiName != null && mgtViewJndiName.length() > 0)
+      {
+         Util.bind(ctx, mgtViewJndiName, mgtViewProxy);
+         log.debug("Bound ManagementView proxy under: "+mgtViewJndiName);
+      }
 
       // Create the DeploymentManager proxy
       Class[] dmIfaces = {DeploymentManager.class};
@@ -179,6 +207,11 @@
       Dispatcher.singleton.registerTarget(dmDispatchName, deployMgr);
       deployMgrProxy = Remoting.createRemoteProxy(dmDispatchName, loader, dmIfaces, locator, proxyInterceptors, "DeploymentManager");
       log.debug("Created DeploymentManager proxy");      
+      if(deployMgrJndiName != null && deployMgrJndiName.length() > 0)
+      {
+         Util.bind(ctx, deployMgrJndiName, deployMgrProxy);
+         log.debug("Bound DeploymentManager proxy under: "+deployMgrJndiName);
+      }
    }
 
    public void stop()
@@ -190,5 +223,15 @@
       InitialContext ctx = new InitialContext();
       Util.unbind(ctx, jndiName);
       log.debug("Unbound ProfileService proxy");
+      if(mgtViewJndiName != null && mgtViewJndiName.length() > 0)
+      {
+         Util.unbind(ctx, mgtViewJndiName);
+         log.debug("Unbound ManagementView proxy");
+      }
+      if(deployMgrJndiName != null && deployMgrJndiName.length() > 0)
+      {
+         Util.unbind(ctx, deployMgrJndiName);
+         log.debug("Unbound DeploymentManager proxy");
+      }
    }
 }

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -41,6 +41,7 @@
 import org.jboss.managed.api.MutableManagedObject;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
 import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedObjectImpl;
 import org.jboss.managed.plugins.ManagedPropertyImpl;
 import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
 import org.jboss.metadata.spi.MetaData;
@@ -119,7 +120,10 @@
             
             ManagedObject bmdfMO = mof.initManagedObject(bmdf, metaData);
             if(bmdfMO == null)
-               continue;
+            {
+               // Create a container managed object
+               bmdfMO = createFactoryManagedObject(bmdf, deploymentMO, metaData);
+            }
 
             if((bmdfMO instanceof MutableManagedObject) == false)
             {
@@ -184,6 +188,16 @@
       beanFactoriesMP.getFields().setField(Fields.VALUE, values);
    }
 
+   protected ManagedObject createFactoryManagedObject(BeanMetaDataFactory bmdf,
+         ManagedObject parent, MetaData metaData)
+   {
+      ManagedObjectImpl bmdfMO = new ManagedObjectImpl(bmdf.getClass().getName());
+      Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>();
+      bmdfMO.setParent(parent);
+      bmdfMO.setProperties(newProps);
+      return bmdfMO;
+   }
+
    /**
     * 
     * @param bmd
@@ -221,6 +235,7 @@
       DefaultFieldsImpl fields = new DefaultFieldsImpl();
       fields.setMetaType(type);
       fields.setName(name);
+      fields.setField(Fields.MAPPED_NAME, name);
       fields.setMandatory(false);
       fields.setDescription("The bean controller state");
 

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -24,6 +24,7 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -54,7 +55,7 @@
  * @see {@link #addAttachmentType(Class, String)}
  * 
  * @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
  */
 public class TypedManagedDeploymentCreator
    implements ManagedDeploymentCreator
@@ -71,13 +72,16 @@
          Map<String, ManagedObject> unitMOs,
          ManagedDeployment parent)
    {
-      if(unit.getSimpleName().startsWith("testEjb2xDeployment"))
-         log.info("Processing testEjb2xDeployment");
-
       DeploymentPhase phase = unit.getAttachment(DeploymentPhase.class);
       ManagementDeployment mdAnnotation = null;
-      for(ManagedObject mo : unitMOs.values())
+      HashMap<String, ManagedObject> validUnitMOs = new HashMap<String, ManagedObject>();
+      for(String name : unitMOs.keySet())
       {
+         // TODO: why should there be null ManagedObjects?
+         ManagedObject mo = unitMOs.get(name);
+         if(mo == null)
+            continue;
+         validUnitMOs.put(name, mo);
          Map<String, Annotation> annotations = mo.getAnnotations();
          if(annotations != null && mdAnnotation == null)
             mdAnnotation = (ManagementDeployment) annotations.get(ManagementDeployment.class.getName());
@@ -96,7 +100,7 @@
       if( phase == null )
          phase = DeploymentPhase.APPLICATION;
       
-      ManagedDeployment md = new ManagedDeploymentImpl(unit.getName(), simpleName, phase, parent, unitMOs);
+      ManagedDeployment md = new ManagedDeploymentImpl(unit.getName(), simpleName, phase, parent, validUnitMOs);
       if(types.length > 0)
       {
          for(String type : types)

Modified: trunk/system/src/main/org/jboss/system/server/ServerInfo.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/ServerInfo.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/system/src/main/org/jboss/system/server/ServerInfo.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -45,8 +45,13 @@
 import javax.management.openmbean.CompositeData;
 
 import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedOperation.Impact;
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
 import org.jboss.util.platform.Java;
 
 /**
@@ -214,51 +219,61 @@
    //                            Server Information                         //
    ///////////////////////////////////////////////////////////////////////////
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getJavaVersion()
    {
       return System.getProperty("java.version");
    }
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getJavaVendor()
    {
       return System.getProperty("java.vendor");
    }
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getJavaVMName()
    {
       return System.getProperty("java.vm.name");
    }
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getJavaVMVersion()
    {
       return System.getProperty("java.vm.version");
    }
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getJavaVMVendor()
    {
       return System.getProperty("java.vm.vendor");
    }
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getOSName()
    {
       return System.getProperty("os.name");
    }
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getOSVersion()
    {
       return System.getProperty("os.version");
    }
 
+   @ManagementProperty(use={ViewUse.RUNTIME}, readOnly=true)
    public String getOSArch()
    {
       return System.getProperty("os.arch");
    }
    
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public Long getTotalMemory()
    {
       return new Long(Runtime.getRuntime().totalMemory());
    }
    
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public Long getFreeMemory()
    {
       return new Long(Runtime.getRuntime().freeMemory());
@@ -268,6 +283,7 @@
     * Returns <tt>Runtime.getRuntime().maxMemory()<tt> on 
     * JDK 1.4 vms or -1 on previous versions.
     */
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public Long getMaxMemory()
    {
       if (Java.isCompatible(Java.VERSION_1_4)) {
@@ -292,6 +308,7 @@
     * Returns <tt>Runtime.getRuntime().availableProcessors()</tt> on 
     * JDK 1.4 vms or -1 on previous versions.
     */
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public Integer getAvailableProcessors()
    {
       if (Java.isCompatible(Java.VERSION_1_4)) {
@@ -315,6 +332,7 @@
    /**
     * Returns InetAddress.getLocalHost().getHostName();
     */
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public String getHostName()
    {
       if (hostName == null)
@@ -336,6 +354,7 @@
    /**
     * Returns InetAddress.getLocalHost().getHostAddress();
     */
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public String getHostAddress()
    {
       if (hostAddress == null)
@@ -359,6 +378,9 @@
     * 
     * @param fancy produce a text-based graph when true
     */
+   @ManagementOperation(description="Return a listing of the thread pools on jdk5+",
+         impact=Impact.ReadOnly,
+         params={@ManagementParameter(name="fancy", description="produce a text-based graph when true")})
    public String listMemoryPools(boolean fancy)
    {
       StringBuffer sbuf = new StringBuffer(4196);
@@ -420,12 +442,14 @@
       
       return sbuf.toString();      
    }
-      
+
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public Integer getActiveThreadCount()
    {
       return new Integer(getRootThreadGroup().activeCount());
    }
 
+   @ManagementProperty(use={ViewUse.STATISTIC}, readOnly=true)
    public Integer getActiveThreadGroupCount()
    {
       return new Integer(getRootThreadGroup().activeGroupCount());
@@ -434,6 +458,8 @@
    /**
     * Return a listing of the active threads and thread groups.
     */
+   @ManagementOperation(description="Return a listing of the active threads and thread groups",
+         impact=Impact.ReadOnly)
    public String listThreadDump()
    {
       ThreadGroup root = getRootThreadGroup();
@@ -464,6 +490,8 @@
    /**
     * Return a listing of the active threads and thread groups.
     */
+   @ManagementOperation(description="Return a listing of the active threads and thread groups",
+         impact=Impact.ReadOnly)
    public String listThreadCpuUtilization()
    {
       Set threads = getThreadCpuUtilization(); 

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -21,6 +21,9 @@
  */
 package org.jboss.system.server.profileservice;
 
+import org.jboss.deployers.plugins.attachments.AttachmentsImpl;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
 import org.jboss.deployers.spi.DeploymentState;
 import org.jboss.deployers.spi.management.KnownDeploymentTypes;
 import org.jboss.deployers.spi.structure.ContextInfo;
@@ -29,15 +32,15 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext;
 import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
-import org.jboss.deployers.plugins.attachments.AttachmentsImpl;
-import org.jboss.deployers.plugins.structure.ContextInfoImpl;
-import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
 import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 
 /**
+ * A DeploymentUnit for exposing the MCServer deployments
+ * 
+ * @see org.jboss.bootstrap.spi.microcontainer.MCServer#getDeployments
+ * 
  * @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
  */
 public class BootstrapDeployment extends AbstractDeploymentUnit
    implements DeploymentUnit
@@ -57,7 +60,6 @@
       predeterminedManagedObjects.addAttachment(KnownDeploymentTypes.class, KnownDeploymentTypes.MCBeans);
       predeterminedManagedObjects.addAttachment(StructureMetaData.class, structure);
       predeterminedManagedObjects.addAttachment(KernelDeployment.class, deployment);
-      predeterminedManagedObjects.addAttachment(DeploymentPhase.class, DeploymentPhase.BOOTSTRAP);
       DeploymentContext rootContext = getDeploymentContext();
       rootContext.setState(DeploymentState.DEPLOYED);
       predeterminedManagedObjects.addAttachment(DeploymentContext.class, rootContext);

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-04-27 17:54:16 UTC (rev 87884)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-04-27 17:57:18 UTC (rev 87885)
@@ -21,6 +21,7 @@
  */
 package org.jboss.system.server.profileservice;
 
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -35,6 +36,7 @@
 
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
 import org.jboss.bootstrap.spi.Bootstrap;
 import org.jboss.bootstrap.spi.Server;
 import org.jboss.bootstrap.spi.ServerConfig;
@@ -58,25 +60,32 @@
 import org.jboss.kernel.spi.registry.KernelRegistryPlugin;
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.Fields;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.api.MutableManagedObject;
 import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementConstants;
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ViewUse;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
 import org.jboss.managed.plugins.DefaultFieldsImpl;
 import org.jboss.managed.plugins.ManagedComponentImpl;
+import org.jboss.managed.plugins.ManagedObjectImpl;
 import org.jboss.managed.plugins.ManagedOperationImpl;
 import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
 import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CollectionMetaType;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.types.SimpleMetaType;
 import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.CollectionValueSupport;
 import org.jboss.metatype.api.values.EnumValue;
 import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
@@ -410,14 +419,13 @@
       Map<String, KernelDeployment> serverDeployments = null;
       if(server instanceof MCServer)
       {
+         // Build ManagedDeployments for the KernelDeployments
          MCServer mcserver = MCServer.class.cast(server);
          Kernel kernel = mcserver.getKernel();
          serverDeployments = mcserver.getDeployments();
          ManagedDeployment firstDeployment = null;
          for(KernelDeployment kd : serverDeployments.values())
          {
-            ManagedObject kdMO = mof.initManagedObject(kd, null);
-            Map<String, ManagedObject> kdMOs = Collections.singletonMap(kd.getName(), kdMO);
             BootstrapDeployment deploymentUnit = new BootstrapDeployment(kd);
             KernelDeploymentVisitor visitor = new KernelDeploymentVisitor();
             try
@@ -429,9 +437,20 @@
                log.debug("Failed to build ManagedDeployment for: "+kd, e);
                continue;
             }
-            ManagedDeployment md = mgtDeploymentCreator.build(deploymentUnit, kdMOs, null);
-            if(firstDeployment == null)
-               firstDeployment = md;
+
+            /* Create minimal deployment ManagedObject. Don't use the ManagedObjectFactory
+             * as this will create ManagedObjects for the beans via the beansFactory
+             * property. We handle the beans below.
+            */
+            Set<ManagedProperty> kdProperties = new HashSet<ManagedProperty>();
+            HashSet<ManagedOperation> ops = null;
+            ManagedObject kdMO = new ManagedObjectImpl(kd.getName(), "",
+                  KernelDeployment.class.getName(),
+                  kdProperties, ops, (Serializable) kd);
+            Map<String, ManagedObject> kdMOs = new HashMap<String, ManagedObject>();
+            kdMOs.put(kd.getName(), kdMO);
+
+            // Traverse the deployment components 
             for(DeploymentUnit compUnit : deploymentUnit.getComponents())
             {
                BeanMetaData bmd = compUnit.getAttachment(BeanMetaData.class);
@@ -445,17 +464,17 @@
                if(bmdMO instanceof MutableManagedObject)
                {
                   MutableManagedObject mmo = (MutableManagedObject) bmdMO;
-                  if(mo != null && mo.name().length() > 0)
+                  if(mo != null && mo.name().length() > 0 && mo.name().equals(ManagementConstants.GENERATED) == false)
                      mmo.setName(mo.name());
                   else
                      mmo.setName(bmd.getName());
                   mmo.setParent(kdMO);
                   // Add an alias property
                   Set<Object> bmdAliases = bmd.getAliases();
+                  Map<String, ManagedProperty> oldProps = mmo.getProperties();
+                  Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
                   if(bmdAliases != null && bmdAliases.size() > 0)
                   {
-                     Map<String, ManagedProperty> oldProps = mmo.getProperties();
-                     Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
                      ArrayMetaType aliasType = new ArrayMetaType(SimpleMetaType.STRING, false);
                      DefaultFieldsImpl fields = getFields("alias", aliasType);
                      fields.setDescription("Aliases of the bean");
@@ -469,21 +488,34 @@
                      fields.setValue(value);
                      ManagedPropertyImpl aliasesMP = new ManagedPropertyImpl(bmdMO, fields);
                      newProps.put("alias", aliasesMP);
-                     // Add a state property
-                     DefaultFieldsImpl stateFields = getFields("state", ControllerStateMetaType.TYPE);
-                     stateFields.setViewUse(new ViewUse[]{ViewUse.STATISTIC});
-                     EnumValue stateValue = getState(bmd.getName(), kernel);
-                     stateFields.setValue(stateValue);
-                     stateFields.setDescription("The bean controller state");
-                     ManagedPropertyImpl stateMP = new ManagedPropertyImpl(mmo, stateFields);
-                     newProps.put("state", stateMP);
-                     // Update the properties
-                     mmo.setProperties(newProps);
                   }
+                  // Add a state property
+                  DefaultFieldsImpl stateFields = getFields("state", ControllerStateMetaType.TYPE);
+                  stateFields.setViewUse(new ViewUse[]{ViewUse.STATISTIC});
+                  EnumValue stateValue = getState(bmd.getName(), kernel);
+                  stateFields.setValue(stateValue);
+                  stateFields.setDescription("The bean controller state");
+                  ManagedPropertyImpl stateMP = new ManagedPropertyImpl(mmo, stateFields);
+                  newProps.put("state", stateMP);
+                  // Update the properties
+                  mmo.setProperties(newProps);
                }
                log.debug("Created ManagedObject: "+bmdMO+" for bean: "+bmd.getName());
+               kdMOs.put(bmd.getName(), bmdMO);
 
+            }
+            // Create the ManagedDeployment
+            ManagedDeployment md = mgtDeploymentCreator.build(deploymentUnit, kdMOs, null);
+            if(firstDeployment == null)
+               firstDeployment = md;
+            // Create the ManagedComponents
+            for(ManagedObject bmdMO : kdMOs.values())
+            {
+               if(bmdMO.getAttachmentName().equals(KernelDeployment.class.getName()))
+                  continue;
+
                ComponentType type = KnownComponentTypes.MCBean.Any.getType();
+               Map<String, Annotation> moAnns = bmdMO.getAnnotations();
                ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
                if(mc != null)
                {
@@ -491,8 +523,9 @@
                }
                ManagedComponentImpl comp = new ManagedComponentImpl(type, md, bmdMO);
                md.addComponent(bmdMO.getName(), comp);
-               log.debug("Created ManagedComponent of type: "+type+" for bean: "+bmd.getName());
+               log.debug("Created ManagedComponent of type: "+type+" for bean: "+bmdMO.getName());               
             }
+
             if(md != null)
                bootstrapMDs.put(kd.getName(), md);
          }
@@ -547,10 +580,12 @@
       DefaultFieldsImpl fields = new DefaultFieldsImpl();
       fields.setMetaType(type);
       fields.setName(name);
+      fields.setField(Fields.MAPPED_NAME, name);
       fields.setMandatory(false);
 
       return fields;
    }
+
    /**
     * Get the state of a bean
     * 




More information about the jboss-cvs-commits mailing list