01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.modeler;
18:
19: import javax.management.Notification;
20:
21: /**
22: * Base JMX Notification. Supports in int code and notes - for faster
23: * access and dispatching.
24: *
25: * @author Costin Manolache
26: */
27: public final class BaseNotification extends Notification {
28:
29: // ----------------------------------------------------------- Constructors
30: private int code;
31: private String type;
32: private Object source;
33: private long seq;
34: private long tstamp;
35:
36: /**
37: * Private constructor.
38: */
39: private BaseNotification(String type, Object source, long seq,
40: long tstamp, int code) {
41: super (type, source, seq, tstamp);
42: init(type, source, seq, tstamp, code);
43: this .code = code;
44: }
45:
46: public void recycle() {
47:
48: }
49:
50: public void init(String type, Object source, long seq, long tstamp,
51: int code) {
52: this .type = type;
53: this .source = source;
54: this .seq = seq;
55: this .tstamp = tstamp;
56: this .code = code;
57: }
58:
59: // -------------------- Override base methods --------------------
60: // All base methods need to be overriden - in order to support recycling.
61:
62: // -------------------- Information associated with the notification ----
63: // Like events ( which Notification extends ), notifications may store
64: // informations related with the event that trigered it. Source and type is
65: // one piece, but it is common to store more info.
66:
67: /** Action id, useable in switches and table indexes
68: */
69: public int getCode() {
70: return code;
71: }
72:
73: // XXX Make it customizable - or grow it
74: private Object notes[] = new Object[32];
75:
76: public final Object getNote(int i) {
77: return notes[i];
78: }
79:
80: public final void setNote(int i, Object o) {
81: notes[i] = o;
82: }
83: }
|