01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2006 Continuent
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.continuent.sequoia.common.jmx.management;
19:
20: import javax.management.openmbean.CompositeData;
21: import javax.management.openmbean.CompositeDataSupport;
22: import javax.management.openmbean.CompositeType;
23: import javax.management.openmbean.OpenDataException;
24: import javax.management.openmbean.OpenType;
25: import javax.management.openmbean.SimpleType;
26: import javax.management.openmbean.TabularData;
27: import javax.management.openmbean.TabularDataSupport;
28: import javax.management.openmbean.TabularType;
29:
30: import org.continuent.sequoia.common.log.Trace;
31:
32: public class TransactionDataSupport {
33:
34: protected static Trace logger = Trace
35: .getLogger(TransactionDataSupport.class.getName());
36:
37: private final static CompositeType TRANSACTION_COMPOSITE_TYPE;
38: private final static TabularType TRANSACTION_TABULAR_TYPE;
39:
40: public static final String[] NAMES = new String[] { "tid", "time" };
41: private static final OpenType[] TYPES = new OpenType[] {
42: SimpleType.LONG, SimpleType.LONG };
43:
44: static {
45: try {
46: TRANSACTION_COMPOSITE_TYPE = new CompositeType(
47: "transaction", "transaction information", NAMES,
48: NAMES, TYPES);
49: TRANSACTION_TABULAR_TYPE = new TabularType("transactions",
50: "table of transaction informations",
51: TRANSACTION_COMPOSITE_TYPE, new String[] { "tid" });
52: } catch (OpenDataException e) {
53: // should never happens but if it does, we're seriously screwed.
54: throw new ExceptionInInitializerError(e);
55: }
56: }
57:
58: public static CompositeData newCompositeData(long tid, long time)
59: throws OpenDataException {
60: Object[] values = new Object[] { new Long(tid), new Long(time) };
61: return new CompositeDataSupport(TRANSACTION_COMPOSITE_TYPE,
62: NAMES, values);
63: }
64:
65: public static TabularData newTabularData() throws Exception {
66: TabularData data = new TabularDataSupport(
67: TRANSACTION_TABULAR_TYPE);
68: return data;
69: }
70: }
|