KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > SNMP4JSettings


1 /*_############################################################################
2   _##
3   _## SNMP4J - SNMP4JSettings.java
4   _##
5   _## Copyright 2003-2007 Frank Fock and Jochen Katz (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;
22
23 /**
24  * The <code>SNMP4JSettings</code> class implements a central configuration
25  * class of the SNMP4J framework. As a rule of thumb, changes to the default
26  * configuration should be made before any other classes of the SNMP4J API are
27  * instantiated or referenced by the application code.
28  *
29  * @author Frank Fock
30  * @version 1.8.1
31  * @since 1.5
32  */

33 public final class SNMP4JSettings {
34
35   /**
36    * Specifies whether SNMP4J can be extended by own implementation of
37    * security protocols, transport mappings, address types, SMI syntaxes, etc.
38    * through property files defined via System properties.
39    * If set to <code>false</code> all classes SNMP4J is aware of will be
40    * used hard coded which speeds up initialization and is required to use
41    * SNMP4J in a secure environment where System properties are not available
42    * (i.e. in an unsigned applet).
43    * @since 1.2.2
44    */

45   private static boolean extensibilityEnabled = false;
46
47   /**
48    * By default SNMP4J (and SNMP4J-Agent*) catch runtime exceptions at thread
49    * boundaries of API controlled threads. In SNMP4J such a thread runs in each
50    * {@link TransportMapping} and in each {@link Snmp} session object. To ensure
51    * robust runtime behavior, unexpected runtime exceptions are caught and
52    * logged. If you need to localize and debug such exceptions then set this
53    * value to <code>true</code>.
54    *
55    * @since 1.8.1
56    */

57   private static volatile boolean forwardRuntimeExceptions = false;
58
59   /**
60    * Enables (or disables) the extensibility feature of SNMP4J. When enabled,
61    * SNMP4J checks certain properties files that describe which transport
62    * mappings, address types, SMI syntaxes, security protocols, etc. should be
63    * supported by SNMP4J.
64    * <p>
65    * By default, the extensibility feature is disabled which provides a faster
66    * startup and since no system properties are read, it ensures that SNMP4J
67    * can be used also in secure environments like applets.
68    * @param enable
69    * if <code>true</code> activates extensibility or if <code>false</code>
70    * disables it. In the latter case, SNMP4J's default configuration will
71    * be used with all available features.
72    * @since 1.2.2
73    */

74   public static void setExtensibilityEnabled(boolean enable) {
75     extensibilityEnabled = enable;
76   }
77
78   /**
79    * Tests if the extensibility feature is enabled.
80    * @return
81    * if <code>true</code> the extensibility is enabled otherwise it is
82    * disabled. In the latter case, SNMP4J's default configuration will
83    * be used with all available features.
84    */

85   public final static boolean isExtensibilityEnabled() {
86     return extensibilityEnabled;
87   }
88
89   /**
90    * Enables or disables runtime exception forwarding.
91    * @see #forwardRuntimeExceptions
92    * @param forwardExceptions
93    * <code>true</code> runtime exceptions are thrown on thread boundaries
94    * controlled by SNMP4J and related APIs. Default is <code>false</code>.
95    * @since 1.8.1
96    */

97   public static void setForwardRuntimeExceptions(boolean forwardExceptions) {
98     forwardRuntimeExceptions = forwardExceptions;
99   }
100
101   /**
102    * Indicates whether runtime exceptions should be thrown on thread boundaries
103    * controlled by SNMP4J and related APIs.
104    * @return
105    * <code>true</code> runtime exceptions are thrown on thread boundaries
106    * controlled by SNMP4J and related APIs. Default is <code>false</code>.
107    * @since 1.8.1
108    */

109   public final static boolean isFowardRuntimeExceptions() {
110     return forwardRuntimeExceptions;
111   }
112 }
113
Popular Tags