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: * @(#)FrameworkStatistics.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.framework;
030:
031: import com.sun.jbi.monitoring.FrameworkStatisticsMBean;
032: import java.util.Date;
033:
034: /**
035: * This class implements the MBean for collection of statistics for the
036: * framework. All statistics are since the last JBI startup; they are all
037: * reset when JBI is restarted.
038: *
039: * @author Sun Microsystems, Inc.
040: */
041: public class FrameworkStatistics implements FrameworkStatisticsMBean {
042: /**
043: * Time of the last JBI Framework startup.
044: */
045: private Date mLastRestartTime;
046:
047: /**
048: * Amount of time in milliseconds taken for the last JBI Framework startup.
049: */
050: private long mStartupTime;
051:
052: /**
053: * Number of component registry additions since the last JBI startup.
054: */
055: private long mRegistryAdds;
056:
057: /**
058: * Number of component registry deletions since the last JBI startup.
059: */
060: private long mRegistryDeletes;
061:
062: //
063: // Methods defined in the FrameworkStatisticsMBean interface.
064: //
065:
066: /**
067: * Get the time/date of the last JBI Framework restart.
068: * @return The time/date of the last restart of the JBI Framework.
069: */
070: public Date getLastRestartTime() {
071: return mLastRestartTime;
072: }
073:
074: /**
075: * Get the time in milliseconds used by the last restart of the JBI
076: * framework.
077: * @return The total startup time in milliseconds.
078: */
079: public long getStartupTime() {
080: return mStartupTime;
081: }
082:
083: /**
084: * Get the count of component registry additions.
085: * @return The total number of entries added to the component registry
086: * since the last JBI startup.
087: */
088: public long getRegistryAdds() {
089: return mRegistryAdds;
090: }
091:
092: /**
093: * Get the count of component registry deletions.
094: * @return The total number of entries deleted from the component registry
095: * since the last JBI startup.
096: */
097: public long getRegistryDeletes() {
098: return mRegistryDeletes;
099: }
100:
101: //
102: // Instrumentation methods local to the framework. Note that the methods
103: // which operate on fields not guaranteed to be thread-safe for updates
104: // are synchronized to prevent data corruption.
105: //
106:
107: /**
108: * Set the time/date of the last JBI Framework restart.
109: * @param lastRestartTime The time/date of the last JBI Framework restart.
110: */
111: synchronized void setLastRestartTime(Date lastRestartTime) {
112: mLastRestartTime = lastRestartTime;
113: }
114:
115: /**
116: * Set the time used for the last JBI Framework restart.
117: * @param startupTime The number of milliseconds used by the last JBI
118: * Framework startup.
119: */
120: synchronized void setStartupTime(long startupTime) {
121: mStartupTime = startupTime;
122: }
123:
124: /**
125: * Increment the count of component registry additions.
126: */
127: synchronized void incrementRegistryAdds() {
128: ++mRegistryAdds;
129: }
130:
131: /**
132: * Increment the count of component registry deletions.
133: */
134: synchronized void incrementRegistryDeletes() {
135: ++mRegistryDeletes;
136: }
137:
138: /**
139: * Reset component registry statistics.
140: */
141: synchronized void resetRegistryStatistics() {
142: mRegistryAdds = 0;
143: mRegistryDeletes = 0;
144: }
145:
146: }
|