use of org.opennms.netmgt.config.service.Service in project opennms by OpenNMS.
the class InvokerTest method invokeMethods.
private static void invokeMethods(Invoker invoker) throws Throwable {
for (InvokerService iservice : invoker.getServices()) {
Service service = iservice.getService();
ObjectName name = new ObjectName(service.getName());
System.err.println("object instance = " + getObjectInstanceString(invoker.getServer().getObjectInstance(name)));
}
List<InvokerResult> results = invoker.invokeMethods();
System.err.println(invoker.getAtType().toString() + ": got " + results.size() + " results");
for (InvokerResult result : results) {
System.err.println(invoker.getAtType().toString() + ": result = " + getResultString(result));
if (result.getThrowable() != null) {
throw result.getThrowable();
}
}
}
use of org.opennms.netmgt.config.service.Service in project opennms by OpenNMS.
the class Starter method start.
private void start() {
LOG.debug("Beginning startup");
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
Invoker invoker = new Invoker();
invoker.setServer(server);
invoker.setAtType(InvokeAtType.START);
List<InvokerService> services = InvokerService.createServiceList(new ServiceConfigFactory().getServices());
invoker.setServices(services);
invoker.instantiateClasses();
List<InvokerResult> resultInfo = invoker.invokeMethods();
for (InvokerResult result : resultInfo) {
if (result != null && result.getThrowable() != null) {
Service service = result.getService();
String name = service.getName();
String className = service.getClassName();
String message = "An error occurred while attempting to start the \"" + name + "\" service (class " + className + "). " + "Shutting down and exiting.";
LOG.error(message, result.getThrowable());
System.err.println(message);
result.getThrowable().printStackTrace();
Manager manager = new Manager();
manager.stop();
manager.doSystemExit();
// Shouldn't get here
return;
}
}
LOG.debug("Startup complete");
}
Aggregations