[jboss-cvs] JBossAS SVN: r94860 - branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 14 08:41:31 EDT 2009
Author: emuckenhuber
Date: 2009-10-14 08:41:31 -0400 (Wed, 14 Oct 2009)
New Revision: 94860
Modified:
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
Log:
JBPAPP-2712
Modified: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java 2009-10-14 12:24:16 UTC (rev 94859)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java 2009-10-14 12:41:31 UTC (rev 94860)
@@ -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: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java 2009-10-14 12:24:16 UTC (rev 94859)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java 2009-10-14 12:41:31 UTC (rev 94860)
@@ -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;
}
More information about the jboss-cvs-commits
mailing list