KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > management > j2ee > MessageDrivenBean


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.management.j2ee;
23
24 import org.jboss.logging.Logger;
25 import org.jboss.management.j2ee.statistics.CountStatisticImpl;
26 import org.jboss.management.j2ee.statistics.MessageDrivenBeanStatsImpl;
27
28 import javax.management.MalformedObjectNameException JavaDoc;
29 import javax.management.ObjectName JavaDoc;
30 import javax.management.j2ee.statistics.Stats JavaDoc;
31
32 /**
33  * The JBoss JSR-77.3.11 implementation of the MessageDrivenBean model
34  *
35  * @author <a HREF="mailto:andreas@jboss.org">Andreas Schaefer</a>
36  * @author <a HREF="mailto:thomas.diesler@jboss.org">Thomas Diesler</a>
37  * @version $Revision: 40550 $
38  */

39 public class MessageDrivenBean extends EJB
40    implements MessageDrivenBeanMBean
41 {
42
43    // Attributes ----------------------------------------------------
44
private static Logger log = Logger.getLogger(MessageDrivenBean.class);
45
46    private MessageDrivenBeanStatsImpl stats;
47
48    // Static --------------------------------------------------------
49

50    // Constructors --------------------------------------------------
51

52    public MessageDrivenBean(String JavaDoc name, ObjectName JavaDoc ejbModuleName,
53                             ObjectName JavaDoc ejbContainerName)
54            throws MalformedObjectNameException JavaDoc,
55            InvalidParentException
56    {
57       this(name, ejbModuleName, ejbContainerName, null);
58    }
59    /**
60     * Create a MessageDrivenBean model
61     *
62     * @param name the ejb-name from the deployment
63     * @param ejbModuleName the JSR-77 EJBModule name for this bean
64     * @param ejbContainerName the JMX name of the JBoss ejb container MBean
65     * @param localJndiName the jndi name of the local home binding is one exists,
66     * null otherwise.
67     * @throws MalformedObjectNameException
68     * @throws InvalidParentException
69     */

70    public MessageDrivenBean(String JavaDoc name, ObjectName JavaDoc ejbModuleName,
71                             ObjectName JavaDoc ejbContainerName, String JavaDoc localJndiName)
72            throws MalformedObjectNameException JavaDoc,
73            InvalidParentException
74    {
75       super(J2EETypeConstants.MessageDrivenBean, name, ejbModuleName,
76          ejbContainerName, null, localJndiName);
77       stats = new MessageDrivenBeanStatsImpl();
78    }
79
80    // Begin StatisticsProvider interface methods
81
public Stats JavaDoc getstats()
82    {
83       try
84       {
85          updateCommonStats(stats);
86
87          ObjectName JavaDoc containerName = getContainerName();
88          CountStatisticImpl msgCount = (CountStatisticImpl) stats.getMessageCount();
89          Long JavaDoc count = (Long JavaDoc) server.getAttribute(containerName, "MessageCount");
90          msgCount.set(count.longValue());
91       }
92       catch (Exception JavaDoc e)
93       {
94          log.debug("Failed to retrieve stats", e);
95       }
96       return stats;
97    }
98
99    public void resetStats()
100    {
101       stats.reset();
102    }
103    // End StatisticsProvider interface methods
104

105    // Object overrides ---------------------------------------------------
106

107    public String JavaDoc toString()
108    {
109       return "MessageDrivenBean[ " + super.toString() + " ]";
110    }
111 }
112
Popular Tags