01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.monitoring.statistics;
06:
07: import javax.management.openmbean.*;
08: import java.util.Map;
09:
10: public class BoundaryStatisticWrapper extends StatisticWrapper {
11: public String[] getItemNames() {
12: return new String[] { "Description", "LastSampleTime",
13: "LowerBound", "Name", "StartTime", "Unit", "UpperBound" };
14: }
15:
16: public String[] getItemDescriptions() {
17: return new String[] { "DescriptionDescription",
18: "LastSampleTimeDescription", "LowerBoundDescription",
19: "NameDescription", "StartTimeDescription",
20: "UnitDescription", "UpperBoundDescription" };
21: }
22:
23: public OpenType[] getItemTypes() {
24: return new OpenType[] { SimpleType.STRING, SimpleType.LONG,
25: SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
26: SimpleType.STRING, SimpleType.LONG };
27: }
28:
29: public StatisticImpl getStatisticImpl() {
30: if (statisticImpl == null) {
31: statisticImpl = new BoundaryStatisticImpl();
32: }
33:
34: return statisticImpl;
35: }
36:
37: public Object[] getItemValues() {
38: BoundaryStatisticImpl boundaryStatistic = (BoundaryStatisticImpl) getStatisticImpl();
39:
40: return new Object[] { boundaryStatistic.getDescription(),
41: new Long(boundaryStatistic.getLastSampleTime()),
42: new Long(boundaryStatistic.getLowerBound()),
43: boundaryStatistic.getName(),
44: new Long(boundaryStatistic.getStartTime()),
45: boundaryStatistic.getUnit(),
46: new Long(boundaryStatistic.getUpperBound()) };
47: }
48:
49: public void setItemValues(CompositeData compositeData) {
50: Object[] values = compositeData.getAll(getItemNames());
51:
52: BoundaryStatisticImpl boundaryStatistic = (BoundaryStatisticImpl) getStatisticImpl();
53: boundaryStatistic.setDescription((String) values[0]);
54: boundaryStatistic.setLastSampleTime(((Long) values[1])
55: .longValue());
56: boundaryStatistic.setLowerBound(((Long) values[2]).longValue());
57: boundaryStatistic.setName((String) values[3]);
58: boundaryStatistic.setStartTime(((Long) values[4]).longValue());
59: boundaryStatistic.setUnit((String) values[5]);
60: boundaryStatistic.setUpperBound(((Long) values[6]).longValue());
61: }
62:
63: public void reset() {
64: BoundaryStatisticImpl boundaryStatistic = (BoundaryStatisticImpl) getStatisticImpl();
65: boundaryStatistic.reset();
66: }
67:
68: public Map getMBeanAttributeInfo() throws OpenDataException {
69: Map result = super .getMBeanAttributeInfo();
70:
71: // LowerBound, UpperBound are configurable, i.e. write-able
72: String[] itemNames = getItemNames();
73: result.put(itemNames[2], new OpenMBeanAttributeInfoSupport(
74: itemNames[2], getCompositeType().getDescription(
75: itemNames[2]), getCompositeType().getType(
76: itemNames[2]), true, true, false));
77: result.put(itemNames[6], new OpenMBeanAttributeInfoSupport(
78: itemNames[6], getCompositeType().getDescription(
79: itemNames[6]), getCompositeType().getType(
80: itemNames[6]), true, true, false));
81:
82: return result;
83: }
84: }
|