View Javadoc
1   // NAME
2   //      $RCSfile: PassiveSnmpContext.java,v $
3   // DESCRIPTION
4   //      [given below in javadoc format]
5   // DELTA
6   //      $Revision: 3.10 $
7   // CREATED
8   //      $Date: 2009/03/05 13:12:50 $
9   // COPYRIGHT
10  //      ERG Group Ltd
11  // TO DO
12  //
13  
14  /*
15   * Copyright (C) 2002 - 2006 by Westhawk Ltd
16   * <a href="www.westhawk.co.uk">www.westhawk.co.uk</a>
17   *
18   * Permission to use, copy, modify, and distribute this software
19   * for any purpose and without fee is hereby granted, provided
20   * that the above copyright notices appear in all copies and that
21   * both the copyright notice and this permission notice appear in
22   * supporting documentation.
23   * This software is provided "as is" without express or implied
24   * warranty.
25   * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
26   */
27  
28  package uk.co.westhawk.snmp.stack;
29  
30  /*-
31   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
32   * SNMP Java Client
33   * ჻჻჻჻჻჻
34   * Copyright 2023 MetricsHub, Westhawk
35   * ჻჻჻჻჻჻
36   * This program is free software: you can redistribute it and/or modify
37   * it under the terms of the GNU Lesser General Public License as
38   * published by the Free Software Foundation, either version 3 of the
39   * License, or (at your option) any later version.
40   *
41   * This program is distributed in the hope that it will be useful,
42   * but WITHOUT ANY WARRANTY; without even the implied warranty of
43   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44   * GNU General Lesser Public License for more details.
45   *
46   * You should have received a copy of the GNU General Lesser Public
47   * License along with this program.  If not, see
48   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
49   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
50   */
51  
52  /**
53   * This class contains the SNMP v1 context that is needed by a Pdu to
54   * send a SNMP v1 request in environments where thread creation is
55   * unwanted.
56   *
57   * <p>
58   * This extends SnmpContext so that it does not create any
59   * threads to send PDUs. It must be used with the
60   * PDU class PassiveTrapPduv1. The original purpose of the
61   * Passive classes is to allow the stack to be used in environments where
62   * thread creation is unwanted, eg database JVMs such as Oracle JServer.
63   * See <a href="http://www.ietf.org/rfc/rfc3416.txt">SNMPv2-PDU</a>.
64   * </p>
65   *
66   * <p>
67   * See 
68   * <a
69   * href="../../../../../uk/co/westhawk/nothread/trap/package-summary.html">notes</a>
70   * on how to send traps in an Oracle JServer environment.
71   * </p>
72   *
73   * @see uk.co.westhawk.snmp.pdu.PassiveTrapPduv1
74   * @since 4_12
75   *
76   * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a>
77   * @version $Revision: 3.10 $ $Date: 2009/03/05 13:12:50 $
78   */
79  public class PassiveSnmpContext extends SnmpContext {
80      private static final String version_id = "@(#)$Id: PassiveSnmpContext.java,v 3.10 2009/03/05 13:12:50 birgita Exp $ Copyright Westhawk Ltd";
81  
82      /**
83       * Constructor.
84       *
85       * @param host The host to which the Pdu will be sent
86       * @param port The port where the SNMP server will be
87       * @see SnmpContext#SnmpContext(String, int)
88       */
89      public PassiveSnmpContext(String host, int port)
90              throws java.io.IOException {
91          super(host, port);
92      }
93  
94      /**
95       * Constructor.
96       * Parameter typeSocketA should be either STANDARD_SOCKET, TCP_SOCKET or a
97       * fully qualified classname.
98       *
99       * @param host        The host to which the Pdu will be sent
100      * @param port        The port where the SNMP server will be
101      * @param typeSocketA The type of socket to use.
102      *
103      * @see SnmpContext#SnmpContext(String, int, String)
104      * @see SnmpContextBasisFace#STANDARD_SOCKET
105      * @see SnmpContextBasisFace#TCP_SOCKET
106      */
107     public PassiveSnmpContext(String host, int port, String typeSocketA)
108             throws java.io.IOException {
109         super(host, port, typeSocketA);
110     }
111 
112     /**
113      * Constructor.
114      *
115      * If bindAddress is null, then the system will pick up a valid local
116      * address to bind the socket.
117      *
118      * The typeSocketA will indicate which type of socket to use. This way
119      * different handlers can be provided.
120      * It should be either STANDARD_SOCKET, TCP_SOCKET or a
121      * fully qualified classname.
122      *
123      * @param host        The host to which the Pdu will be sent
124      * @param port        The port where the SNMP server will be
125      * @param bindAddress The local address the server will bind to
126      * @param typeSocketA The type of socket to use.
127      *
128      * @exception java.io.IOException Thrown when the socket cannot be
129      *                                created.
130      *
131      * @see SnmpContextBasisFace#STANDARD_SOCKET
132      * @see SnmpContextBasisFace#TCP_SOCKET
133      * @since 4_14
134      */
135     protected PassiveSnmpContext(String host, int port, String bindAddress, String typeSocketA)
136             throws java.io.IOException {
137         super(host, port, bindAddress, typeSocketA);
138     }
139 
140     /**
141      * Overrides the AbstractSnmpContext.activate() to do nothing.
142      * This prevents the creation of threads in the base class.
143      *
144      * @see AbstractSnmpContext#activate()
145      */
146     protected void activate() {
147         // do nothing
148     }
149 
150 }