import static org.junit.Assert.assertNull;
import java.io.Closeable;
-
import javax.annotation.Nullable;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator;
private RootRuntimeBeanRegistrator runtimeBeanRegistrator;
private boolean recreate;
- public TestingScheduledThreadPoolModule(ModuleIdentifier identifier,
- @Nullable AutoCloseable oldCloseable,
- @Nullable TestingScheduledThreadPoolImpl oldInstance) {
+ public TestingScheduledThreadPoolModule(final ModuleIdentifier identifier,
+ @Nullable final AutoCloseable oldCloseable,
+ @Nullable final TestingScheduledThreadPoolImpl oldInstance) {
this.identifier = identifier;
this.oldCloseable = oldCloseable;
this.oldInstance = oldInstance;
@Override
public void setRuntimeBeanRegistrator(
- RootRuntimeBeanRegistrator runtimeBeanRegistrator) {
+ final RootRuntimeBeanRegistrator runtimeBeanRegistrator) {
this.runtimeBeanRegistrator = runtimeBeanRegistrator;
}
"Parameter 'ThreadCount' must be greater than 0");
}
+ @Override
+ public boolean canReuse(final Module oldModule) {
+ return getClass().isInstance(oldModule) && getThreadCount() ==
+ ((TestingScheduledThreadPoolModule) oldModule).getThreadCount();
+ }
+
@Override
public int getThreadCount() {
return threadCount;
}
@Override
- public void setThreadCount(int threadCount) {
+ public void setThreadCount(final int threadCount) {
this.threadCount = threadCount;
}
if (oldCloseable != null) {
try {
oldCloseable.close();
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new RuntimeException(e);
}
}
}
@Override
- public void setRecreate(boolean recreate) {
+ public void setRecreate(final boolean recreate) {
this.recreate = recreate;
}