KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > agentx > master > AbstractAgentXPending


1 /*_############################################################################
2   _##
3   _## SNMP4J-AgentX - AbstractAgentXPending.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.master;
24
25 import org.snmp4j.agent.agentx.AgentXProtocol;
26 import org.snmp4j.agent.request.SnmpRequest;
27 import java.util.Date JavaDoc;
28
29 public abstract class AbstractAgentXPending implements AgentXPending {
30
31   protected AgentXRegEntry registration;
32   private SnmpRequest request;
33   private boolean pending = true;
34   private long timestamp = 0L;
35   private int timeout = AgentXProtocol.DEFAULT_TIMEOUT_SECONDS;
36
37   public AbstractAgentXPending(AgentXRegEntry registration,
38                                SnmpRequest request) {
39     this.registration = registration;
40     this.request = request;
41   }
42
43   public void updateTimestamp() {
44     timestamp = System.currentTimeMillis();
45   }
46
47   public long getTimestamp() {
48     return timestamp;
49   }
50
51   public void setTimeout(int timeoutSeconds) {
52     this.timeout = timeoutSeconds;
53   }
54
55   public void setPending(boolean pending) {
56     this.pending = pending;
57   }
58
59   public int getTimeout() {
60     return timeout;
61   }
62
63   public AgentXRegEntry getRegistration() {
64     return registration;
65   }
66
67   public boolean isPending() {
68     return pending;
69   }
70
71   public SnmpRequest getRequest() {
72     return request;
73   }
74
75   public String JavaDoc toString() {
76     return getClass().getName()+"["+toStringMembers()+"]";
77   }
78
79   protected final String JavaDoc toStringMembers() {
80     return "registration="+registration+",request="+request+",pending="+
81         pending+",timestamp="+new Date JavaDoc(timestamp)+",timeout="+timeout;
82   }
83 }
84
Popular Tags