KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > DeniableEventObject


1 /*_############################################################################
2   _##
3   _## SNMP4J-Agent - DeniableEventObject.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21 package org.snmp4j.agent.mo;
22
23 import java.util.EventObject JavaDoc;
24
25 /**
26  * The <code>DeniableEventObject</code> describes an event that can be canceled
27  * through reporting a SNMP error status to the event source.
28  *
29  * @author Frank Fock
30  * @version 1.1
31  * @since 1.1
32  */

33 public class DeniableEventObject extends EventObject JavaDoc {
34
35   private static final long serialVersionUID = 8808826350825049569L;
36
37   private int denyReason = 0;
38   private boolean deniable = false;
39
40   /**
41    * Creates an deniable event instance.
42    * @param source
43    * the event source.
44    * @param deniable
45    * if <code>true</code> the event can be canceled by setting its deny
46    * reason to a SNMPv2/v3 error status, <code>false</code> if the event
47    * cannot be canceled, because, for example, it is fired on behalf of
48    * the commit phase of a 2PC transaction.
49    */

50   public DeniableEventObject(Object JavaDoc source, boolean deniable) {
51     super(source);
52     this.deniable = deniable;
53   }
54
55   /**
56    * Sets the reason why this event needs to be canceled. A reason other than
57    * zero will cancel the change if it has not been performed yet.
58    * @param denyReason
59    * a SNMPv2/v3 error status.
60    */

61   public void setDenyReason(int denyReason) {
62     this.denyReason = denyReason;
63   }
64
65   /**
66    * Returns the reason (i.e., SNMPv2/v3 error status) that indicates the error
67    * condition that caused this event to be canceled.
68    * @return
69    * a SNMP2v/v3 error status.
70    */

71   public int getDenyReason() {
72     return denyReason;
73   }
74
75   /**
76    * Checks whether this event is fired in the preparation phase or the commit
77    * phase of the 2PC.
78    * @return
79    * <code>true</code> if the event can be canceled and thus the event has
80    * been fired on behalf of the preparation phase and <code>false</code>
81    * if it has been fired on behalf of the commit phase.
82    */

83   public boolean isDeniable() {
84     return deniable;
85   }
86
87 }
88
Popular Tags