[jboss-cvs] JBossAS SVN: r97445 - trunk/profileservice/src/main/java/org/jboss/profileservice/management.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 4 05:43:47 EST 2009


Author: emuckenhuber
Date: 2009-12-04 05:43:47 -0500 (Fri, 04 Dec 2009)
New Revision: 97445

Modified:
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
Log:
[JBAS-7500] missing profileservice changes.

Modified: trunk/profileservice/src/main/java/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java	2009-12-04 10:07:50 UTC (rev 97444)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java	2009-12-04 10:43:47 UTC (rev 97445)
@@ -78,23 +78,36 @@
    {
       ManagedProperty mp = this.registry.getManagedProperty(propID);
       AbstractRuntimeComponentDispatcher.setActiveProperty(mp);
-      return dispatcher.get(componentName, propertyName);
+      try
+      {
+         return dispatcher.get(componentName, propertyName);
+      }
+      finally
+      {
+         AbstractRuntimeComponentDispatcher.setActiveProperty(null);
+      }
    }
 
    public MetaValue invoke(Long opID, Object componentName, String methodName, MetaValue... param)
    {
       ManagedOperation op = this.registry.getManagedOperation(opID);
       AbstractRuntimeComponentDispatcher.setActiveOperation(op);
-
-      if(param == null)
-         param = new MetaValue[0];
-      
-      MetaValue result = null;
-      if (componentName != null)
+      try
       {
-         result = (MetaValue) dispatcher.invoke(componentName, methodName, param);
+         if(param == null)
+            param = new MetaValue[0];
+         
+         MetaValue result = null;
+         if (componentName != null)
+         {
+            result = (MetaValue) dispatcher.invoke(componentName, methodName, param);
+         }
+         return result;
       }
-      return result; 
+      finally
+      {
+         AbstractRuntimeComponentDispatcher.setActiveOperation(null);
+      }
    }
    
    public RunState updateRunState(Object componentName)

Modified: trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagedOperationProxyFactory.java	2009-12-04 10:07:50 UTC (rev 97444)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagedOperationProxyFactory.java	2009-12-04 10:43:47 UTC (rev 97445)
@@ -26,7 +26,6 @@
 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;
@@ -45,10 +44,12 @@
 import org.jboss.profileservice.management.client.ManagedOperationDelegate;
 import org.jboss.profileservice.management.client.ManagedPropertyDelegate;
 import org.jboss.remoting.InvokerLocator;
+import org.jboss.util.collection.ConcurrentReferenceHashMap;
+import org.jboss.util.collection.ConcurrentReferenceHashMap.ReferenceType;
 
 /**
- * A factory for generating managed operations and properties delegating
- * request to a RuntimeComponentDispatcher proxy.
+ * Factory generating managed operations and properties delegating
+ * requests to a RuntimeComponentDispatcher proxy.
  *
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
@@ -61,12 +62,13 @@
    private AtomicLong propertyID = new AtomicLong(0);
    private RuntimeComponentDispatcher dispatcher;
    private InvokerLocator locator;
-   private Map<Long, ManagedProperty> properties = new ConcurrentHashMap<Long, ManagedProperty>();
-   private Map<Long, ManagedOperation> operations = new ConcurrentHashMap<Long, ManagedOperation>();
-
+   private Map<Long, ManagedProperty> properties = new ConcurrentReferenceHashMap<Long, ManagedProperty>(ReferenceType.STRONG, ReferenceType.WEAK);
+   private Map<Long, ManagedOperation> operations = new ConcurrentReferenceHashMap<Long, ManagedOperation>(ReferenceType.STRONG, ReferenceType.WEAK);
+   
    /** The runtime component dispatcher proxy. */
    private DelegatingComponentDispatcher dispatcherProxy;
 
+   /** The dispatch name. */
    private String dispatchName;
 
    public String getDispatchName()
@@ -113,12 +115,18 @@
       this.dispatcherProxy = createDispatcherProxy();
    }
 
-   public synchronized void clear()
+   public void clear()
    {
-      this.properties.clear();
-      this.operations.clear();
+      //
    }
 
+   /**
+    * Get the managed operation delegate
+    * 
+    * @param the operation id
+    * @return the operation
+    * @throws IllegalStateException if the operation is not registered
+    */
    public ManagedOperation getManagedOperation(Long opID)
    {
       ManagedOperation op = this.operations.get(opID);
@@ -127,6 +135,13 @@
       return op;
    }
 
+   /**
+    * Get the managed property delegate
+    * 
+    * @param the property id
+    * @return the property
+    * @throws IllegalStateException if the property is not registered
+    */
    public ManagedProperty getManagedProperty(Long propID)
    {
       ManagedProperty prop = this.properties.get(propID);
@@ -136,22 +151,6 @@
    }
 
    /**
-    * 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
-    */
-   public ManagedProperty createPropertyProxy(ManagedProperty delegate, Object componentName)
-   {
-      long propID = propertyID.incrementAndGet();
-      ManagedPropertyDelegate proxy = new ManagedPropertyDelegate(propID, delegate, componentName, dispatcherProxy);
-      this.properties.put(propID, proxy);
-      return proxy;
-   }
-
-   /**
     * Create a delegating managed component.
     * 
     * @param comp the managed component
@@ -159,13 +158,42 @@
     */
    public MutableManagedComponent createComponentProxy(MutableManagedComponent comp)
    {
+      // 
       if(comp.getComponentName() == null)
          return comp;
       
+      // Check if this is a delegate component already
+      if(comp instanceof ManagedComponentDelegate)
+         return comp;
+      
       return new ManagedComponentDelegate(comp.getComponentName(), comp, dispatcherProxy);
    }
    
    /**
+    * 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
+    */
+   public ManagedProperty createPropertyProxy(ManagedProperty delegate, Object componentName)
+   {
+      if(delegate instanceof ManagedPropertyDelegate)
+      {
+         // Ignore ManagedPropertyDelegate
+         return delegate;
+      }
+      else
+      {
+         long propID = propertyID.incrementAndGet();
+         ManagedPropertyDelegate proxy = new ManagedPropertyDelegate(propID, delegate, componentName, dispatcherProxy);
+         this.properties.put(propID, proxy);
+         return proxy;
+      }
+   }
+   
+   /**
     * Create managed operations for runtime components, where the invoke() can
     * be invoked on the client side.
     *
@@ -180,20 +208,19 @@
       HashSet<ManagedOperation> opProxies = new HashSet<ManagedOperation>();
       for (ManagedOperation op : ops)
       {
-         // If this is already oa delegage just use it
          if(op instanceof ManagedOperationDelegate)
          {
+            // Ignore 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);
-         this.operations.put(opID, proxy);
-         opProxies.add(proxy);
+         else
+         {
+            long opID = operationID.incrementAndGet();
+            ManagedOperationDelegate proxy = new ManagedOperationDelegate(opID, op, componentName, dispatcherProxy);
+            this.operations.put(opID, proxy);
+            opProxies.add(proxy);               
+         }
       }
       return opProxies;
    }

Modified: trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-12-04 10:07:50 UTC (rev 97444)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-12-04 10:43:47 UTC (rev 97445)
@@ -22,12 +22,17 @@
 package org.jboss.profileservice.management;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
+import javax.management.ReflectionException;
 
 import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory;
 




More information about the jboss-cvs-commits mailing list