001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.monitoring.statistics;
006:
007: import javax.management.openmbean.*;
008: import java.util.Map;
009:
010: public class BoundedRangeStatisticWrapper extends StatisticWrapper {
011: public String[] getItemNames() {
012: return new String[] { "Current", "Description",
013: "HighWaterMark", "LastSampleTime", "LowWaterMark",
014: "LowerBound", "Name", "StartTime", "Unit", "UpperBound" };
015: }
016:
017: public String[] getItemDescriptions() {
018: return new String[] { "CurrentDescription",
019: "DescriptionDescription", "HighWaterMarkDescription",
020: "LastSampleTimeDescription", "LowWaterMarkDescription",
021: "LowerBound", "NameDescription",
022: "StartTimeDescription", "UnitDescription", "UpperBound" };
023: }
024:
025: public OpenType[] getItemTypes() {
026: return new OpenType[] { SimpleType.LONG, SimpleType.STRING,
027: SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
028: SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
029: SimpleType.STRING, SimpleType.LONG };
030: }
031:
032: public StatisticImpl getStatisticImpl() {
033: if (statisticImpl == null) {
034: statisticImpl = new BoundedRangeStatisticImpl();
035: }
036:
037: return statisticImpl;
038: }
039:
040: public Object[] getItemValues() {
041: BoundedRangeStatisticImpl boundedRangeStatistic = (BoundedRangeStatisticImpl) getStatisticImpl();
042:
043: return new Object[] {
044: new Long(boundedRangeStatistic.getCurrent()),
045: boundedRangeStatistic.getDescription(),
046: new Long(boundedRangeStatistic.getHighWaterMark()),
047: new Long(boundedRangeStatistic.getLastSampleTime()),
048: new Long(boundedRangeStatistic.getLowWaterMark()),
049: new Long(boundedRangeStatistic.getLowerBound()),
050: boundedRangeStatistic.getName(),
051: new Long(boundedRangeStatistic.getStartTime()),
052: boundedRangeStatistic.getUnit(),
053: new Long(boundedRangeStatistic.getUpperBound()) };
054: }
055:
056: public void setItemValues(CompositeData compositeData) {
057: Object[] values = compositeData.getAll(getItemNames());
058:
059: BoundedRangeStatisticImpl boundedRangeStatistic = (BoundedRangeStatisticImpl) getStatisticImpl();
060: boundedRangeStatistic
061: .setCurrent(((Long) values[0]).longValue());
062: boundedRangeStatistic.setDescription((String) values[1]);
063: boundedRangeStatistic.setHighWaterMark(((Long) values[2])
064: .longValue());
065: boundedRangeStatistic.setLastSampleTime(((Long) values[3])
066: .longValue());
067: boundedRangeStatistic.setLowWaterMark(((Long) values[4])
068: .longValue());
069: boundedRangeStatistic.setLowerBound(((Long) values[5])
070: .longValue());
071: boundedRangeStatistic.setName((String) values[6]);
072: boundedRangeStatistic.setStartTime(((Long) values[7])
073: .longValue());
074: boundedRangeStatistic.setUnit((String) values[8]);
075: boundedRangeStatistic.setUpperBound(((Long) values[9])
076: .longValue());
077: }
078:
079: public void reset() {
080: BoundedRangeStatisticImpl boundedRangeStatistic = (BoundedRangeStatisticImpl) getStatisticImpl();
081: boundedRangeStatistic.reset();
082: }
083:
084: public Map getMBeanAttributeInfo() throws OpenDataException {
085: Map result = super .getMBeanAttributeInfo();
086:
087: // LowerBound, UpperBound are configurable, i.e. write-able
088: String[] itemNames = getItemNames();
089: result.put(itemNames[5], new OpenMBeanAttributeInfoSupport(
090: itemNames[5], getCompositeType().getDescription(
091: itemNames[5]), getCompositeType().getType(
092: itemNames[5]), true, true, false));
093: result.put(itemNames[9], new OpenMBeanAttributeInfoSupport(
094: itemNames[9], getCompositeType().getDescription(
095: itemNames[9]), getCompositeType().getType(
096: itemNames[9]), true, true, false));
097:
098: return result;
099: }
100: }
|