Search in sources :

Example 6 with ServiceRegistry

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);
}
Also used : ServiceRegistry(org.opennms.core.soa.ServiceRegistry) InMemoryGraphmlRepository(org.opennms.features.graphml.service.InMemoryGraphmlRepository)

Example 7 with ServiceRegistry

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();
}
Also used : ServiceRegistry(org.opennms.core.soa.ServiceRegistry)

Aggregations

ServiceRegistry (org.opennms.core.soa.ServiceRegistry)7 Test (org.junit.Test)4 Registration (org.opennms.core.soa.Registration)3 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletException (javax.servlet.ServletException)1 HttpSession (javax.servlet.http.HttpSession)1 ServiceRegistryHttpInvokerServiceExporter (org.opennms.core.spring.web.ServiceRegistryHttpInvokerServiceExporter)1 InMemoryGraphmlRepository (org.opennms.features.graphml.service.InMemoryGraphmlRepository)1 DiscoveryConfiguration (org.opennms.netmgt.config.discovery.DiscoveryConfiguration)1 ExcludeRange (org.opennms.netmgt.config.discovery.ExcludeRange)1 IncludeRange (org.opennms.netmgt.config.discovery.IncludeRange)1 IncludeUrl (org.opennms.netmgt.config.discovery.IncludeUrl)1 Specific (org.opennms.netmgt.config.discovery.Specific)1 DiscoveryTaskExecutor (org.opennms.netmgt.discovery.DiscoveryTaskExecutor)1