001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)ProxyBindingStatistics.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.proxy;
030:
031: import java.util.Date;
032: import com.sun.jbi.util.monitoring.StatisticsBaseImpl;
033: import com.sun.jbi.monitoring.ProxyBindingStatisticsMBean;
034:
035: /**
036: * This class provides the statistics implementation for the ProxyBinding.
037: * All statistics are since the last JBI startup; they are all reset when
038: * JBI is restarted.
039: *
040: * @author Sun Microsystems, Inc.
041: */
042: public class ProxyBindingStatistics extends ProxyBindingStatisticsBase
043: implements ProxyBindingStatisticsMBean {
044: /**
045: * Events received by the ProxyBinding
046: */
047: private long mEventsReceived;
048:
049: /**
050: * Events sent by the ProxyBinding
051: */
052: private long mEventsSent;
053:
054: /**
055: * Last time the ProxyBinding was restarted
056: */
057: private Date mLastNodeRestartTime;
058:
059: /** constructor. */
060: public ProxyBindingStatistics() {
061: //mStatisticsBase = new StatisticsBaseImpl("SunProxyBinding");
062: }
063:
064: /**
065: * Increment the total number of Events received since the
066: * last PB startup.
067: */
068: public synchronized void incrementReceivedEvents() {
069: mEventsReceived++;
070: }
071:
072: /**
073: * Increment the total number of Events sent since the
074: * last PB startup.
075: */
076: public synchronized void incrementSentEvents() {
077: mEventsSent++;
078: }
079:
080: /**
081: * Set the PB restart time.
082: * @param time the new restart time.
083: */
084: public synchronized void setNodeRestartTime(Date time) {
085: mLastNodeRestartTime = time;
086: }
087:
088: /**
089: * Reset all statistics.
090: */
091: public synchronized void resetAllStatistics() {
092: mEventsReceived = 0;
093: mEventsSent = 0;
094: super .resetAllStatistics();
095: }
096:
097: // methods on ProxyBindingStatisticsMBean
098:
099: /**
100: * Get the total number of Events received by the PB since the
101: * last NMR startup.
102: * @return The number of Events received.
103: */
104: public long getReceivedEvents() {
105: return mEventsReceived;
106: }
107:
108: /**
109: * Get the total number of Events sent by the PB since the
110: * last NMR startup.
111: * @return The number of Events sent.
112: */
113: public long getSentEvents() {
114: return mEventsSent;
115: }
116:
117: /**
118: * Get the last time the NMR in the local JBI instance restarted.
119: * @return The time of last restart.
120: */
121: public Date getLastNodeRestartTime() {
122: return mLastNodeRestartTime;
123: }
124: }
|