[jboss-cvs] JBossAS SVN: r77172 - in projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar: spi and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 18 17:03:38 EDT 2008
Author: ALRubinger
Date: 2008-08-18 17:03:38 -0400 (Mon, 18 Aug 2008)
New Revision: 77172
Modified:
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/plugin/mc/Ejb3McRegistrar.java
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3Registrar.java
Log:
[EJBTHREE-1468] Add to Ejb3Registrar the ability to list all bound objects
Modified: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/plugin/mc/Ejb3McRegistrar.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/plugin/mc/Ejb3McRegistrar.java 2008-08-18 20:39:18 UTC (rev 77171)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/plugin/mc/Ejb3McRegistrar.java 2008-08-18 21:03:38 UTC (rev 77172)
@@ -21,8 +21,15 @@
*/
package org.jboss.ejb3.common.registrar.plugin.mc;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
import org.jboss.ejb3.common.registrar.spi.DuplicateBindException;
import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
@@ -70,7 +77,48 @@
// --------------------------------------------------------------------------------||
// Required Implementations -------------------------------------------------------||
// --------------------------------------------------------------------------------||
+
+ /**
+ * Lists out all installed (bound) objects in form
+ * key == name , value == object. Primarily for
+ * metrics/debugging/management. If nothing is installed,
+ * an empty Map will be returned. The returned Map is
+ * immutable.
+ *
+ * @return
+ */
+ public Map<Object, Object> list()
+ {
+ // Obtain all installed Contexts
+ Set<ControllerContext> installedContexts = this.getKernel().getController().getContextsByState(
+ ControllerState.INSTALLED);
+
+ // If nothing is installed
+ if (installedContexts == null)
+ {
+ // Return an empty Map
+ return new HashMap<Object, Object>();
+ }
+
+ // Initialize a Map
+ Map<Object, Object> installedObjects = new ConcurrentHashMap<Object, Object>();
+
+ // For each installed Context
+ for (ControllerContext context : installedContexts)
+ {
+ Object bindName = context.getName();
+ Object value = context.getTarget();
+ installedObjects.put(bindName, value == null ? "[null]" : value);
+ }
+
+ // Decorate as immutable
+ installedObjects = Collections.unmodifiableMap(installedObjects);
+
+ // Return
+ return installedObjects;
+ }
+
/**
* Obtains the value bound at the specified name,
* throwing NotBoundException if there is nothing
Modified: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3Registrar.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3Registrar.java 2008-08-18 20:39:18 UTC (rev 77171)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3Registrar.java 2008-08-18 21:03:38 UTC (rev 77172)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb3.common.registrar.spi;
+import java.util.Map;
+
/**
* Ejb3Registrar
*
@@ -34,6 +36,17 @@
public interface Ejb3Registrar
{
/**
+ * Lists out all installed (bound) objects in form
+ * key == name , value == object. Primarily for
+ * metrics/debugging/management. If nothing is installed,
+ * an empty Map will be returned. The returned Map is
+ * immutable.
+ *
+ * @return
+ */
+ Map<Object, Object> list();
+
+ /**
* Obtains the value bound at the specified name,
* throwing NotBoundException if there is nothing
* bound at the key
More information about the jboss-cvs-commits
mailing list