1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * 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 /***
23 * Base JMX Notification. Supports in int code and notes - for faster
24 * access and dispatching.
25 *
26 * @author Costin Manolache
27 */
28 public final class BaseNotification extends Notification {
29
30 // ----------------------------------------------------------- Constructors
31 private int code;
32 private String type;
33 private Object source;
34 private long seq;
35 private long tstamp;
36
37 /***
38 * Private constructor.
39 */
40 private BaseNotification(String type,
41 Object source,
42 long seq,
43 long tstamp,
44 int code) {
45 super(type, source, seq, tstamp);
46 init( type, source, seq, tstamp, code );
47 this.code=code;
48 }
49
50 public void recycle() {
51
52 }
53
54 public void init( String type, Object source,
55 long seq, long tstamp, int code )
56 {
57 this.type=type;
58 this.source = source;
59 this.seq=seq;
60 this.tstamp=tstamp;
61 this.code = code;
62 }
63
64 // -------------------- Override base methods --------------------
65 // All base methods need to be overriden - in order to support recycling.
66
67
68 // -------------------- Information associated with the notification ----
69 // Like events ( which Notification extends ), notifications may store
70 // informations related with the event that trigered it. Source and type is
71 // one piece, but it is common to store more info.
72
73 /*** Action id, useable in switches and table indexes
74 */
75 public int getCode() {
76 return code;
77 }
78
79 // XXX Make it customizable - or grow it
80 private Object notes[]=new Object[32];
81
82 public final Object getNote(int i ) {
83 return notes[i];
84 }
85
86 public final void setNote(int i, Object o ) {
87 notes[i]=o;
88 }
89 }