/** * <p>getObjectInstances</p> */ public void getObjectInstances() { for (InvokerService invokerService : getServices()) { Service service = invokerService.getService(); try { // find the mbean LOG.debug("finding mbean instance {}", service.getName()); ObjectName name = new ObjectName(service.getName()); invokerService.setMbean(getServer().getObjectInstance(name)); } catch (Throwable t) { LOG.error("An error occurred loading the mbean {} of type {} it will be skipped", service.getName(), service.getClassName(), t); invokerService.setBadThrowable(t); } } }
/** * Gets the logging prefix. * * @param svc the OpenNMS service * @return the logging prefix attribute */ private static Attribute getLoggingPrefix(Service svc) { for (Attribute a : svc.getAttributes()) { if (a.getName().equals("LoggingPrefix")) { return a; } } return null; }
/** * Returns an array of all the defined configuration information for the * <em>Services</em>. If there are no defined services an array of length * zero is returned to the caller. * * @return An array holding a reference to all the Service configuration * instances. */ @Override public Service[] getServices() { final List<Service> services = new ArrayList<>(); for (Service s : m_config.getServices()) { if (s.isEnabled()) services.add(s); } return services.toArray(new Service[services.size()]); } }
public Service(final String name, final String className, final List<Attribute> attributes, final List<Invoke> invokes) { setName(name); setClassName(className); setAttributes(attributes); setInvokes(invokes); }
int index = 0; for (Service baseSvc : baseConfig.getServices()) { Service localSvc = getService(currentCfg, baseSvc.getName()); if (localSvc == null) { if (baseSvc.isEnabled()) { log("Adding new service %s\n", baseSvc.getName()); } else { log("Marking service %s as disabled\n", baseSvc.getName()); if (!baseSvc.isEnabled()) { log("Disabling service %s because it is not on the default list of enabled services\n", localSvc.getName()); localSvc.setEnabled(false); if (localSvc.getClassName().equals("org.opennms.netmgt.poller.jmx.RemotePollerBackEnd")) { log("Fixing the class path for RemotePollerBackEnd.\n"); localSvc.setClassName("org.opennms.netmgt.poller.remote.jmx.RemotePollerBackEnd"); if (localSvc.getName().equals("OpenNMS:Name=Linkd")) { log("Disabling Linkd (to promote EnhancedLinkd)\n"); localSvc.setEnabled(false); log("Fixing logging prefix for service %s\n", localSvc.getName()); a.getValue().setContent(prefix);
try { LOG.debug("loading class {}", service.getClassName()); Class<?> clazz = Class.forName(service.getClassName()); LOG.debug("create new instance of {}", service.getClassName()); LOG.debug("registering mbean instance {}", service.getName()); ObjectName name = new ObjectName(service.getName()); invokerService.setMbean(getServer().registerMBean(bean, name)); final List<org.opennms.netmgt.config.service.Attribute> attribs = service.getAttributes(); if (attribs != null) { for (final org.opennms.netmgt.config.service.Attribute attrib : attribs) { LOG.error("An error occurred loading the mbean {} of type {}", service.getName(), service.getClassName(), t); invokerService.setBadThrowable(t);
log().debug("loading class " + service.getClassName()); Class<?> clazz = Class.forName(service.getClassName()); + service.getClassName()); + service.getName()); ObjectName name = new ObjectName(service.getName()); invokerService.setMbean(getServer().registerMBean(bean, name)); service.getAttribute(); if (attribs != null) { for (org.opennms.netmgt.config.service.Attribute attrib : attribs) { + service.getName() + " of type " + service.getClassName() + ": " + t, t); invokerService.setBadThrowable(t);
/** * Gets the service. * * @param svcConfig the service configuration object * @param serviceName the service name * @return the service */ private static Service getService(ServiceConfiguration svcConfig, String serviceName) { for(Service s : svcConfig.getServices()) { if (s.getName().equals(serviceName)) { return s; } } return null; } }
continue; final String eolServiceName = eolService.getName(); if (eolServiceName.equals(serviceName)) { final String displayName = serviceName.replace("OpenNMS:Name=", ""); log("Disabling EOL service: " + displayName + "\n"); eolService.setEnabled(false);
String name = invokerService.getService().getName(); ObjectInstance mbean = invokerService.getMbean(); for (final Invoke invoke : invokerService.getService().getInvokes()) { if (invoke.getPass() != pass || !getAtType().equals(invoke.getAt())) { continue;
org.opennms.netmgt.config.service.Attribute[] attribs = service.getAttribute(); Invoke[] invokes = service.getInvoke(); if (invokes == null) {
/** * Get the last pass for a set of InvokerServices. * * @param invokerServices list to look at * @return highest pass value found for all Invoke objects in the * invokerServices list */ private int getLastPass() { List<InvokerService> invokerServices = getServices(); int end = 0; for (InvokerService invokerService : invokerServices) { Invoke[] invokes = invokerService.getService().getInvoke(); if (invokes == null) { continue; } for (Invoke invoke : invokes) { if (invoke.getPass() > end) { end = invoke.getPass(); } } } return end; }
/** * Get the last pass for a set of InvokerServices. * * @param invokerServices list to look at * @return highest pass value found for all Invoke objects in the * invokerServices list */ private int getLastPass() { List<InvokerService> invokerServices = getServices(); int end = 0; for (final InvokerService invokerService : invokerServices) { final List<Invoke> invokes = invokerService.getService().getInvokes(); if (invokes == null) { continue; } for (final Invoke invoke : invokes) { if (invoke.getPass() > end) { end = invoke.getPass(); } } } return end; }
/** * Gets the service. * * @param svcConfig the service configuration object * @param serviceName the service name * @return the service */ private static Service getService(ServiceConfiguration svcConfig, String serviceName) { for(Service s : svcConfig.getServices()) { if (s.getName().equals(serviceName)) { return s; } } return null; }
/** * <p>getObjectInstances</p> */ public void getObjectInstances() { for (InvokerService invokerService : getServices()) { Service service = invokerService.getService(); try { // find the mbean if (log().isDebugEnabled()) { log().debug("finding mbean instance " + service.getName()); } ObjectName name = new ObjectName(service.getName()); invokerService.setMbean(getServer().getObjectInstance(name)); } catch (Throwable t) { log().error("An error occurred loading the mbean " + service.getName() + " of type " + service.getClassName() + " it will be skipped", t); invokerService.setBadThrowable(t); } } }
private Service getConfiguredService(String serviceName) { ServiceConfigFactory sfact = getServiceConfigFactory(); Service[] services = sfact.getServices(); for (Service service : services) { if (service.getName().equals(serviceName)) { return service; } } return null; }
if (result != null && result.getThrowable() != null) { Service service = result.getService(); String name = service.getName(); String className = service.getClassName();
final String name = localSvc.getName(); if (oldServices.contains(name)) { log("Removing old service %s\n", name);
if (result != null && result.getThrowable() != null) { Service service = result.getService(); String name = service.getName(); String className = service.getClassName();