public Invoke(final InvokeAtType type, final Integer pass, final String method, final List<Argument> arguments) { setAt(type); setPass(pass); setMethod(method); setArguments(arguments); }
ServiceConfiguration currentCfg = JaxbUtils.unmarshal(ServiceConfiguration.class, configFile); 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()); currentCfg.getServices().add(index, baseSvc); continue; 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); String prefix = a.getValue().getContent().toLowerCase(); if (!a.getValue().getContent().equals(prefix)) {
org.opennms.netmgt.config.service.Attribute[] attribs = service.getAttribute(); if (attrib.getName().equals("AuthenticationMethod")) { if (!attrib.getValue().getContent().equals("basic")) { LogUtils.errorf(this, "AuthenticationMethod is \"%s\", but only \"basic\" is supported", attrib.getValue()); return null; Invoke[] invokes = service.getInvoke(); if (invokes == null) { String password = null; for (Invoke invoke : invokes) { if (invoke.getMethod().equals("addAuthorization")) { Argument[] args = invoke.getArgument(); if (args != null && args.length == 2 && args[0].getContent().equals("manager")) { username = args[0].getContent(); password = args[1].getContent(); break;
private Attribute getAttribute(org.opennms.netmgt.config.service.Attribute attrib) throws Exception { Class<?> attribClass = Class.forName(attrib.getValue().getType()); Constructor<?> construct = attribClass.getConstructor(new Class[] { String.class }); Object value; String log4jPrefix = ThreadCategory.getPrefix(); try { value = construct.newInstance(new Object[] { attrib.getValue().getContent() }); } finally { ThreadCategory.setPrefix(log4jPrefix); } return new Attribute(attrib.getName(), value); }
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; LOG.debug("pass {} on service {} will invoke method \"{}\"", pass, name, invoke.getMethod());
/** * 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; }
public Service(final String name, final String className, final List<Attribute> attributes, final List<Invoke> invokes) { setName(name); setClassName(className); setAttributes(attributes); setInvokes(invokes); }
/** * 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 Value(final String type, final String content) { setType(type); setContent(content); }
/** * 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; }
private Object getArgument(Argument arg) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> argClass = Class.forName(arg.getType()); Constructor<?> construct = argClass.getConstructor(new Class[] { String.class }); String log4jPrefix = ThreadCategory.getPrefix(); try { return construct.newInstance(new Object[] { arg.getContent() }); } finally { ThreadCategory.setPrefix(log4jPrefix); } }
private Object getArgument(Argument arg) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> argClass = Class.forName(arg.getType()); Constructor<?> construct = argClass.getConstructor(new Class[] { String.class }); Map<String,String> mdc = Logging.getCopyOfContextMap(); try { return construct.newInstance(new Object[] { arg.getValue().orElse(null) }); } finally { Logging.setContextMap(mdc); } }
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; }
public ServiceConfiguration(final List<Service> services) { setServices(services); }
private Attribute getAttribute(org.opennms.netmgt.config.service.Attribute attrib) throws Exception { Class<?> attribClass = Class.forName(attrib.getValue().getType()); Constructor<?> construct = attribClass.getConstructor(new Class[] { String.class }); Object value; Map<String,String> mdc = Logging.getCopyOfContextMap(); try { value = construct.newInstance(new Object[] { attrib.getValue().getContent() }); } finally { Logging.setContextMap(mdc); } return new Attribute(attrib.getName(), value); }
/** * 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; } }