1 /*
2 * Copyright 1999,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.apache.commons.modeler;
17
18 import javax.management.Notification;
19
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,
40 Object source,
41 long seq,
42 long tstamp,
43 int code) {
44 super(type, source, seq, tstamp);
45 init( type, source, seq, tstamp, code );
46 this.code=code;
47 }
48
49 public void recycle() {
50
51 }
52
53 public void init( String type, Object source,
54 long seq, long tstamp, int code )
55 {
56 this.type=type;
57 this.source = source;
58 this.seq=seq;
59 this.tstamp=tstamp;
60 this.code = code;
61 }
62
63 // -------------------- Override base methods --------------------
64 // All base methods need to be overriden - in order to support recycling.
65
66
67 // -------------------- Information associated with the notification ----
68 // Like events ( which Notification extends ), notifications may store
69 // informations related with the event that trigered it. Source and type is
70 // one piece, but it is common to store more info.
71
72 /*** Action id, useable in switches and table indexes
73 */
74 public int getCode() {
75 return code;
76 }
77
78 // XXX Make it customizable - or grow it
79 private Object notes[]=new Object[32];
80
81 public final Object getNote(int i ) {
82 return notes[i];
83 }
84
85 public final void setNote(int i, Object o ) {
86 notes[i]=o;
87 }
88 }