@Test public void shouldRegisterProviderAndAddToHandler() throws IOException { DataProviderManager mgr = new DataProviderManager(taskTriggerHandler, taskDataProviderService); TaskDataProvider provider = new TaskDataProvider(); provider.setId(TASK_DATA_PROVIDER_ID); String json = String.format("{ name: '%s', objects: []", TASK_DATA_PROVIDER_NAME); when(dataProvider.toJSON()).thenReturn(json); mgr.bind(dataProvider, null); verify(taskDataProviderService).registerProvider(json); verify(taskTriggerHandler).addDataProvider(dataProvider); }
@Override public void bind(Object service, Map serviceProperties) { try { if (service instanceof DataProvider) { DataProvider provider = (DataProvider) service; taskDataProviderService.registerProvider(provider.toJSON()); if (handler != null) { handler.addDataProvider(provider); } LOGGER.info(String.format("Added data provider: %s", provider.getName())); } } catch (RuntimeException e) { LOGGER.error("Unable to add the data provider: {}", service, e); } }
DataProviderManager implements OsgiServiceLifecycleListener { @Override public void bind(Object service, Map serviceProperties) { try { if (service instanceof DataProvider) { DataProvider provider = (DataProvider) service; taskDataProviderService.registerProvider(provider.toJSON()); if (handler != null) { handler.addDataProvider(provider); } LOGGER.info(String.format("Added data provider: %s", provider.getName())); } } catch (RuntimeException e) { LOGGER.error("Unable to add the data provider: {}", service, e); } } }
DataProviderManager implements OsgiServiceLifecycleListener { @Override public void bind(Object service, Map serviceProperties) { try { if (service instanceof DataProvider) { DataProvider provider = (DataProvider) service; taskDataProviderService.registerProvider(provider.toJSON()); if (handler != null) { handler.addDataProvider(provider); } LOGGER.info(String.format("Added data provider: %s", provider.getName())); } } catch (RuntimeException e) { LOGGER.error("Unable to add the data provider: {}", service, e); } } DataProviderManager(TaskDataProviderService taskDataProviderService); @Autowired  DataProviderManager(TriggerHandler handler, TaskDataProviderService taskDataProviderService); }
DataProviderManager implements OsgiServiceLifecycleListener { @Override public void bind(Object service, Map serviceProperties) { try { if (service instanceof DataProvider) { DataProvider provider = (DataProvider) service; taskDataProviderService.registerProvider(provider.toJSON()); if (handler != null) { handler.addDataProvider(provider); } LOGGER.info(String.format("Added data provider: %s", provider.getName())); } } catch (RuntimeException e) { LOGGER.error("Unable to add the data provider: {}", service, e); } } DataProviderManager(TaskDataProviderService taskDataProviderService); @Autowired  DataProviderManager(TriggerHandler handler, TaskDataProviderService taskDataProviderService); @Override void bind(Object service, Map serviceProperties); @Override void unbind(Object service, Map serviceProperties); }
DataProviderManager implements OsgiServiceLifecycleListener { @Override public void bind(Object service, Map serviceProperties) { try { if (service instanceof DataProvider) { DataProvider provider = (DataProvider) service; taskDataProviderService.registerProvider(provider.toJSON()); if (handler != null) { handler.addDataProvider(provider); } LOGGER.info(String.format("Added data provider: %s", provider.getName())); } } catch (RuntimeException e) { LOGGER.error("Unable to add the data provider: {}", service, e); } } DataProviderManager(TaskDataProviderService taskDataProviderService); @Autowired  DataProviderManager(TriggerHandler handler, TaskDataProviderService taskDataProviderService); @Override void bind(Object service, Map serviceProperties); @Override void unbind(Object service, Map serviceProperties);  }