214 Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME,true,null); |
214 Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME,true,null); |
215 final Method initializeMethod = |
215 final Method initializeMethod = |
216 adaptorClass.getMethod("initialize", |
216 adaptorClass.getMethod("initialize", |
217 String.class, Properties.class); |
217 String.class, Properties.class); |
218 initializeMethod.invoke(null,snmpPort,props); |
218 initializeMethod.invoke(null,snmpPort,props); |
219 } catch (ClassNotFoundException x) { |
219 } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException x) { |
220 // The SNMP packages are not present: throws an exception. |
220 // snmp runtime doesn't exist - initialization fails |
221 throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); |
|
222 } catch (NoSuchMethodException x) { |
|
223 // should not happen... |
|
224 throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); |
221 throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); |
225 } catch (InvocationTargetException x) { |
222 } catch (InvocationTargetException x) { |
226 final Throwable cause = x.getCause(); |
223 final Throwable cause = x.getCause(); |
227 if (cause instanceof RuntimeException) |
224 if (cause instanceof RuntimeException) |
228 throw (RuntimeException) cause; |
225 throw (RuntimeException) cause; |
229 else if (cause instanceof Error) |
226 else if (cause instanceof Error) |
230 throw (Error) cause; |
227 throw (Error) cause; |
231 // should not happen... |
228 // should not happen... |
232 throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,cause); |
229 throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,cause); |
233 } catch (IllegalAccessException x) { |
|
234 // should not happen... |
|
235 throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); |
|
236 } |
230 } |
237 } |
231 } |
238 |
232 |
239 // read config file and initialize the properties |
233 // read config file and initialize the properties |
240 private static void readConfiguration(String fname, Properties p) { |
234 private static void readConfiguration(String fname, Properties p) { |
307 try { |
301 try { |
308 // Instantiate the named class. |
302 // Instantiate the named class. |
309 // invoke the premain(String args) method |
303 // invoke the premain(String args) method |
310 Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname); |
304 Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname); |
311 Method premain = clz.getMethod("premain", |
305 Method premain = clz.getMethod("premain", |
312 new Class[] { String.class }); |
306 new Class<?>[] { String.class }); |
313 premain.invoke(null, /* static */ |
307 premain.invoke(null, /* static */ |
314 new Object[] { args }); |
308 new Object[] { args }); |
315 } catch (ClassNotFoundException ex) { |
309 } catch (ClassNotFoundException ex) { |
316 error(AGENT_CLASS_NOT_FOUND, "\"" + cname + "\""); |
310 error(AGENT_CLASS_NOT_FOUND, "\"" + cname + "\""); |
317 } catch (NoSuchMethodException ex) { |
311 } catch (NoSuchMethodException ex) { |