/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class initializes and starts the SNMP Adaptor for JSR 163 SNMP
* Monitoring.
**/
public final class AdaptorBootstrap {
/**
* Default values for SNMP configuration properties.
**/
public static interface DefaultValues {
}
/**
* Names of SNMP configuration properties.
**/
public static interface PropertyNames {
"com.sun.management.config.file";
"com.sun.management.snmp.trap";
"com.sun.management.snmp.acl";
"com.sun.management.snmp.acl.file";
"com.sun.management.snmp.interface";
}
/**
* We keep a reference - so that we can possibly call
* terminate(). As of now, terminate() is only called by unit tests
* (makes it possible to run several testcases sequentially in the
* same JVM).
**/
}
/**
* Compute the full path name for a default file.
* @param basename basename (with extension) of the default file.
* @return ${JRE}/lib/management/${basename}
**/
}
/**
* Retrieve the Trap Target List from the ACL file.
**/
int defaultTrapPort) {
new ArrayList<NotificationTarget>();
for (; td.hasMoreElements() ;) {
final Enumeration tc =
for (;tc.hasMoreElements() ;) {
final NotificationTarget target =
}
}
}
return result;
}
/**
* Initializes and starts the SNMP Adaptor Server.
* If the com.sun.management.snmp.port property is not defined,
* simply return. Otherwise, attempts to load the config file, and
* then calls {@link #initialize(java.lang.String, java.util.Properties)}.
*
**/
// Load a new properties
}
/**
* Initializes and starts the SNMP Adaptor Server.
**/
public static synchronized
// Get port number
final int port;
try {
} catch (NumberFormatException x) {
}
if (port < 0) {
}
// Get trap port number
final String trapPortStr =
final int trapPort;
try {
} catch (NumberFormatException x) {
}
if (trapPort < 0) {
}
// Get bind address
// Get ACL File
final String defaultAclFileName =
final String aclFileName =
final boolean useAcl =
try {
} catch (Exception e) {
}
return adaptor;
}
final InetAddress address;
try {
} catch (UnknownHostException e) {
}
+ aclFileName):"\n\tNo ACL")+
""));
}
final InetAddressAcl acl;
try {
: null;
} catch (UnknownHostException e) {
}
// Create adaptor
final SnmpAdaptorServer adaptor =
// Create MIB
//
try {
} catch (IllegalAccessException x) {
}
// Configure the trap destinations.
//
// Start Adaptor
//
try {
// Will wait until the adaptor starts or fails to start.
// If the adaptor fails to start, a CommunicationException or
// an InterruptedException is thrown.
//
} catch (Exception x) {
Throwable t=x;
}
throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED, t,
}
// double check that adaptor is actually started (should always
// be active, so that exception should never be thrown from here)
//
throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED,
}
try {
// Add MIB to adaptor
//
// Add Adaptor to the MIB
//
} catch (RuntimeException x) {
throw x;
}
}
throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_SET);
}
}
}
try {
}
}
} catch (IOException e) {
}
}
/**
* Get the port on which the adaptor is bound.
* Returns 0 if the adaptor is already terminated.
*
**/
public synchronized int getPort() {
return 0;
}
/**
* Stops the adaptor server.
**/
public synchronized void terminate() {
// Terminate the MIB (deregister NotificationListener from
// MemoryMBean)
//
try {
} catch (Exception x) {
// Must not prevent to stop...
//
x.toString());
} finally {
}
// Stop the adaptor
//
try {
} finally {
}
}
}