@SuppressWarnings("rawtypes") @Override public void updated(Dictionary settings) throws ConfigurationException { // Handle the update in the component executor thread. Any exception thrown during the component updated callback will be // synchronously awaited and re-thrown to the CM thread. // We schedule the update in the component executor in order to avoid race conditions, // like when the component is stopping while we receive a configuration update, or if the component restarts // while the configuration is being updated, or if the getProperties method is invoked while we are losing the configuration ... // there are many racy situations, and the safe way to handle them is to schedule the updated callback in the component executor. InvocationUtil.invokeUpdated(m_component.getExecutor(), () -> doUpdated(settings)); }
@SuppressWarnings("rawtypes") public void updated(String pid, Dictionary properties) throws ConfigurationException { // FELIX-5193: invoke the updated callback in the internal decorator component queue, in order // to safely detect if the component is still active or not. InvocationUtil.invokeUpdated(m_decoratorComponent.getExecutor(), () -> updatedSafe(pid, properties)); }
private ConfigurationDependencyImpl createConfigurationDependency(Object service) { BundleContext bc = mock(BundleContext.class); Logger mockLogger = mock(Logger.class); ComponentContext component = mock(ComponentContext.class); when(component.getExecutor()).thenReturn(Executors.newSingleThreadExecutor()); when(component.getLogger()).thenReturn(mockLogger); ConfigurationDependencyImpl result = new ConfigurationDependencyImpl(bc, mockLogger); result.setCallback(service, "updated").setPid("does.not.matter"); result.setComponentContext(component); result.start(); return result; }