[jboss-cvs] JBossAS SVN: r88570 - in branches/Branch_5_x: profileservice/src/main/org/jboss/profileservice/management and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat May 9 04:54:03 EDT 2009


Author: jason.greene at jboss.com
Date: 2009-05-09 04:54:03 -0400 (Sat, 09 May 2009)
New Revision: 88570

Added:
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
Modified:
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservic/spi/ManagedMBeanDeploymentFactory.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java
   branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml
Log:
Add dispatching support to pure mbean components
Add workaround property for setting the default ViewUse of a mbean property
Set the default of web mbean component properties to STATISTIC
Add a testcase for verifying property operation



Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservic/spi/ManagedMBeanDeploymentFactory.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservic/spi/ManagedMBeanDeploymentFactory.java	2009-05-08 23:35:03 UTC (rev 88569)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservic/spi/ManagedMBeanDeploymentFactory.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -28,6 +28,7 @@
 import javax.management.ObjectName;
 
 import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.annotation.ViewUse;
 
 /**
  * @author Scott.Stark at jboss.org
@@ -102,4 +103,5 @@
    }
    public String getFactoryName();
    public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer);
+   public String getDefaultViewUse();
 }

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	2009-05-08 23:35:03 UTC (rev 88569)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -82,7 +82,7 @@
 /**
  * A type of ManagedObject factory that generates a ManagedObject from an MBean
  * MBeanInfo.
- * 
+ *
  * @author Scott.Stark at jboss.org
  * @version $Revision:$
  */
@@ -90,8 +90,8 @@
 {
    private static Logger log = Logger.getLogger(MBeanManagedObjectFactory.class);
    /** The meta type factory */
-   private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance(); 
-   
+   private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
    public MetaTypeFactory getMetaTypeFactory()
    {
       return metaTypeFactory;
@@ -105,7 +105,7 @@
     * Builds a ManagedObject from the MBeanInfo.
     * TODO: none of the org.jboss.managed.api.annotation.* annotations are
     * taken from the MBeanInfo. The descriptor feature could be used for this.
-    * 
+    *
     * @param mbean
     * @param info
     * @param mbeanLoader
@@ -113,10 +113,19 @@
     * @return
     * @throws Exception
     */
+
    public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
          ClassLoader mbeanLoader, MetaData metaData)
       throws Exception
    {
+      return getManagedObject(mbean, info, mbeanLoader, metaData, null);
+   }
+
+   // FIXME - Hack until metadata mechanism is provided
+   public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
+         ClassLoader mbeanLoader, MetaData metaData, ViewUse[] defaultViewUse)
+      throws Exception
+   {
       boolean trace = log.isTraceEnabled();
 
       // Process the ManagementObject fields
@@ -223,7 +232,7 @@
                   mandatory = managementProperty.mandatory();
                if (mandatory)
                   fields.setField(Fields.MANDATORY, Boolean.TRUE);
-               
+
                boolean readOnly = propertyInfo.isWritable() == false;
                if (readOnly == false && managementProperty != null)
                   readOnly = managementProperty.readOnly();
@@ -239,6 +248,10 @@
                   ViewUse[] use = managementProperty.use();
                   fields.setField(Fields.VIEW_USE, use);
                }
+               else if (defaultViewUse != null)
+               {
+                  fields.setField(Fields.VIEW_USE, defaultViewUse);
+               }
                // ActivationPolicy
                ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
                if (managementProperty != null)
@@ -340,7 +353,7 @@
          operation information.
       */
       Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
-      
+
       MBeanOperationInfo[] methodInfos = info.getOperations();
       if (methodInfos != null && methodInfos.length > 0)
       {
@@ -377,6 +390,9 @@
       for (ManagedProperty property : properties)
          property.setManagedObject(result);
       result.setTransientAttachment(MBeanInfo.class.getName(), info);
+
+      // Marker for associating the correct dispatcher
+      result.setTransientAttachment(MBeanRuntimeComponentDispatcher.class.getName(), true);
       return result;
    }
 
@@ -402,11 +418,11 @@
       // TODO...
       return null;
    }
-   
+
    /**
     * Get the MetaType for info by looking for MetaMapping/MetaMappingFactory
     * annotations in addition to the info type.
-    * 
+    *
     * @param methodInfo
     * @param metaData
     * @return the MetaType for info's type
@@ -553,12 +569,12 @@
          type = void.class;
       else if(propertyType.equals("boolean"))
          type = boolean.class;
-      
+
       else
       {
          type = loader.loadClass(propertyType);
       }
       return type;
-         
+
    }
 }

Added: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java	                        (rev 0)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.management;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Arrays;
+
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.dependency.spi.ControllerState;
+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;
+
+/**
+ * MBean runtime component dispatcher.
+ *
+ * @author Jason T. Greene
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author Scott.Stark at jboss.org
+ */
+public class MBeanRuntimeComponentDispatcher extends AbstractRuntimeComponentDispatcher
+{
+   private final MBeanServer mbeanServer;
+
+   public MBeanRuntimeComponentDispatcher(MBeanServer mbeanServer)
+   {
+      this(mbeanServer, null);
+   }
+
+   public MBeanRuntimeComponentDispatcher(MBeanServer mbeanServer, MetaValueFactory valueFactory)
+   {
+      super(valueFactory);
+      if (mbeanServer == null)
+         throw new IllegalArgumentException("Null MBean Server");
+
+      this.mbeanServer = mbeanServer;
+   }
+
+   public void start()
+   {
+   }
+
+   public MetaValue get(Object componentName, String propertyName)
+   {
+      ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
+      try
+      {
+         Object value = mbeanServer.getAttribute(new ObjectName(componentName.toString()), propertyName);
+         MetaValue mvalue = null;
+         if(value != null)
+         {
+            if(prop != null)
+            {
+               MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
+               if(mapper != null)
+                  mvalue = mapper.createMetaValue(prop.getMetaType(), value);
+               else
+                  mvalue = create(value);
+            }
+            else
+            {
+               mvalue = create(value);
+            }
+         }
+         return mvalue;
+      }
+      catch (Throwable t)
+      {
+         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 + "'.");
+         }
+      }
+   }
+
+   public void set(Object componentName, String propertyName, MetaValue value)
+   {
+      try
+      {
+         ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
+         Object uvalue = null;
+         if(prop != null)
+         {
+            MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
+            if(mapper != null)
+               uvalue = mapper.unwrapMetaValue(value);
+            else
+               uvalue = unwrap(value);
+         }
+         else
+         {
+            uvalue = unwrap(value);
+         }
+
+         mbeanServer.setAttribute(new ObjectName(componentName.toString()), new Attribute(propertyName, uvalue));
+      }
+      catch (Throwable t)
+      {
+         throw new UndeclaredThrowableException(t, "Failed to set property '" + propertyName + "' on component '" + componentName + "' to value [" + value + "].");
+      }
+   }
+
+   public Object invoke(Object componentName, String methodName, MetaValue... param)
+   {
+      try
+      {
+         ManagedOperation op = AbstractRuntimeComponentDispatcher.getActiveOperation();
+         String[] sig = new String[param.length];
+         Object[] args = new Object[param.length];
+         if(op != null)
+         {
+            ManagedParameter[] params = op.getParameters();
+            if(params != null &&  params.length == param.length)
+            {
+               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 = toArguments(param);
+               sig = toSignature(param);
+            }
+         }
+         else
+         {
+            args = toArguments(param);
+            sig = toSignature(param);
+         }
+         // Invoke
+         Object value = mbeanServer.invoke(new ObjectName(componentName.toString()), methodName, args, sig);
+         MetaValue mvalue = null;
+         if (value != null)
+         {
+            // Look for a return type MetaMapper
+            MetaMapper returnTypeMapper = op.getTransientAttachment(MetaMapper.class);
+            if (returnTypeMapper != null)
+               mvalue = returnTypeMapper.createMetaValue(op.getReturnType(), value);
+            else
+               mvalue = create(value);
+         }
+         return mvalue;
+      }
+      catch (Throwable t)
+      {
+         throw new UndeclaredThrowableException(t, "Failed to invoke method '" + methodName + "' on component '" + componentName + "' with parameters " + Arrays.asList(param) + ".");
+      }
+   }
+
+   public String getState(Object name)
+   {
+      return ControllerState.INSTALLED.getStateString();
+   }
+
+   public <T extends Enum<?>> T mapControllerState(Object name, ContextStateMapper<T> mapper)
+   {
+      if(name == null)
+         throw new IllegalArgumentException("null name");
+      if(mapper == null)
+         throw new IllegalArgumentException("null mapper");
+
+
+      return mapper.map(ControllerState.INSTALLED, ControllerState.INSTALLED);
+   }
+}


Property changes on: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java	2009-05-08 23:35:03 UTC (rev 88569)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -18,7 +18,7 @@
  * 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.management;
 
 import java.io.Serializable;
@@ -44,8 +44,8 @@
 
 /**
  * A factory for generating managed operations and properties delegating
- * request to a RuntimeComponentDispatcher proxy. 
- * 
+ * request to a RuntimeComponentDispatcher proxy.
+ *
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -62,7 +62,19 @@
 
    /** The runtime component dispatcher proxy. */
    private DelegatingComponentDispatcher dispatcherProxy;
-   
+
+   private String dispatchName;
+
+   public String getDispatchName()
+   {
+      return dispatchName;
+   }
+
+   public void setDispatchName(String dispatchName)
+   {
+      this.dispatchName = dispatchName;
+   }
+
    public RuntimeComponentDispatcher getDispatcher()
    {
       return dispatcher;
@@ -71,12 +83,12 @@
    {
       this.dispatcher = dispatcher;
    }
-   
+
    public InvokerLocator getLocator()
    {
       return locator;
    }
-   
+
    public void setLocator(InvokerLocator locator)
    {
       this.locator = locator;
@@ -86,23 +98,23 @@
    {
       return dispatcherProxy;
    }
-   
+
    public void start() throws Exception
    {
       if(this.dispatcher == null)
          throw new IllegalStateException("Null dispatcher.");
       if(this.locator == null)
          throw new IllegalStateException("Null locator.");
-      
+
       this.dispatcherProxy = createDispatcherProxy();
    }
-   
+
    public synchronized void clear()
    {
       this.properties.clear();
       this.operations.clear();
    }
-   
+
    public ManagedOperation getManagedOperation(Long opID)
    {
       ManagedOperation op = this.operations.get(opID);
@@ -110,7 +122,7 @@
          throw new IllegalStateException("operation not found for id " + opID);
       return op;
    }
-   
+
    public ManagedProperty getManagedProperty(Long propID)
    {
       ManagedProperty prop = this.properties.get(propID);
@@ -122,7 +134,7 @@
    /**
     * Create a delegating managed property. This is used for ViewUse.STATISTIC properties,
     * delegating the getValue() request to the dispatcher proxy.
-    * 
+    *
     * @param delegate the original property
     * @param componentName the component name
     * @return the delegate managed property
@@ -138,7 +150,7 @@
    /**
     * Create managed operations for runtime components, where the invoke() can
     * be invoked on the client side.
-    * 
+    *
     * @param ops the managed operations
     * @param componentName the component name
     * @return a set of runtime operations
@@ -167,10 +179,10 @@
       }
       return opProxies;
    }
-   
+
    /**
     * Create a remoting DelegatingComponentDispatcher proxy.
-    * 
+    *
     * @return the proxy
     * @throws Exception
     */
@@ -181,11 +193,12 @@
       interceptors.add(SecurityClientInterceptor.singleton);
       interceptors.add(MergeMetaDataInterceptor.singleton);
       interceptors.add(InvokeRemoteInterceptor.singleton);
-      
-      String dispatchName = "ProfileService.DelegatingComponentDispatcher";
+
       Class<?>[] ifaces = {DelegatingComponentDispatcher.class};
-      
+
       DelegatingComponentDispatcher delegate = new DelegatingComponentDispatcherImpl(this, this.dispatcher);
+
+      String dispatchName = "ProfileService-" + this.dispatchName;
       Dispatcher.singleton.registerTarget(dispatchName, delegate);
       return (DelegatingComponentDispatcher) Remoting.createRemoteProxy(dispatchName,
             getClass().getClassLoader(), ifaces, locator, interceptors, "ProfileService");

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-05-08 23:35:03 UTC (rev 88569)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -99,7 +99,7 @@
 
 /**
  * The default ManagementView implementation.
- * 
+ *
  * @author Scott.Stark at jboss.org
  * @author adrian at jboss.org
  * @author ales.justin at jboss.org
@@ -113,14 +113,14 @@
    /** The logger. */
    private static Logger log = Logger.getLogger(ManagementViewImpl.class);
    private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages"; //$NON-NLS-1$
-   
+
    /** The ProfileService for loading profiles */
    private ProfileService ps;
    /** The last modified cache for loaded profiles */
    private Map<ProfileKey, Long> lastModified = new HashMap<ProfileKey, Long>();
    /** Force a reload of ManagementView. */
    private boolean forceReload;
-   
+
    /** The MainDeployer only used to get the ManagedDeployments */
    private MainDeployer mainDeployer;
    /** The attachment store to persist the component changes. */
@@ -128,14 +128,14 @@
 
    /** The deployment templates that have been registered with the MV */
    private HashMap<String, DeploymentTemplate> templates = new HashMap<String, DeploymentTemplate>();
-   
+
    /** The internationalization resource bundle */
    private ResourceBundle i18n;
    /** the Locale for the i18n messages */
    private Locale currentLocale;
    /** The formatter used for i18n messages */
    private MessageFormat formatter = new MessageFormat("");
-   
+
    /** An index of ManagedComponent by ComponentType */
    private HashMap<ComponentType, Set<ManagedComponent>> compByCompType = new HashMap<ComponentType, Set<ManagedComponent>>();
    /** id/type key to ManagedObject map */
@@ -144,23 +144,26 @@
    private Map<String, Set<ManagedProperty>> unresolvedRefs = new HashMap<String, Set<ManagedProperty>>();
    /** A map of runtime ManagedObjects needing to be merged with their matching ManagedObject. */
    private Map<String, ManagedObject> runtimeMOs = new HashMap<String, ManagedObject>();
-   
+
    /** The bootstrap deployment name to ManagedDeployment map */
-   private Map<String, ManagedDeployment> bootstrapManagedDeployments = Collections.emptyMap(); 
+   private Map<String, ManagedDeployment> bootstrapManagedDeployments = Collections.emptyMap();
    /** The deployment name to ManagedDeployment map */
-   private Map<String, ManagedDeployment> managedDeployments = new HashMap<String, ManagedDeployment>();   
+   private Map<String, ManagedDeployment> managedDeployments = new HashMap<String, ManagedDeployment>();
    /** The root deployments to resolve the deployment name. */
    private List<String> rootDeployments = new ArrayList<String>();
-   
+
    /** The state mappings. */
    private static final ContextStateMapper<RunState> runStateMapper;
    private static final ContextStateMapper<DeploymentState> deploymentStateMapper;
-   
+
    /** The dispatcher handles ManagedOperation dispatches */
    private RuntimeComponentDispatcher dispatcher;
    /** The managed operation proxy factory. */
    private ManagedOperationProxyFactory proxyFactory;
 
+   /** A proxy for pure JMX dispatch */
+   private ManagedOperationProxyFactory mbeanProxyFactory;
+
    /** . */
    private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
    /** ManagedObjectFactory used for platform mbean ManagedObjects */
@@ -168,7 +171,11 @@
    /** */
    private HashMap<String, ManagedMBeanDeploymentFactory> mdfs =
       new HashMap<String, ManagedMBeanDeploymentFactory>();
+
+   /** The JMX Kernel for non MC managed JMXobjects */
    private MBeanServer mbeanServer;
+
+   /** An MO Factory using MBeanInfo */
    private MBeanManagedObjectFactory mbeanMOFactory = new MBeanManagedObjectFactory();
 
    static
@@ -194,28 +201,28 @@
       deploymentMappings.put("Installed", DeploymentState.STARTED);
 
       deploymentStateMapper = new ContextStateMapper<DeploymentState>(deploymentMappings,
-            DeploymentState.STARTING, DeploymentState.STOPPING, DeploymentState.FAILED, DeploymentState.UNKNOWN);   
+            DeploymentState.STARTING, DeploymentState.STOPPING, DeploymentState.FAILED, DeploymentState.UNKNOWN);
    }
-   
+
    public ManagementViewImpl() throws IOException
    {
-      
+
       currentLocale = Locale.getDefault();
       formatter.setLocale(currentLocale);
       i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
    }
-   
+
    public void start() throws Exception
    {
       // nothing
    }
-   
+
    public void stop()
    {
       // Cleanup on stop
       release();
    }
-   
+
    public synchronized boolean load()
    {
       // If the profile is not modified do nothing
@@ -225,7 +232,7 @@
          return false;
       }
       this.forceReload = false;
-      
+
       // Clear any thread interrupt
       boolean wasInterrupted = Thread.interrupted();
       if(wasInterrupted)
@@ -234,12 +241,12 @@
       // Cleanup
       release();
 
-      // 
+      //
       boolean trace = log.isTraceEnabled();
-      
+
       // load the profiles
       loadProfiles(trace);
-      
+
       // Process mbean components that need to be exposed as ManagedDeployment/ManagedComponent
       for(ManagedMBeanDeploymentFactory mdf : mdfs.values())
       {
@@ -257,14 +264,14 @@
                   log.debug("Saw MBeanComponent: "+comp);
                   try
                   {
-                     ManagedObject mo = createManagedObject(comp.getName());
+                     ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse());
                      // Add a ManagementComponent annotation
                      String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject("
                         + "name=\""+comp.getName()+"\","
                         + "componentType=@org.jboss.managed.api.annotation.ManagementComponent(type=\""
-                        + comp.getType()+"\",subtype=\""+comp.getSubtype()+"\")"
+                        + comp.getType()+"\",subtype=\""+comp.getSubtype()+"\"),"
+                        + "isRuntime=true"
                         + ")";
-                     // System.err.println(annotationExpr);
                      ManagementObject moAnn = (ManagementObject) AnnotationCreator.createAnnotation(
                            annotationExpr, ManagementObject.class);
                      // Bot the ManagementObject and ManagementComponent annotation need to be in the MO annotations
@@ -282,12 +289,12 @@
             ManagedDeploymentImpl mdi = new ManagedDeploymentImpl(md.getName(), md.getName(), null, unitMOs);
             try
             {
-               processManagedDeployment(mdi, null, DeploymentState.STARTED, 0, trace); 
+               processManagedDeployment(mdi, null, DeploymentState.STARTED, 0, trace);
             }
             catch(Exception e)
             {
                log.warn("Failed to process ManagedDeployment for: " + md.getName(), e);
-            }         
+            }
          }
       }
 
@@ -296,8 +303,8 @@
       {
          try
          {
-            // 
-            processManagedDeployment(md, null, DeploymentState.STARTED, 0, trace); 
+            //
+            processManagedDeployment(md, null, DeploymentState.STARTED, 0, trace);
          }
          catch(Exception e)
          {
@@ -306,7 +313,7 @@
       }
       if(this.runtimeMOs.size() > 0)
          log.warn("Failed to merged the following runtime ManagedObjects: "+runtimeMOs);
-      
+
       // Now create a ManagedDeployment for the platform beans
       Map<String, ManagedObject> platformMBeanMOs = ManagementFactoryUtils.getPlatformMBeanMOs(managedObjFactory);
       ManagedDeploymentImpl platformMBeans = new ManagedDeploymentImpl("JDK PlatformMBeans", "PlatformMBeans", null,
@@ -330,11 +337,11 @@
       platformMBeans.getChildren().add(mmMD);
       ManagedDeploymentImpl mpoolMD = new ManagedDeploymentImpl("MemoryPoolMXBeans", "MemoryPoolMXBeans", null, mpoolMOs);
       platformMBeans.getChildren().add(mpoolMD);
-      
+
       try
       {
          // Create the ManagedComponents
-         processManagedDeployment(platformMBeans, null, DeploymentState.STARTED, 0, trace);   
+         processManagedDeployment(platformMBeans, null, DeploymentState.STARTED, 0, trace);
       }
       catch(Exception e)
       {
@@ -348,13 +355,13 @@
       }
       return true;
    }
-   
+
    public void reload()
    {
       forceReload = true;
-      load();  
+      load();
    }
-   
+
    public void release()
    {
       // Cleanup
@@ -367,9 +374,9 @@
       this.rootDeployments.clear();
       // Cleanup delegate operations
       this.proxyFactory.clear();
-      
+
    }
-   
+
    protected void loadProfiles(boolean trace)
    {
       log.debug("reloading profiles: "+ this.ps.getActiveProfileKeys());
@@ -392,7 +399,7 @@
                   {
                      ManagedDeployment md = getManagedDeployment(deployment);
                      processRootManagedDeployment(md, key, trace);
-                     
+
                      // TODO update profileservice-spi
                      // Cache the deployment types
                      if(md.getTypes() != null && md.getTypes().isEmpty() == false)
@@ -405,12 +412,12 @@
                      String deploymentName = deployment.getName();
                      ManagedDeployment md = new ManagedDeploymentImpl(deploymentName,
                            deployment.getRoot().getName());
-                     
+
                      // TODO update profileservice-spi
-                     // Try to get the cached deployment type 
+                     // Try to get the cached deployment type
                      Collection<String> deploymentTypes = (Collection<String>) ((AbstractProfileDeployment)deployment)
                            .getTransientAttachment(KnownDeploymentTypes.class.getName());
-                     
+
                      if(deploymentTypes != null)
                      {
                         md.setTypes(new HashSet<String>(deploymentTypes));
@@ -425,11 +432,11 @@
                               guessedType = guessedType.substring(0, guessedType.length() -1 );
                            md.setTypes(new HashSet<String>(1));
                            md.addType(guessedType);
-                        }  
+                        }
                      }
-                     
+
                      processManagedDeployment(md, key, DeploymentState.STOPPED, 0, trace);
-                  }  
+                  }
                }
                catch(Exception e)
                {
@@ -443,7 +450,7 @@
          }
       }
    }
-   
+
    protected boolean isReload()
    {
       if(forceReload == true)
@@ -456,7 +463,7 @@
       {
          if(this.lastModified.containsKey(key) == false)
             return true;
-         
+
          try
          {
             Profile profile = this.ps.getActiveProfile(key);
@@ -475,21 +482,21 @@
     * get populated to the child deployments as well.
     *
     * @param md the managed deployment
-    * @param profile the associated profile key 
+    * @param profile the associated profile key
     * @param trace is trace enabled
     * @throws Exception for any error
     */
    protected void processRootManagedDeployment(ManagedDeployment md, ProfileKey profile, boolean trace) throws Exception
    {
       DeploymentState state = getDeploymentState(md);
-      processManagedDeployment(md, profile, state, 0, trace);      
+      processManagedDeployment(md, profile, state, 0, trace);
    }
-   
+
    /**
     * Process managed deployment.
     *
     * @param md the managed deployment
-    * @param profile the associated profile key 
+    * @param profile the associated profile key
     * @param state the deployment state
     * @param level depth level
     * @param trace is trace enabled
@@ -503,17 +510,17 @@
       Map<String, ManagedObject> mos = md.getManagedObjects();
       if (trace)
          log.trace(name + " ManagedObjects_ " + level + ": " + mos);
-      
+
       // Set the deployment state
       if(state != null && md instanceof ManagedDeploymentImpl)
          ((ManagedDeploymentImpl)md).setDeploymentState(state);
-      
+
       for(ManagedObject mo : mos.values())
       {
          processManagedObject(mo, md);
       }
       managedDeployments.put(name, md);
-      
+
       // Associate profile with the deployment
       if(profile != null)
       {
@@ -523,7 +530,7 @@
       // Add root deployments
       if(level == 0)
          this.rootDeployments.add(name);
-      
+
       // Process children
       List<ManagedDeployment> mdChildren = md.getChildren();
       if(mdChildren != null && mdChildren.isEmpty() == false)
@@ -558,7 +565,7 @@
          boolean merged = false;
          ManagementComponent mc = managementObject.componentType();
          boolean isMC = !(mc.type().length() == 0 && mc.subtype().length() == 0);
-         
+
          // Merge this with the ManagedObject
          ManagedObject parentMO = moRegistry.get(key);
          if (parentMO == null && isMC == false)
@@ -583,7 +590,7 @@
          // There is no further processing of runtime ManagedObjects, unless its marked as a component
          if (isMC == false)
             return;
-         // 
+         //
          else if (merged == false)
          {
             Set<ManagedOperation> runtimeOps = mo.getOperations();
@@ -781,7 +788,7 @@
       }
       return state;
    }
-   
+
    protected DeploymentState getDeploymentState(ManagedDeployment md)
    {
       DeploymentState state = md.getDeploymentState();
@@ -789,7 +796,7 @@
       {
          Object name = md.getName();
          if(name != null)
-         { 
+         {
             state = getMappedState(name, deploymentStateMapper);
          }
       }
@@ -812,9 +819,9 @@
       {
          log.debug("Failed to get controller state", e);
       }
-      return state;      
+      return state;
    }
-   
+
    /**
     * Process generic value.
     *
@@ -834,7 +841,7 @@
       }
    }
 
-   
+
    public Map<String, ManagedDeployment> getBootstrapManagedDeployments()
    {
       return bootstrapManagedDeployments;
@@ -865,22 +872,22 @@
    {
       return proxyFactory;
    }
-   
+
    public void setProxyFactory(ManagedOperationProxyFactory proxyFactory)
    {
       this.proxyFactory = proxyFactory;
    }
-   
+
    public AttachmentStore getAttachmentStore()
    {
       return store;
    }
-   
+
    public void setAttachmentStore(AttachmentStore store)
    {
       this.store = store;
    }
-   
+
    public MainDeployer getMainDeployer()
    {
       return mainDeployer;
@@ -909,13 +916,13 @@
    {
       this.managedObjFactory = managedObjFactory;
    }
-   
+
    public void setDispatcher(RuntimeComponentDispatcher dispatcher)
    {
       this.dispatcher = dispatcher;
    }
 
-   
+
    public MBeanServer getMbeanServer()
    {
       return mbeanServer;
@@ -926,7 +933,7 @@
       this.mbeanServer = mbeanServer;
    }
 
-   
+
    public MBeanManagedObjectFactory getMbeanMOFactory()
    {
       return mbeanMOFactory;
@@ -948,7 +955,7 @@
    /**
     * Get the names of the deployment in the profile that have the
     * given deployment type.
-    * 
+    *
     * @param type - the deployment type
     */
    public Set<String> getDeploymentNamesForType(String type)
@@ -1029,7 +1036,7 @@
       String name = factory.getFactoryName();
       this.mdfs.remove(name);
    }
- 
+
    public void addTemplate(DeploymentTemplate template)
    {
       this.templates.put(template.getInfo().getName(), template);
@@ -1045,7 +1052,7 @@
 
    /**
     * Get the managed deployment.
-    * 
+    *
     * @param name the deployment name
     * @throws NoSuchDeploymentException if no matching deployment was found
     */
@@ -1053,7 +1060,7 @@
    {
       if(name == null)
          throw new IllegalArgumentException("Null deployment name");
-      
+
       // Resolve internally.
       ManagedDeployment md = this.managedDeployments.get(name);
       if (md == null)
@@ -1061,7 +1068,7 @@
          // Check the bootstrap deployments
          md = this.bootstrapManagedDeployments.get(name);
       }
-      
+
       // Check the file name
       if(md == null)
       {
@@ -1076,7 +1083,7 @@
                md = this.managedDeployments.get(deployment);
                break;
             }
-         }  
+         }
       }
       // Do not return null
       if (md == null)
@@ -1086,7 +1093,7 @@
    }
 
    /**
-    * 
+    *
     * @param key
     * @param type
     * @return
@@ -1106,10 +1113,10 @@
    }
 
    /**
-    * 
+    *
     * @param key
     * @param type
-    * @return 
+    * @return
     * @throws NoSuchProfileException
     */
    public Set<ManagedComponent> getComponentsForType(ComponentType type)
@@ -1120,7 +1127,7 @@
          comps = Collections.emptySet();
       return comps;
    }
-   
+
    public ManagedComponent getComponent(String name, ComponentType type)
       throws Exception
    {
@@ -1196,7 +1203,7 @@
          throw new IllegalArgumentException("Null deployment base name.");
       if(info == null)
          throw new IllegalArgumentException("Null template info.");
-      
+
       DeploymentTemplate template = templates.get(info.getName());
       if( template == null )
       {
@@ -1208,16 +1215,16 @@
 
       // Create a deployment base from the template
       if( log.isTraceEnabled() )
-         log.trace("applyTemplate, deploymentBaseName="+deploymentBaseName +", info="+info);      
-      
+         log.trace("applyTemplate, deploymentBaseName="+deploymentBaseName +", info="+info);
+
       // Create, distribute and start a deployment template
       String deploymentName = super.applyTemplate(template, deploymentBaseName, info);
-      
+
       // Process the deployment
       ManagedDeployment md = getMainDeployer().getManagedDeployment(deploymentName);
       processRootManagedDeployment(md, getDefaulProfiletKey(), log.isTraceEnabled());
    }
-   
+
    public void process() throws DeploymentException
    {
       //
@@ -1237,7 +1244,7 @@
       // Get the parent
       while( md.getParent() != null )
          md = md.getParent();
-         
+
       String name = md.getName();
       ProfileDeployment compDeployment = getProfileDeployment(name);
       if( compDeployment == null )
@@ -1251,7 +1258,7 @@
       // Apply the managed properties to the server ManagedDeployment/ManagedComponent
       ManagedDeployment compMD = managedDeployments.get(md.getName());
       log.debug("updateComponent, deploymentName="+name+": "+compMD);
-      
+
       ManagedComponent serverComp = null;
       // Find the managed component again
       if(comp.getDeployment().getParent() == null)
@@ -1268,9 +1275,9 @@
             {
                if(serverComp != null)
                   break;
-               
+
                serverComp = child.getComponent(comp.getName());
-            }            
+            }
          }
       }
       if(serverComp == null)
@@ -1327,11 +1334,11 @@
          MetaValue metaValue = (MetaValue)value;
          ctxProp.setField(Fields.META_TYPE, metaValue.getMetaType());
          ctxProp.setValue(metaValue);
-         
+
          // Dispatch any runtime component property values
          Object componentName = getComponentName(ctxProp);
          ActivationPolicy policy = ctxProp.getActivationPolicy();
-         
+
          if (componentName != null && policy.equals(ActivationPolicy.IMMEDIATE))
          {
             AbstractRuntimeComponentDispatcher.setActiveProperty(ctxProp);
@@ -1344,7 +1351,7 @@
       // Force reload
       this.forceReload = true;
    }
-   
+
    public void removeComponent(ManagedComponent comp) throws Exception
    {
       if(comp == null)
@@ -1355,7 +1362,7 @@
       // Get the parent
       while( md.getParent() != null )
          md = md.getParent();
-         
+
       String name = md.getName();
       ProfileDeployment profileDeployment = getProfileDeployment(name);
       if( profileDeployment == null )
@@ -1365,11 +1372,11 @@
          String msg = formatter.format(args);
          throw new NoSuchDeploymentException(msg);
       }
-      
+
       // Apply the managed properties to the server ManagedDeployment/ManagedComponent
       ManagedDeployment compMD = managedDeployments.get(md.getName());
       log.debug("updateComponent, deploymentName="+name+": "+compMD);
-      
+
       ManagedComponent serverComp = null;
       // Find the managed component again
       if(comp.getDeployment().getParent() == null)
@@ -1386,9 +1393,9 @@
             {
                if(serverComp != null)
                   break;
-               
+
                serverComp = child.getComponent(comp.getName());
-            }            
+            }
          }
       }
       if(serverComp == null)
@@ -1400,7 +1407,7 @@
          String msg = formatter.format(args);
          throw new IllegalArgumentException(msg);
       }
-      
+
       //
       log.debug("remove component: " + comp + ", deployment: "+ profileDeployment);
       // Remove
@@ -1436,12 +1443,12 @@
             prop.setTargetManagedObject(mo);
          }
          unresolvedRefs.remove(key);
-      }      
+      }
    }
 
    /**
     * Merge the and proxy runtime props and ops
-    * 
+    *
     * @param mo - the parent managed object to merge into. May be null if the
     * runtimeMO is a self contained managed object as is the case for runtime
     * components.
@@ -1511,7 +1518,7 @@
             if (prop.getTargetManagedObject() == null)
                prop.setTargetManagedObject(runtimeMO);
          }
-         
+
          log.debug("Properties after:"+props);
       }
       if (runtimeOps != null && runtimeOps.size() > 0)
@@ -1532,9 +1539,13 @@
    {
       if (proxyFactory == null)
          throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
-      
+
       // Create the delegate property
       Object componentName = prop.getManagedObject().getComponentName();
+
+      if (prop.getManagedObject().getTransientAttachment(MBeanRuntimeComponentDispatcher.class.getName()) != null)
+         return mbeanProxyFactory.createPropertyProxy(prop, componentName);
+
       return proxyFactory.createPropertyProxy(prop, componentName);
    }
 
@@ -1558,7 +1569,7 @@
       Object componentName = mo.getComponentName();
       return createOperationProxies(ops, componentName);
    }
-   
+
    protected Set<ManagedOperation> createOperationProxies(Set<ManagedOperation> ops, Object componentName)
       throws Exception
    {
@@ -1566,36 +1577,37 @@
       return proxyFactory.createOperationProxies(ops, componentName);
    }
 
-   private ManagedObject createManagedObject(ObjectName mbean)
+   private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse)
       throws Exception
    {
       MBeanInfo info = mbeanServer.getMBeanInfo(mbean);
       ClassLoader mbeanLoader = mbeanServer.getClassLoaderFor(mbean);
       MetaData metaData = null;
-      ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData);
+      ViewUse[] viewUse = defaultViewUse == null ? null : new ViewUse[]{ViewUse.valueOf(defaultViewUse)};
+      ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse);
       return mo;
    }
-   
+
    private ManagedDeployment getManagedDeployment(ProfileDeployment ctx) throws DeploymentException
    {
       return mainDeployer.getManagedDeployment(ctx.getName());
    }
-   
+
    private ProfileKey getProfileKeyForDeployemnt(String name) throws NoSuchDeploymentException
    {
       ManagedDeployment md = getDeployment(name);
       return md.getAttachment(ProfileKey.class);
    }
-   
+
    private Profile getProfileForDeployment(String name) throws Exception
    {
       ProfileKey key = getProfileKeyForDeployemnt(name);
       if(key == null)
          throw new NoSuchDeploymentException("No associated profile found for deployment:" + name);
-      
+
       return this.ps.getActiveProfile(key);
    }
-   
+
    private ProfileDeployment getProfileDeployment(String name) throws Exception
    {
       Profile profile = getProfileForDeployment(name);
@@ -1613,4 +1625,14 @@
          System.err.println(on);
       }
    }
+
+   public ManagedOperationProxyFactory getMbeanProxyFactory()
+   {
+      return mbeanProxyFactory;
+   }
+
+   public void setMbeanProxyFactory(ManagedOperationProxyFactory mbeanProxyFactory)
+   {
+      this.mbeanProxyFactory = mbeanProxyFactory;
+   }
 }

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-05-08 23:35:03 UTC (rev 88569)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -35,6 +35,7 @@
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.annotation.ViewUse;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.profileservic.spi.ManagedMBeanDeploymentFactory;
 import org.jboss.profileservic.spi.ManagedMBeanDeploymentFactory.MBeanDeployment;
@@ -42,7 +43,7 @@
 /**
  * A ManagedDeploymentFactory that acts as a facade on top of mbean deployments
  * given by an ObjectName pattern.
- * 
+ *
  * @author Scott.Stark at jboss.org
  * @version $Revision:$
  */
@@ -61,7 +62,9 @@
    /** A map of attribute name to ComponentType:ComponentSubType for child components of the root component */
    private Map<String, String> componetInfo;
 
-   
+   /** The default view to expose fields as */
+   private String defaultViewUse;
+
    public String getFactoryName()
    {
       return factoryName;
@@ -99,7 +102,7 @@
    {
       this.pattern = pattern;
    }
-   
+
    public Map<String, String> getComponetInfo()
    {
       return componetInfo;
@@ -118,6 +121,17 @@
       this.patternKey = patternKey;
    }
 
+   public String getDefaultViewUse()
+   {
+      return this.defaultViewUse;
+   }
+
+   public void setDefaultViewUse(String defaultViewUse)
+   {
+      this.defaultViewUse = defaultViewUse;
+   }
+
+
    public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer)
    {
       ArrayList<MBeanDeployment> tmp = new ArrayList<MBeanDeployment>();
@@ -160,7 +174,7 @@
    /**
     * Generate MBeanComponents for each name given by the attribute value. This
     * processes the attribute value as an array or collection of strings or
-    * ObjectNames referencing other mbeans that are child type of components. 
+    * ObjectNames referencing other mbeans that are child type of components.
     * @param attribute - the value containing the names of child components
     * @param type - the child component type
     * @param subtype - the child component subtype
@@ -203,7 +217,7 @@
             else
             {
                compName = new ObjectName(name.toString());
-               
+
             }
             comp = new MBeanComponent(compName, type , subtype);
             deployment.addComponent(comp);
@@ -211,4 +225,5 @@
       }
    }
 
+
 }

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java	2009-05-08 23:35:03 UTC (rev 88569)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -18,7 +18,7 @@
  * 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.management.views;
 
 import java.util.Collection;
@@ -34,6 +34,7 @@
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ViewUse;
 import org.jboss.managed.plugins.ManagedDeploymentImpl;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.profileservic.spi.ManagedMBeanDeploymentFactory;
@@ -51,24 +52,24 @@
  */
 public class MBeanProfileView extends AbstractProfileView
 {
- 
+
    /** The logger. */
    private static final Logger log = Logger.getLogger(MBeanProfileView.class);
-   
+
    /** A fake profile key. */
    private static final ProfileKey key = new ProfileKey(MBeanProfileView.class.getName());
-   
+
    /** */
    private HashMap<String, ManagedMBeanDeploymentFactory> mdfs =
       new HashMap<String, ManagedMBeanDeploymentFactory>();
    private MBeanServer mbeanServer;
    private MBeanManagedObjectFactory mbeanMOFactory = new MBeanManagedObjectFactory();
-   
+
    public MBeanProfileView(ManagedOperationProxyFactory proxyFactory)
    {
       super(proxyFactory);
    }
-   
+
    public MBeanServer getMbeanServer()
    {
       return mbeanServer;
@@ -78,7 +79,7 @@
    {
       this.mbeanServer = mbeanServer;
    }
-   
+
    public void addManagedMBeanDeployments(ManagedMBeanDeploymentFactory factory)
    {
       log.info("addManagedDeployment, "+factory);
@@ -91,13 +92,13 @@
       String name = factory.getFactoryName();
       this.mdfs.remove(name);
    }
-   
+
    @Override
    public ProfileKey getProfileKey()
    {
       return key;
    }
-   
+
    protected void load()
    {
       boolean trace = log.isTraceEnabled();
@@ -118,7 +119,7 @@
                   log.debug("Saw MBeanComponent: "+comp);
                   try
                   {
-                     ManagedObject mo = createManagedObject(comp.getName());
+                     ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse());
                      // Add a ManagementComponent annotation
                      String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject("
                         + "name=\""+comp.getName()+"\","
@@ -143,26 +144,26 @@
             ManagedDeploymentImpl mdi = new ManagedDeploymentImpl(md.getName(), md.getName(), null, unitMOs);
             try
             {
-               processManagedDeployment(mdi, DeploymentState.STARTED, 0, trace); 
+               processManagedDeployment(mdi, DeploymentState.STARTED, 0, trace);
             }
             catch(Exception e)
             {
                log.warn("Failed to process ManagedDeployment for: " + md.getName(), e);
-            }         
+            }
          }
       }
    }
-   
-   private ManagedObject createManagedObject(ObjectName mbean)
-      throws Exception
+
+   private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse) throws Exception
    {
       MBeanInfo info = mbeanServer.getMBeanInfo(mbean);
       ClassLoader mbeanLoader = mbeanServer.getClassLoaderFor(mbean);
       MetaData metaData = null;
-      ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData);
+      ViewUse[] viewUse = defaultViewUse == null ? null : new ViewUse[] { ViewUse.valueOf(defaultViewUse) };
+      ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse);
       return mo;
-   }   
-   
+   }
+
    @Override
    public boolean hasBeenModified(Profile profile)
    {

Modified: branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml	2009-05-08 23:35:03 UTC (rev 88569)
+++ branches/Branch_5_x/profileservice/src/resources/profileservice-jboss-beans.xml	2009-05-09 08:54:03 UTC (rev 88570)
@@ -77,11 +77,24 @@
        </constructor>
     </bean>
     
+    <bean name="MBeanRuntimeComponentDispatcher" class="org.jboss.profileservice.management.MBeanRuntimeComponentDispatcher">
+       <constructor>
+           <parameter name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></parameter>
+       </constructor>
+    </bean>
+
     <bean name="ManagedOperationProxyFactory" class="org.jboss.profileservice.management.ManagedOperationProxyFactory">
     	<property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
         <property name="dispatcher"><inject bean="RuntimeComponentDispatcher"/></property>
+        <property name="dispatchName">kernel-dispatcher</property>
     </bean>
     
+    <bean name="MBeanManagedOperationProxyFactory" class="org.jboss.profileservice.management.ManagedOperationProxyFactory">
+    	<property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
+        <property name="dispatcher"><inject bean="MBeanRuntimeComponentDispatcher"/></property>
+        <property name="dispatchName">mbean-dispatcher</property>
+    </bean>
+
     <!-- The default applications profile key -->
     <bean name="ApplicationsProfileKey" class="org.jboss.profileservice.spi.ProfileKey">
 		<constructor><parameter><inject bean="BootstrapProfileFactory" property="applicationsName" /></parameter></constructor>
@@ -109,6 +122,7 @@
         <property name="defaultProfileKey"><inject bean="ApplicationsProfileKey"/></property>
         <property name="dispatcher"><inject bean="RuntimeComponentDispatcher"/></property>
         <property name="proxyFactory"><inject bean="ManagedOperationProxyFactory"/></property>
+        <property name="mbeanProxyFactory"><inject bean="MBeanManagedOperationProxyFactory"/></property>
         <property name="bootstrapManagedDeployments"><inject bean="ProfileServiceBootstrap" property="bootstrapMDs"/></property>
         <!-- Accept any implementor of DeploymentTemplate -->
         <incallback method="addTemplate"/>
@@ -185,7 +199,7 @@
         <property name="compSubtype">WebApplicationManager</property>
         <property name="pattern">jboss.web:host=localhost,type=Manager,*</property>
         <property name="patternKey">path</property>
-
+        <property name="defaultViewUse">STATISTIC</property>
     </bean>
     <bean name="WebModuleManagedDeploymentFactory"
         class="org.jboss.profileservice.management.ProxyManagedDeploymentFactory">
@@ -194,6 +208,7 @@
         <property name="compSubtype">WebApplication</property>
         <property name="pattern">jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,*</property>
         <property name="patternKey">name</property>
+        <property name="defaultViewUse">STATISTIC</property>
         <property name="componetInfo">
             <map keyClass="java.lang.String" valueClass="java.lang.String">
                 <!-- Process the servlets components -->

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java	2009-05-09 08:54:03 UTC (rev 88570)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test;
+
+import java.net.URL;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * Tests JMX components exposed outside the MC
+ *
+ * @author Jason T. Greene
+ */
+public class JMXMappingUnitTestCase extends AbstractProfileServiceTest
+{
+   public JMXMappingUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testWebApplicationManager()
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "WebApplicationManager"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:host=localhost,path=/jmx-console,type=Manager".equals(comp.getName()))
+         {
+            assertEquals(16, ((SimpleValue)comp.getProperty("sessionIdLength").getValue()).getValue());
+            assertEquals("MD5", ((SimpleValue)comp.getProperty("algorithm").getValue()).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find jmx-console Manager");
+   }
+
+   public void testServlet() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "Servlet"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:J2EEApplication=none,J2EEServer=none,WebModule=//localhost/jmx-console,j2eeType=Servlet,name=HtmlAdaptor".equals(comp.getName()))
+         {
+            assertEquals("jboss.web", ((SimpleValue)comp.getProperty("engineName").getValue()).getValue());
+
+            // Statistic
+            int requests = (Integer)((SimpleValue)comp.getProperty("requestCount").getValue()).getValue();
+            new URL("http://" + getServerHost() + ":8080/jmx-console/HtmlAdaptor").openStream().close();
+            assertEquals(requests + 1, ((SimpleValue)comp.getProperty("requestCount").getValue()).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find HtmlAdapor servlet");
+   }
+
+   public void testWebApplication() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "WebApplication"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,name=//localhost/jmx-console".equals(comp.getName()))
+         {
+            assertEquals("jboss", ((SimpleValue)comp.getProperty("server").getValue()).getValue());
+            ((SimpleValue)comp.getProperty("docBase").getValue()).getValue().toString().endsWith("jmx-console.war/");
+
+            return;
+         }
+      }
+
+      fail("Could not find jmx-console Web Application");
+   }
+
+
+}
\ No newline at end of file


Property changes on: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jboss-cvs-commits mailing list