@Test public void test_register() { assertThat( () -> diagnosticServices.register(null, service1), is(throwing(instanceOf(NullPointerException.class)))); assertThat( () -> diagnosticServices.register(MyService1.class, null), is(throwing(instanceOf(NullPointerException.class)))); assertThat(diagnosticServices.register(MyService1.class, service1), is(instanceOf(DiagnosticServicesRegistration.class))); assertThat( () -> diagnosticServices.register(MyService1.class, service1), is(throwing(instanceOf(IllegalArgumentException.class)).andMessage(is(equalTo("Service org.terracotta.diagnostic.server.DefaultDiagnosticServicesTest$MyService1 is already registered"))))); assertThat(diagnosticServices.register(MyService2.class, service2), is(instanceOf(DiagnosticServicesRegistration.class))); }
@Override public <T> DiagnosticServicesRegistration<T> register(Class<T> serviceInterface, T serviceImplementation) { DiagnosticServiceDescriptor<T> added = handler.add( serviceInterface, serviceImplementation, () -> unregister(serviceInterface), name -> registerMBean(name, serviceInterface)); LOGGER.info("Registered Diagnostic Service: {}", serviceInterface.getName()); added.discoverMBeanName().ifPresent(name -> registerMBean(name, added)); fireOnService(serviceInterface, serviceImplementation); return added; }
DefaultDiagnosticServices implements DiagnosticServices, Closeable { @Override public <T> DiagnosticServicesRegistration<T> register(Class<T> serviceInterface, T serviceImplementation) { DiagnosticServiceDescriptor<T> added = handler.add( serviceInterface, serviceImplementation, () -> unregister(serviceInterface), name -> registerMBean(name, serviceInterface)); LOGGER.info("Registered Diagnostic Service: {}", serviceInterface.getName()); added.discoverMBeanName().ifPresent(name -> registerMBean(name, added)); fireOnService(serviceInterface, serviceImplementation); return added; } }
DefaultDiagnosticServices implements DiagnosticServices, Closeable { @Override public <T> DiagnosticServicesRegistration<T> register(Class<T> serviceInterface, T serviceImplementation) { DiagnosticServiceDescriptor<T> added = handler.add( serviceInterface, serviceImplementation, () -> unregister(serviceInterface), name -> registerMBean(name, serviceInterface)); LOGGER.info("Registered Diagnostic Service: {}", serviceInterface.getName()); added.discoverMBeanName().ifPresent(name -> registerMBean(name, added)); fireOnService(serviceInterface, serviceImplementation); return added; } DefaultDiagnosticServices(ObjectMapperFactory objectMapperFactory);  DefaultDiagnosticServices(DiagnosticCodec<String> codec); }
DefaultDiagnosticServices implements DiagnosticServices, Closeable { @Override public <T> DiagnosticServicesRegistration<T> register(Class<T> serviceInterface, T serviceImplementation) { DiagnosticServiceDescriptor<T> added = handler.add( serviceInterface, serviceImplementation, () -> unregister(serviceInterface), name -> registerMBean(name, serviceInterface)); LOGGER.info("Registered Diagnostic Service: {}", serviceInterface.getName()); added.discoverMBeanName().ifPresent(name -> registerMBean(name, added)); fireOnService(serviceInterface, serviceImplementation); return added; } DefaultDiagnosticServices(ObjectMapperFactory objectMapperFactory);  DefaultDiagnosticServices(DiagnosticCodec<String> codec); void init(); @Override void close(); @Override DiagnosticServicesRegistration<T> register(Class<T> serviceInterface, T serviceImplementation); @Override Collection<Class<?>> listServices(); @Override Optional<T> findService(Class<T> serviceInterface); @Override CompletionStage<T> onService(Class<T> serviceInterface); @Override void onService(Class<T> serviceInterface, Consumer<T> action); @Override void clear(); @Override void unregister(Class<T> serviceInterface); }
DefaultDiagnosticServices implements DiagnosticServices, Closeable { @Override public <T> DiagnosticServicesRegistration<T> register(Class<T> serviceInterface, T serviceImplementation) { DiagnosticServiceDescriptor<T> added = handler.add( serviceInterface, serviceImplementation, () -> unregister(serviceInterface), name -> registerMBean(name, serviceInterface)); LOGGER.info("Registered Diagnostic Service: {}", serviceInterface.getName()); added.discoverMBeanName().ifPresent(name -> registerMBean(name, added)); fireOnService(serviceInterface, serviceImplementation); return added; } DefaultDiagnosticServices(ObjectMapperFactory objectMapperFactory);  DefaultDiagnosticServices(DiagnosticCodec<String> codec); void init(); @Override void close(); @Override DiagnosticServicesRegistration<T> register(Class<T> serviceInterface, T serviceImplementation); @Override Collection<Class<?>> listServices(); @Override Optional<T> findService(Class<T> serviceInterface); @Override CompletionStage<T> onService(Class<T> serviceInterface); @Override void onService(Class<T> serviceInterface, Consumer<T> action); @Override void clear(); @Override void unregister(Class<T> serviceInterface);  }