KickJava   Java API By Example, From Geeks To Geeks.

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


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.RangeStatisticImpl;
26 import org.jboss.management.j2ee.statistics.StatelessSessionBeanStatsImpl;
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.15 implementation of the StatelessSessionBean 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 StatelessSessionBean extends SessionBean
40    implements StatelessSessionBeanMBean
41 {
42
43    // Attributes ----------------------------------------------------
44
private static Logger log = Logger.getLogger(StatelessSessionBean.class);
45    private StatelessSessionBeanStatsImpl stats;
46
47    // Static --------------------------------------------------------
48

49    // Constructors --------------------------------------------------
50

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

71    public StatelessSessionBean(String JavaDoc name, ObjectName JavaDoc ejbModuleName,
72       ObjectName JavaDoc ejbContainerName, String JavaDoc jndiName, String JavaDoc localJndiName)
73            throws MalformedObjectNameException JavaDoc,
74            InvalidParentException
75    {
76       super(J2EETypeConstants.StatelessSessionBean, name, ejbModuleName,
77          ejbContainerName, jndiName, localJndiName);
78       stats = new StatelessSessionBeanStatsImpl();
79    }
80
81    // Begin StatisticsProvider interface methods
82
public Stats JavaDoc getstats()
83    {
84       try
85       {
86          updateCommonStats(stats);
87
88          ObjectName JavaDoc poolName = getContainerPoolName();
89          RangeStatisticImpl readyCount = (RangeStatisticImpl) stats.getMethodReadyCount();
90          Integer JavaDoc poolSize = (Integer JavaDoc) server.getAttribute(poolName, "CurrentSize");
91          readyCount.set(poolSize.longValue());
92       }
93       catch (Exception JavaDoc e)
94       {
95          log.debug("Failed to retrieve stats", e);
96       }
97       return stats;
98    }
99
100    public void resetStats()
101    {
102       stats.reset();
103    }
104    // End StatisticsProvider interface methods
105

106    // Object overrides ---------------------------------------------------
107

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