KickJava   Java API By Example, From Geeks To Geeks.

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


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.EntityBeanStatsImpl;
26 import org.jboss.management.j2ee.statistics.RangeStatisticImpl;
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.12 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 EntityBean extends EJB
40    implements EntityBeanMBean
41 {
42
43    // Attributes ----------------------------------------------------
44

45    private EntityBeanStatsImpl stats;
46    
47    // Static --------------------------------------------------------
48

49    private static Logger log = Logger.getLogger(EntityBean.class);
50    
51    // Constructors --------------------------------------------------
52

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

74    public EntityBean(String JavaDoc name, ObjectName JavaDoc ejbModuleName,
75       ObjectName JavaDoc ejbContainerName, String JavaDoc jndiName, String JavaDoc localJndiName)
76            throws MalformedObjectNameException JavaDoc,
77            InvalidParentException
78    {
79       super(J2EETypeConstants.EntityBean, name, ejbModuleName, ejbContainerName,
80          jndiName, localJndiName);
81       stats = new EntityBeanStatsImpl();
82    }
83
84    // Begin StatisticsProvider interface methods
85
public Stats JavaDoc getstats()
86    {
87       try
88       {
89          updateCommonStats(stats);
90
91          ObjectName JavaDoc poolName = getContainerPoolName();
92          RangeStatisticImpl pooledCount = (RangeStatisticImpl) stats.getReadyCount();
93          Integer JavaDoc poolSize = (Integer JavaDoc) server.getAttribute(poolName, "CurrentSize");
94          pooledCount.set(poolSize.longValue());
95
96          ObjectName JavaDoc cacheName = getContainerCacheName();
97          RangeStatisticImpl readyCount = (RangeStatisticImpl) stats.getReadyCount();
98          Long JavaDoc count = (Long JavaDoc) server.getAttribute(cacheName, "CacheSize");
99          readyCount.set(count.longValue());
100       }
101       catch (Exception JavaDoc e)
102       {
103          log.debug("Failed to retrieve stats", e);
104       }
105       return stats;
106    }
107
108    public void resetStats()
109    {
110       stats.reset();
111    }
112    
113    // End StatisticsProvider interface methods
114

115    // Object overrides ---------------------------------------------------
116

117    public String JavaDoc toString()
118    {
119       return "EntityBean { " + super.toString() + " } []";
120    }
121 }
122
Popular Tags