RecordSessionEJBMBeanImpl.java
01 package com.bea.medrec.controller;
02 
03 import javax.management.StandardMBean;
04 
05 /**
06  <p>The implementation for a standard MBean that keeps track of how many
07  * times RecordSessionEJB writes a prescription to the database.</p>
08  <p>The MBean's interface is implemented in this class (instead of in
09  * the EJB itself) so that management logic is separate from business logic.</p> 
10  <p>All implementations of standard MBeans must be public classes.</p>
11  <p>This class extends javax.management.StandardMBean so that the
12  * MBean can follow BEA's naming conventions:</p>
13  <ul>
14  <li>The interface file is named <code><i>Business-object</i>MBean.java</code>
15  <br/>where <i>Business-object</i> is the object that is being managed.</li>
16  <li>The implementation file is named <code><i>MBean-interface</i>Impl.java</code>
17  </li></ul>
18  *
19  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
20  */
21 
22 public class RecordSessionEJBMBeanImpl
23     extends StandardMBean implements RecordSessionEJBMBean {
24   
25   /**
26    <p>Instance variable for the number of times RecordSessionEJB writes
27    * a prescription to the database.</p>
28    <p>The variable is static because RecordSessionEJB is
29    * static.</p>
30    */  
31   public static int totalRx = 0;
32  
33   /**
34    <p>Implements the getTotalRx() method in the management interface.</p>
35    */
36   public int getTotalRx() {
37     return totalRx;
38   }
39  
40   /**
41    <p>Used by RecordSessionEJB to push management data to this MBean.</p>
42    <p>The RecordSessionEJB.addPrescriptions() method is implemented to invoke
43    * this method. </p>
44    */
45   public static void incrementTotalRx() {
46     totalRx++;
47   }
48 
49   public void resetTotalRx() {
50     totalRx = 0;
51   }
52 
53   /**
54    <p>Because the class extends javax.management.StandardMBean, it must
55    * provide a public constructor that implements the 
56    * StandardMBean(Object implementation, Class mbeanInterface) constructor.</p>
57    */
58   public RecordSessionEJBMBeanImpl() throws
59       javax.management.NotCompliantMBeanException {
60     super(RecordSessionEJBMBean.class);
61   }
62 }