[jboss-cvs] JBossAS SVN: r64731 - in trunk/ejb3/src: main/org/jboss/ejb3/cache and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 21 09:55:13 EDT 2007


Author: wolfc
Date: 2007-08-21 09:55:13 -0400 (Tue, 21 Aug 2007)
New Revision: 64731

Added:
   trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java
   trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java
   trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceDelegateWrapper.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapper.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapperMBean.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapper.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapperMBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java
Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
   trunk/ejb3/src/main/org/jboss/ejb3/Container.java
   trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
   trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java
   trunk/ejb3/src/main/org/jboss/ejb3/Pool.java
   trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java
   trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java
   trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
   trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
   trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
   trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
   trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java
Log:
EJBTHREE-1033: added JMX stats

Modified: trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -21,9 +21,6 @@
  */
 package org.jboss.ejb3;
 
-import org.jboss.annotation.ejb.cache.tree.CacheConfig;
-import org.jboss.aop.Advisor;
-import org.jboss.ejb3.stateful.StatefulBeanContext;
 import org.jboss.injection.Injector;
 import org.jboss.logging.Logger;
 
@@ -41,12 +38,24 @@
 
    protected Injector[] injectors;
    protected Container container;
+   protected int createCount = 0;
+   protected int removeCount = 0;
 
    public AbstractPool()
    {
 
    }
 
+   public int getCreateCount()
+   {
+      return createCount;
+   }
+   
+   public int getRemoveCount()
+   {
+      return removeCount;
+   }
+   
    public void initialize(Container container, int maxSize, long timeout)
    {
       assert container != null : "container is null";
@@ -109,6 +118,8 @@
       //TODO This needs to be reimplemented as replacement for create() on home interface
       container.invokeInit(ctx.getInstance(), initTypes, initValues);
       
+      ++createCount;
+      
       return ctx;
    }
    
@@ -126,10 +137,11 @@
       finally
       {
          ctx.remove();
+         ++removeCount;
       }
    }
 
-   public void discard(BeanContext ctx)
+   public void discard(BeanContext<?> ctx)
    {
       remove(ctx);
    }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Container.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Container.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Container.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -50,6 +50,8 @@
     */
    BeanContext<?> createBeanContext();
    
+   Object getMBean();
+   
    Class getBeanClass();
 
    String getEjbName();

Added: trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3;
+
+import javax.ejb.TimerService;
+
+import org.jboss.ejb3.statistics.InvocationStatistics;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ContainerDelegateWrapper<CONTAINER_TYPE extends Container> implements ContainerDelegateWrapperMBean
+{
+   protected CONTAINER_TYPE delegate;
+
+   protected ContainerDelegateWrapper(CONTAINER_TYPE delegate)
+   {
+      assert delegate != null : "delegate is null";
+      
+      this.delegate = delegate;
+   }
+   
+   // FIXME: this is here for EJBTHREE-630, re-establishing timers
+   public TimerService getTimerService(Object pKey)
+   {
+      return delegate.getTimerService(pKey);
+   }
+   
+   public InvocationStatistics getInvokeStats()
+   {
+      return delegate.getInvokeStats();
+   }
+}


Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3;
+
+import javax.ejb.TimerService;
+
+import org.jboss.ejb3.statistics.InvocationStatistics;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface ContainerDelegateWrapperMBean
+{
+   InvocationStatistics getInvokeStats();
+   
+   // FIXME: this is here for EJBTHREE-630, re-establishing timers
+   TimerService getTimerService(Object pKey);
+}


Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -321,6 +321,7 @@
       ObjectName on = container.getObjectName();
       String name = on.getCanonicalName();
       kernelAbstraction.install(name, container.getDependencyPolicy(), container);
+      mbeanServer.registerMBean(container.getMBean(), on);
       log.debug("Bound ejb3 container " + name);
    }
 
@@ -605,11 +606,11 @@
 
    public void stop() throws Exception
    {
-      for (Object o : ejbContainers.keySet())
+      for (ObjectName on : ejbContainers.keySet())
       {
          try
          {
-            ObjectName on = (ObjectName)o;
+            mbeanServer.unregisterMBean(on);
             kernelAbstraction.uninstall(on.getCanonicalName());
          }
          catch (Exception e)

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -33,6 +33,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
+ at Deprecated
 public class Ejb3Module extends ServiceMBeanSupport implements Ejb3ModuleMBean
 {
    public final static String BASE_EJB3_JMX_NAME = "jboss.j2ee:service=EJB3";

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Pool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Pool.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Pool.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -61,8 +61,18 @@
 
    void initialize(Container container, int maxSize, long timeout);
 
+   int getCurrentSize();
+   
+   int getAvailableCount();
+   
+   int getMaxSize();
+   
    void setMaxSize(int maxSize);
    
+   int getCreateCount();
+   
+   int getRemoveCount();
+  
    /**
     * Destroy the pool.
     */

Modified: trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -35,7 +35,9 @@
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
+ * @deprecated service mbeans are no longer in use
  */
+ at Deprecated
 public class ServiceDelegateWrapper extends ServiceMBeanSupport implements ServiceDelegateWrapperMBean
 {
    private Object delegate;

Modified: trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -31,7 +31,9 @@
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
+ * @deprecated service mbeans are no longer used
  */
+ at Deprecated
 public interface ServiceDelegateWrapperMBean extends ServiceMBean
 {
    // FIXME: this is here to re-establish timers (EJBTHREE-630), do not use for other purposes

Modified: trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -44,6 +44,7 @@
     * instance will block until an instance is freed.
     */
    private FIFOSemaphore strictMaxSize;
+   private int inUse = 0;
    /**
     * The time in milliseconds to wait for the strictMaxSize semaphore.
     */
@@ -78,6 +79,21 @@
       this.strictTimeout = timeout;
    }
    
+   public int getCurrentSize()
+   {
+	   return pool.size();
+   }
+   
+   public int getAvailableCount()
+   {
+	   return maxSize - inUse;
+   }
+   
+   public int getMaxSize()
+   {
+	   return maxSize;
+   }
+   
    public void setMaxSize(int maxSize)
    {
       this.maxSize = maxSize;
@@ -119,11 +135,14 @@
       {
          if (!pool.isEmpty())
          {
-            return pool.removeFirst();
+            BeanContext bean = (BeanContext) pool.removeFirst();
+            ++inUse;
+            return bean;
          }
       }
 
       // Pool is empty, create an instance
+      ++inUse;
       return create(initTypes, initValues);
    }
 
@@ -163,6 +182,7 @@
          if (removeIt) remove(ctx);
          // If we block when maxSize instances are in use, invoke release on strictMaxSize
          strictMaxSize.release();
+         --inUse;
       }
       catch (Exception ignored)
       {
@@ -185,6 +205,7 @@
 
       // If we block when maxSize instances are in use, invoke release on strictMaxSize
       strictMaxSize.release();
+      --inUse;
 
       // Throw away, unsetContext()
       super.discard(ctx);
@@ -216,6 +237,7 @@
          discard(bc);
       }
       pool.clear();
+      inUse = 0;
    }
 
    // Inner classes -------------------------------------------------

Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -27,7 +27,6 @@
 import org.jboss.ejb3.Container;
 import org.jboss.ejb3.Pool;
 import org.jboss.ejb3.stateful.StatefulBeanContext;
-import org.jboss.util.id.GUID;
 
 /**
  * Comment
@@ -39,6 +38,8 @@
 {
    private Pool pool;
    private HashMap<Object, StatefulBeanContext> cacheMap;
+   private int createCount = 0;
+   private int removeCount = 0;
 
    public void initialize(Container container) throws Exception
    {
@@ -73,6 +74,7 @@
       try
       {
          ctx = (StatefulBeanContext) pool.get(initTypes, initValues);
+         ++createCount;
          synchronized (cacheMap)
          {
             cacheMap.put(ctx.getId(), ctx);
@@ -138,8 +140,50 @@
       {
          ctx = (StatefulBeanContext) cacheMap.remove(key);
       }
-      if (ctx != null) pool.remove(ctx);
+      if (ctx != null)
+      {
+         pool.remove(ctx);
+         ++removeCount;
+      }
    }
 
-
+   public int getCacheSize()
+   {
+	   return cacheMap.size();
+   }
+   
+   public int getTotalSize()
+   {
+      return cacheMap.size();
+   }
+   
+   public int getCreateCount()
+   {
+	   return createCount;
+   }
+   
+   public int getPassivatedCount()
+   {
+	   return 0;
+   }
+   
+   public int getRemoveCount()
+   {
+      return removeCount;
+   }
+   
+   public int getAvailableCount()
+   {
+      return -1;
+   }
+   
+   public int getMaxSize()
+   {
+      return -1;
+   }
+   
+   public int getCurrentSize()
+   {
+      return cacheMap.size();
+   }
 }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -75,6 +75,22 @@
     */
    public StatefulBeanContext get(Object key, boolean markInUse) throws EJBException;
 
+   int getAvailableCount();
+   
+   int getCacheSize();
+   
+   int getCreateCount();
+   
+   int getCurrentSize();
+   
+   int getMaxSize();
+   
+   int getPassivatedCount();
+   
+   int getRemoveCount();
+   
+   int getTotalSize();
+   
    public void remove(Object key);
 
    public void finished(StatefulBeanContext ctx);

Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -56,7 +56,9 @@
    private SessionTimeoutTask timeoutTask;
    private RemovalTimeoutTask removalTask = null;
    private boolean running = true;
-   private Container container;
+   private int createCount = 0;
+   private int passivatedCount = 0;
+   private int removeCount = 0;
 
    private class CacheMap extends LinkedHashMap
    {
@@ -237,7 +239,6 @@
    public void initialize(Container container) throws Exception
    {
       Advisor advisor = (Advisor) container;
-      this.container = container;
       this.pool = container.getPool();
       cacheMap = new CacheMap();
       PersistenceManager pmConfig = (PersistenceManager) advisor.resolveAnnotation(PersistenceManager.class);
@@ -296,6 +297,7 @@
       {
          Thread.currentThread().setContextClassLoader(((EJBContainer) ctx.getContainer()).getClassloader());
          pm.passivateSession(ctx);
+         ++passivatedCount;
       }
       finally
       {
@@ -320,6 +322,7 @@
          }
          ctx.setInUse(true);
          ctx.lastUsed = System.currentTimeMillis();
+         ++createCount;
       }
       catch (EJBException e)
       {
@@ -350,6 +353,7 @@
          }
          ctx.setInUse(true);
          ctx.lastUsed = System.currentTimeMillis();
+         ++createCount;
       }
       catch (EJBException e)
       {
@@ -383,6 +387,7 @@
          {
             throw new NoSuchEJBException("Could not find stateful bean: " + key);
          }
+         --passivatedCount;
          
          // We cache the entry even if we will throw an exception below
          // as we may still need it for its children and XPC references
@@ -438,6 +443,8 @@
          if (!ctx.isRemoved())
             pool.remove(ctx);
          
+         ++removeCount;
+         
          if (ctx.getCanRemoveFromCache())
          {
             synchronized (cacheMap)
@@ -448,5 +455,43 @@
       }
    }
 
+   public int getCacheSize()
+   {
+      return cacheMap.size();
+   }
 
+   public int getTotalSize()
+   {
+      return getCacheSize() + getPassivatedCount();
+   }
+   
+   public int getCreateCount()
+   {
+      return createCount;
+   }
+   
+   public int getPassivatedCount()
+   {
+      return passivatedCount;
+   }
+   
+   public int getRemoveCount()
+   {
+      return removeCount;
+   }
+   
+   public int getAvailableCount()
+   {
+      return -1;
+   }
+   
+   public int getMaxSize()
+   {
+      return maxSize;
+   }
+   
+   public int getCurrentSize()
+   {
+      return cacheMap.size();
+   }
 }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -101,7 +101,9 @@
    public static long MarkInUseWaitTime = 15000;
    
    protected String[] hashBuckets = DEFAULT_HASH_BUCKETS;
-   
+   protected int createCount = 0;
+   protected int passivatedCount = 0;
+   protected int removeCount = 0;
    protected long removalTimeout = 0; 
    protected RemovalTimeoutTask removalTask = null;
    protected boolean running = true;
@@ -121,6 +123,7 @@
          putInCache(ctx);
          ctx.setInUse(true);
          ctx.lastUsed = System.currentTimeMillis();
+         ++createCount;
          beans.put(ctx.getId(), ctx.lastUsed);
       }
       catch (EJBException e)
@@ -147,6 +150,7 @@
          putInCache(ctx);
          ctx.setInUse(true);
          ctx.lastUsed = System.currentTimeMillis();
+         ++createCount;
          beans.put(ctx.getId(), ctx.lastUsed);
       }
       catch (EJBException e)
@@ -394,6 +398,65 @@
       log.debug("stop(): StatefulTreeCache stopped successfully for " +cacheNode);
    }
    
+   public int getCacheSize()
+   {
+      return -1;
+      /* FIXME: make this work
+      int count = 0;
+      try
+      {
+         Set children = null;
+         for (int i = 0; i < hashBuckets.length; i++)
+         {
+            children = cache.getChildrenNames(new Fqn(cacheNode, hashBuckets[i]));
+            count += (children == null ? 0 : children.size());
+         }
+         count = count - passivatedCount;
+      }
+      catch (CacheException e)
+      {
+         log.error("Caught exception calculating cache size", e);
+         count = -1;
+      }
+      return count;
+      */
+   }
+
+   public int getTotalSize()
+   {
+      return beans.size();
+   }
+   
+   public int getCreateCount()
+   {
+	   return createCount;
+   }
+   
+   public int getPassivatedCount()
+   {
+	   return passivatedCount;
+   }
+   
+   public int getRemoveCount()
+   {
+      return removeCount;
+   }
+   
+   public int getAvailableCount()
+   {
+      return -1;
+   }
+   
+   public int getMaxSize()
+   {
+      return -1;
+   }
+   
+   public int getCurrentSize()
+   {
+      return getCacheSize();
+   }
+   
    private void putInCache(StatefulBeanContext ctx)
    {
       Boolean active = localActivity.get();
@@ -465,8 +528,7 @@
          if (Boolean.TRUE != localActivity.get()) 
          {
             // But we do want to record that the bean's now in memory
-            // FIXEME Bill D -- uncomment this when you port stats from 4.2
-            //--passivatedCount;
+            --passivatedCount;
             return; 
          }
          
@@ -477,6 +539,8 @@
             throw new IllegalStateException("nodeLoaded(): null bean instance.");
          }
 
+         --passivatedCount;
+
          if(log.isTraceEnabled())
          {
             log.trace("nodeLoaded(): send postActivate event to bean at fqn: " +fqn);
@@ -537,6 +601,7 @@
                }
                
                bean.passivateAfterReplication();
+                  ++passivatedCount;
             }
          }
          catch (NoSuchEJBException e)

Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -21,34 +21,42 @@
  */
 package org.jboss.ejb3.mdb;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.EJBException;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
 import org.jboss.annotation.ejb.ResourceAdapter;
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.MethodInfo;
-import org.jboss.aop.advice.Interceptor;
 import org.jboss.deployment.DeploymentException;
-import org.jboss.ejb3.*;
-import org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.Ejb3Module;
+import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
 import org.jboss.ejb3.jms.JMSDestinationFactory;
+import org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
 import org.jboss.jms.jndi.JMSProviderAdapter;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ActivationConfigPropertyMetaData;
 
-import javax.ejb.*;
-import javax.ejb.Timer;
-import javax.jms.*;
-import javax.jms.Queue;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.*;
-
 /**
  * @version <tt>$Revision$</tt>
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
@@ -60,6 +68,7 @@
    protected TimerService timerService;
    protected ActivationSpec activationSpec = new ActivationSpec();
    protected JBossMessageEndpointFactory messageEndpointFactory;
+   private MessagingDelegateWrapper mbean = new MessagingDelegateWrapper(this);
 
    /**
     * Default destination type. Used when no message-driven-destination is given
@@ -83,6 +92,11 @@
       return new MDBContext(this, construct());
    }
    
+   public Object getMBean()
+   {
+      return mbean;
+   }
+   
    public abstract Class getMessagingType();
    
    public abstract Map getActivationConfigProperties();

Added: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3.mdb;
+
+import org.jboss.ejb3.ContainerDelegateWrapper;
+
+/**
+ * TODO: implement proper mdb stats
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MessagingDelegateWrapper extends ContainerDelegateWrapper<MessagingContainer>
+{
+   protected MessagingDelegateWrapper(MessagingContainer delegate)
+   {
+      super(delegate);
+   }
+
+   public int getMinPoolSize()
+   {
+      return -1;
+   }
+
+   public int getMaxPoolSize()
+   {
+      return -1;
+   }
+
+   public int getMaxMessages()
+   {
+      return -1;
+   }
+
+   public int getKeepAliveMillis()
+   {
+      return -1;
+   }
+}


Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -37,6 +37,7 @@
 import org.jboss.ejb.AllowedOperationsAssociation;
 import org.jboss.ejb.AllowedOperationsFlags;
 import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.ContainerDelegateWrapper;
 import org.jboss.ejb3.EJBContainerInvocation;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.ProxyFactory;
@@ -81,6 +82,7 @@
    MBeanServer mbeanServer;
    ObjectName delegateObjectName;
    private TimerService timerService;
+   private Object mbean = new ServiceDelegateWrapper(this);
 
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(ServiceContainer.class);
@@ -141,6 +143,11 @@
       throw new RuntimeException("NYI");
    }
 
+   public Object getMBean()
+   {
+      return mbean;
+   }
+   
    public Object getSingleton()
    {
       return singleton;

Added: trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceDelegateWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceDelegateWrapper.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceDelegateWrapper.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3.service;
+
+import org.jboss.ejb3.ContainerDelegateWrapper;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ServiceDelegateWrapper extends ContainerDelegateWrapper<ServiceContainer>
+{
+   protected ServiceDelegateWrapper(ServiceContainer delegate)
+   {
+      super(delegate);
+   }
+}


Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceDelegateWrapper.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -76,6 +76,7 @@
    private static final Logger log = Logger.getLogger(StatefulContainer.class);
 
    protected StatefulCache cache;
+   private StatefulDelegateWrapper mbean = new StatefulDelegateWrapper(this);
 
    public StatefulContainer(ClassLoader cl, String beanClassName, String ejbName, AspectManager manager,
                             Hashtable ctxProperties, InterceptorInfoRepository interceptorRepository,
@@ -110,6 +111,11 @@
       }
    }
    
+   public Object getMBean()
+   {
+      return mbean;
+   }
+   
    public void start() throws Exception
    {
       try

Copied: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapper.java (from rev 64727, branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapper.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapper.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapper.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.stateful;
+
+import org.jboss.ejb3.ContainerDelegateWrapper;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class StatefulDelegateWrapper extends ContainerDelegateWrapper<StatefulContainer> implements StatefulDelegateWrapperMBean
+{
+   protected StatefulDelegateWrapper(StatefulContainer delegate)
+   {
+	   super(delegate);
+   }
+   
+   public int getCacheSize()
+   {
+	   return delegate.getCache().getCacheSize();
+   }
+   
+   public int getTotalSize()
+   {
+      return delegate.getCache().getTotalSize();
+   }
+   
+   public int getPassivatedCount()
+   {
+	   return delegate.getCache().getPassivatedCount();
+   }
+   
+   public int getCreateCount()
+   {
+	   return delegate.getCache().getCreateCount();
+   }
+   
+   public int getRemoveCount()
+   {
+      return delegate.getCache().getRemoveCount();
+   }
+   
+   public int getAvailableCount()
+   {
+      return delegate.getCache().getAvailableCount();
+   }
+   
+   public int getMaxSize()
+   {
+      return delegate.getCache().getMaxSize();
+   }
+   
+   public int getCurrentSize()
+   {
+      return delegate.getCache().getCurrentSize();
+   }
+   
+}

Copied: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapperMBean.java (from rev 64727, branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapperMBean.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapperMBean.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulDelegateWrapperMBean.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.stateful;
+
+import org.jboss.ejb3.ContainerDelegateWrapperMBean;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulDelegateWrapperMBean extends ContainerDelegateWrapperMBean
+{
+   int getCacheSize();
+
+   int getPassivatedCount();
+
+   int getCreateCount();
+
+   int getRemoveCount();
+
+   int getAvailableCount();
+
+   int getMaxSize();
+
+   int getCurrentSize();
+
+   int getTotalSize();
+}

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -72,6 +72,7 @@
    private static final Logger log = Logger.getLogger(StatelessContainer.class);
 
    protected TimerService timerService;
+   private StatelessDelegateWrapper mbean = new StatelessDelegateWrapper(this);
 
    public StatelessContainer(ClassLoader cl, String beanClassName, String ejbName, AspectManager manager,
                              Hashtable ctxProperties, InterceptorInfoRepository interceptorRepository,
@@ -111,6 +112,11 @@
       return null;
    }
    
+   public Object getMBean()
+   {
+      return mbean;
+   }
+   
    public void start() throws Exception
    {
       try

Copied: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapper.java (from rev 64727, branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapper.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapper.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapper.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.stateless;
+
+import org.jboss.ejb3.ContainerDelegateWrapper;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class StatelessDelegateWrapper extends ContainerDelegateWrapper<StatelessContainer> implements StatelessDelegateWrapperMBean
+{
+   protected StatelessDelegateWrapper(StatelessContainer delegate)
+   {
+      super(delegate);
+   }
+
+   public int getAvailableCount()
+   {
+      return delegate.getPool().getAvailableCount();
+   }
+
+   public int getMaxSize()
+   {
+      return delegate.getPool().getMaxSize();
+   }
+
+   public int getCurrentSize()
+   {
+      return delegate.getPool().getCurrentSize();
+   }
+
+   public int getCreateCount()
+   {
+      return delegate.getPool().getCreateCount();
+   }
+
+   public int getRemoveCount()
+   {
+      return delegate.getPool().getRemoveCount();
+   }
+}

Copied: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapperMBean.java (from rev 64727, branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapperMBean.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapperMBean.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessDelegateWrapperMBean.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.stateless;
+
+import org.jboss.ejb3.ContainerDelegateWrapperMBean;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessDelegateWrapperMBean extends ContainerDelegateWrapperMBean
+{
+   int getAvailableCount();
+
+   int getMaxSize();
+
+   int getCurrentSize();
+
+   int getCreateCount();
+
+   int getRemoveCount();
+}

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -36,6 +36,7 @@
    boolean testSessionContext();
    
    public boolean wasPassivated();
+   public void clearPassivated();
    public String getInterceptorState();
    public void setInterceptorState(String param);
    

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -197,6 +197,11 @@
       return wasPassivated;
    }
 
+   public void clearPassivated()
+   {
+      wasPassivated = false;
+   }
+   
    @Init
    public void ejbCreate(Integer state)
    {

Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java (from rev 64727, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.stateful.unit;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.jboss.ejb3.test.stateful.Stateful;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+import org.jboss.security.SimplePrincipal;
+import org.jboss.security.SecurityAssociation;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MetricsUnitTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
+
+   public MetricsUnitTestCase(String name)
+   {
+
+      super(name);
+
+   }
+   
+   public void testJmxMetrics() throws Exception
+   {
+	   SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
+	   SecurityAssociation.setCredential("password".toCharArray());
+	      
+	   MBeanServerConnection server = getServer();
+	      
+	   testJmxMetrics(server, "Stateful", "jboss.j2ee:jar=stateful-test.jar,name=StatefulBean,service=EJB3");
+	   testJmxMetrics(server, "TreeCacheStateful", "jboss.j2ee:jar=stateful-test.jar,name=TreeCacheStatefulBean,service=EJB3");
+   }
+   
+   protected void testJmxMetrics(MBeanServerConnection server, String jndiBinding, String objectName) throws Exception
+   {
+      ObjectName testerName = new ObjectName(objectName);
+      
+      System.out.println("testPassivation");
+      Stateful stateful = (Stateful)getInitialContext().lookup(jndiBinding);
+      assertNotNull(stateful);
+      stateful.setState("state");
+      
+      int count = (Integer)server.getAttribute(testerName, "CreateCount");
+      assertEquals(1, count);
+      
+      int size = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(1, size);
+      
+      assertEquals("state", stateful.getState());
+      stateful.testSerializedState("state");
+      stateful.clearPassivated();
+      assertEquals(null, stateful.getInterceptorState());
+      stateful.setInterceptorState("hello world");
+      assertFalse(stateful.testSessionContext());
+      Thread.sleep(10 * 1000);
+      
+      size = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(0, size);
+      
+      count = (Integer)server.getAttribute(testerName, "PassivatedCount");
+      assertEquals(1, count);
+      assertTrue(stateful.wasPassivated());
+      
+      assertEquals("state", stateful.getState());
+      assertEquals("hello world", stateful.getInterceptorState());
+
+      Stateful another = (Stateful)getInitialContext().lookup(jndiBinding);
+      assertEquals(null, another.getInterceptorState());
+      another.setInterceptorState("foo");
+      assertEquals("foo", another.getInterceptorState());
+      assertEquals("hello world", stateful.getInterceptorState());
+      
+      assertFalse(stateful.testSessionContext());
+      
+      // Wolf: transient re-injection is broken (EJBTHREE-883)
+      //stateful.testResources();
+      
+      count = (Integer)server.getAttribute(testerName, "CreateCount");
+      assertEquals(2, count);
+      
+      size = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(2, size);
+      
+      size = (Integer)server.getAttribute(testerName, "RemoveCount");
+      assertEquals(0, size);
+      
+      another.removeBean();
+      size = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(1, size);
+      
+      size = (Integer)server.getAttribute(testerName, "RemoveCount");
+      assertEquals(1, size);
+      
+      stateful.removeBean();
+      size = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(0, size);
+      
+      size = (Integer)server.getAttribute(testerName, "RemoveCount");
+      assertEquals(2, size);
+      
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MetricsUnitTestCase.class, "stateful-test.jar");
+   }
+
+}

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java	2007-08-21 12:25:20 UTC (rev 64730)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java	2007-08-21 13:55:13 UTC (rev 64731)
@@ -38,12 +38,12 @@
       throw new RuntimeException("Bogus");
    }
 
-   public BeanContext get()
+   public BeanContext<?> get()
    {
       throw new RuntimeException("Bogus");
    }
 
-   public BeanContext get(Class[] initTypes, Object[] initValues)
+   public BeanContext<?> get(Class[] initTypes, Object[] initValues)
    {
       throw new RuntimeException("Bogus");
    }
@@ -68,4 +68,29 @@
    {
       throw new RuntimeException("Bogus");
    }
+
+   public int getAvailableCount()
+   {
+      throw new RuntimeException("Bogus");
+   }
+
+   public int getCreateCount()
+   {
+      throw new RuntimeException("Bogus");
+   }
+
+   public int getCurrentSize()
+   {
+      throw new RuntimeException("Bogus");
+   }
+
+   public int getMaxSize()
+   {
+      throw new RuntimeException("Bogus");
+   }
+
+   public int getRemoveCount()
+   {
+      throw new RuntimeException("Bogus");
+   }
 }




More information about the jboss-cvs-commits mailing list