use of org.opennms.core.soa.ServiceRegistry in project opennms by OpenNMS.
the class GraphMLRestServiceIT method afterServletStart.
@Override
protected void afterServletStart() throws Exception {
MockLogAppender.setupLogging(true, "DEBUG");
System.setProperty("opennms.home", "target/" + getClass().getSimpleName().toLowerCase());
// Register dummy graphml repository
final ServiceRegistry serviceRegistry = BeanUtils.getBean("soaContext", "serviceRegistry", ServiceRegistry.class);
serviceRegistry.register(new InMemoryGraphmlRepository(), GraphmlRepository.class);
}
use of org.opennms.core.soa.ServiceRegistry in project opennms by OpenNMS.
the class HtmlInjectHandler method inject.
public static String inject(final HttpServletRequest request) {
// Fetch the serviceRegistry bean on the first call and cache it since
// the reference won't change until the JVM is restarted
ServiceRegistry serviceRegistry = serviceRegistryRef.updateAndGet(ref -> {
if (ref == null) {
return BeanUtils.getBean("soaContext", "serviceRegistry", ServiceRegistry.class);
} else {
return ref;
}
});
// Iterate over all the Injector implementations published in the registry
// and concatenate their results
final StringBuilder sb = new StringBuilder();
sb.append("<!-- Begin injected -->");
for (HtmlInjector injector : serviceRegistry.findProviders(HtmlInjector.class)) {
try {
final String content = injector.inject(request);
if (content != null) {
sb.append(content);
}
} catch (Throwable t) {
LOG.warn("Injector {} failed.", injector, t);
}
}
sb.append("<!-- End injected -->\n");
return sb.toString();
}
Aggregations