[jboss-cvs] JBossAS SVN: r89742 - projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 3 11:05:13 EDT 2009
Author: ALRubinger
Date: 2009-06-03 11:05:13 -0400 (Wed, 03 Jun 2009)
New Revision: 89742
Added:
projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicMessageDrivenMetrics.java
Modified:
projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java
Log:
[EJBTHREE-1839] Add MDB metrics
Added: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicMessageDrivenMetrics.java
===================================================================
--- projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicMessageDrivenMetrics.java (rev 0)
+++ projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicMessageDrivenMetrics.java 2009-06-03 15:05:13 UTC (rev 89742)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metrics.deployer;
+
+import javax.ejb.TimerService;
+
+import org.jboss.ejb3.mdb.MessagingContainer;
+import org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean;
+import org.jboss.ejb3.statistics.InvocationStatistics;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+
+/**
+ * BasicMessageDrivenMetrics
+ *
+ * Implementation of a MDB
+ * metrics collector. Additionally exposed as a
+ * management object.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at ManagementObject(isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "Message-Driven Instance Metrics", componentType = @ManagementComponent(type = "EJB3", subtype = "MDB"))
+public class BasicMessageDrivenMetrics implements MessagingDelegateWrapperMBean
+{
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Underlying Container through which we'll get the metrics
+ */
+ private MessagingContainer mdb;
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param slsb The underlying container
+ * @throws IllegalArgumentException If the underlying container is not supplied
+ */
+ public BasicMessageDrivenMetrics(final MessagingContainer mdb) throws IllegalArgumentException
+ {
+ // Precondition check
+ if (mdb == null)
+ {
+ throw new IllegalArgumentException("Underlying container was null");
+ }
+
+ // Set
+ this.setMessagingContainer(mdb);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean#getKeepAliveMillis()
+ */
+ @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+ public int getKeepAliveMillis()
+ {
+ return this.getMBean().getKeepAliveMillis();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean#getMaxMessages()
+ */
+ @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+ public int getMaxMessages()
+ {
+ return this.getMBean().getMaxMessages();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean#getMaxPoolSize()
+ */
+ @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+ public int getMaxPoolSize()
+ {
+ return this.getMBean().getMaxPoolSize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean#getMinPoolSize()
+ */
+ @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+ public int getMinPoolSize()
+ {
+ return this.getMBean().getMinPoolSize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean#isDeliveryActive()
+ */
+ @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+ public boolean isDeliveryActive()
+ {
+ return this.getMBean().isDeliveryActive();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean#startDelivery()
+ */
+ @ManagementOperation
+ public void startDelivery()
+ {
+ this.getMBean().startDelivery();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean#stopDelivery()
+ */
+ @ManagementOperation
+ public void stopDelivery()
+ {
+ this.getMBean().stopDelivery();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.ContainerDelegateWrapperMBean#getInvokeStats()
+ */
+ @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+ public InvocationStatistics getInvokeStats()
+ {
+ return this.getMBean().getInvokeStats();
+ }
+
+ /*
+ * Not a managed operation, breaks the contract of
+ * MessagingDelegateWrapperMBean. Here just to appease the compiler.
+ */
+ public TimerService getTimerService(Object key)
+ {
+ throw new UnsupportedOperationException("Not supported via Managed Object; invoke over JMX Bus");
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the underlying pool
+ */
+ private MessagingDelegateWrapperMBean getMBean()
+ {
+ return (MessagingDelegateWrapperMBean) this.getMessagingContainer().getMBean();
+ }
+
+ /**
+ * @return the slsb
+ */
+ private MessagingContainer getMessagingContainer()
+ {
+ return mdb;
+ }
+
+ /**
+ * @param slsb the slsb to set
+ */
+ private void setMessagingContainer(final MessagingContainer mdb)
+ {
+ this.mdb = mdb;
+ }
+}
Property changes on: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicMessageDrivenMetrics.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java
===================================================================
--- projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java 2009-06-03 14:44:55 UTC (rev 89741)
+++ projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java 2009-06-03 15:05:13 UTC (rev 89742)
@@ -38,6 +38,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.mdb.MessagingContainer;
import org.jboss.ejb3.metrics.spi.SessionInstanceMetrics;
import org.jboss.ejb3.session.SessionContainer;
import org.jboss.ejb3.stateful.StatefulContainer;
@@ -157,13 +158,15 @@
// For each EJB Container
for (final Container container : containers)
{
+ // Get the EJB Name
+ final String ejbName = container.getEjbName();
+
// Session Containers
if (container instanceof SessionContainer)
{
// Cast
final SessionContainer sessionContainer = (SessionContainer) container;
- final String ejbName = sessionContainer.getXml().getEjbName();
// Get the invocation stats
final InvocationStatistics stats = sessionContainer.getInvokeStats();
@@ -209,8 +212,23 @@
}
}
+ // MDB
+ else if (container instanceof MessagingContainer)
+ {
+ // Cast
+ final MessagingContainer mdb = (MessagingContainer) container;
+
+ // Make new metrics
+ final BasicMessageDrivenMetrics metrics = new BasicMessageDrivenMetrics(mdb);
+
+ // Add to beanFactories
+ final String beanName = ejbName + BEAN_NAME_METRICS_SUFFIX_INSTANCE;
+ this.attach(metrics, beanName, beanFactories);
+ log.debug("Attached metrics stats for: " + beanName);
+ }
}
- //
+
+ // Add the Kernel Attachment
du.addAttachment(NAME_OUTPUT, kernelDeployment, KernelDeployment.class);
}
More information about the jboss-cvs-commits
mailing list