KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > agentx > AgentXResponseEvent


1 /*_############################################################################
2   _##
3   _## SNMP4J-AgentX - AgentXResponseEvent.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## This program is free software; you can redistribute it and/or modify
8   _## it under the terms of the GNU General Public License version 2 as
9   _## published by the Free Software Foundation.
10   _##
11   _## This program is distributed in the hope that it will be useful,
12   _## but WITHOUT ANY WARRANTY; without even the implied warranty of
13   _## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   _## GNU General Public License for more details.
15   _##
16   _## You should have received a copy of the GNU General Public License
17   _## along with this program; if not, write to the Free Software
18   _## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19   _## MA 02110-1301 USA
20   _##
21   _##########################################################################*/

22
23 package org.snmp4j.agent.agentx;
24
25 import java.util.EventObject JavaDoc;
26
27 import org.snmp4j.smi.Address;
28
29 public class AgentXResponseEvent extends EventObject JavaDoc {
30   private Address peerAddress;
31   private AgentXTarget target;
32   private AgentXPDU request;
33   private AgentXResponsePDU response;
34   private Object JavaDoc userObject;
35   private Exception JavaDoc error;
36
37   /**
38    * Creates an <code>AgentXResponseEvent</code> instance.
39    * @param source
40    * the event source.
41    * @param target
42    * the target where the request has been sent to.
43    * @param peerAddress
44    * the transport address of the entity that send the response.
45    * @param request
46    * the request AgentXPDU (must not be <code>null</code>).
47    * @param response
48    * the AgentXResponsePDU or <code>null</code> if the request timed out.
49    * @param userObject
50    * an optional user object.
51    */

52   public AgentXResponseEvent(Object JavaDoc source,
53                              AgentXTarget target,
54                              Address peerAddress,
55                              AgentXPDU request,
56                              AgentXResponsePDU response,
57                              Object JavaDoc userObject) {
58     super(source);
59     setPeerAddress(peerAddress);
60     this.target = target;
61     setRequest(request);
62     setResponse(response);
63     setUserObject(userObject);
64   }
65
66   /**
67    * Creates an <code>ResponseEvent</code> instance with an exception object
68    * indicating a message processing error.
69    * @param source
70    * the event source.
71    * @param target
72    * the target where the request has been sent to.
73    * @param peerAddress
74    * the transport address of the entity that send the response.
75    * @param request
76    * the request PDU (must not be <code>null</code>).
77    * @param response
78    * the response PDU or <code>null</code> if the request timed out.
79    * @param userObject
80    * an optional user object.
81    * @param error
82    * an <code>Exception</code>.
83    */

84   public AgentXResponseEvent(Object JavaDoc source,
85                              AgentXTarget target,
86                              Address peerAddress,
87                              AgentXPDU request,
88                              AgentXResponsePDU response,
89                              Object JavaDoc userObject,
90                              Exception JavaDoc error) {
91     this(source, target, peerAddress, request, response, userObject);
92     this.error = error;
93   }
94
95   /**
96    * Gets the request PDU.
97    * @return
98    * a <code>PDU</code>.
99    */

100   public AgentXPDU getRequest() {
101     return request;
102   }
103
104   protected final void setPeerAddress(Address peerAddress) {
105     this.peerAddress = peerAddress;
106   }
107
108   protected final void setRequest(AgentXPDU request) {
109     this.request = request;
110   }
111
112   protected final void setResponse(AgentXResponsePDU response) {
113     this.response = response;
114   }
115
116   /**
117    * Gets the response PDU.
118    * @return
119    * a PDU instance if a response has been received. If the request
120    * timed out then <code>null</code> will be returned.
121    */

122   public AgentXResponsePDU getResponse() {
123     return response;
124   }
125
126   protected final void setUserObject(Object JavaDoc userObject) {
127     this.userObject = userObject;
128   }
129
130   /**
131    * Gets the user object that has been supplied to the asynchronous request
132    * {@link AgentX#send(AgentXPDU pdu, AgentXTarget target,
133    * TransportMapping transport)}.
134    * @return
135    * an Object.
136    */

137   public Object JavaDoc getUserObject() {
138     return userObject;
139   }
140
141   /**
142    * Gets the exception object from the exception that has been generated
143    * when the request processing has failed due to an error.
144    * @return
145    * an <code>Exception</code> instance.
146    */

147   public Exception JavaDoc getError() {
148     return error;
149   }
150
151   /**
152    * Gets the transport address of the response sender.
153    * @return
154    * the transport <code>Address</code> of the command responder that send
155    * this response, or <code>null</code> if no response has been received
156    * within the time-out interval or if an error occured (see
157    * {@link #getError()}).
158    */

159   public Address getPeerAddress() {
160     return peerAddress;
161   }
162
163   public AgentXTarget getTarget() {
164     return target;
165   }
166
167 }
168
Popular Tags