/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import static com.google.common.base.Preconditions.checkState;
import java.io.Closeable;
-
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.manager.testingservices.seviceinterface.ModifiableThreadPoolServiceInterface;
import org.opendaylight.controller.config.spi.Module;
private int threadCount = 0;
private boolean triggerNewInstanceCreation;
- TestingFixedThreadPoolModule(ModuleIdentifier name,
- @Nullable AutoCloseable oldCloseable,
- @Nullable TestingFixedThreadPool oldInstance) {
+ TestingFixedThreadPoolModule(final ModuleIdentifier name,
+ @Nullable final AutoCloseable oldCloseable,
+ @Nullable final TestingFixedThreadPool oldInstance) {
this.name = name;
this.oldCloseable = oldCloseable;
this.oldInstance = oldInstance;
}
- @Override
- public ModuleIdentifier getName() {
- return name;
- }
-
// attributes
@Override
- public void setThreadCount(int threadCount) {
+ public void setThreadCount(final int threadCount) {
this.threadCount = threadCount;
}
}
@Override
- public void setTriggerNewInstanceCreation(boolean triggerNewInstanceCreation) {
+ public void setTriggerNewInstanceCreation(final boolean triggerNewInstanceCreation) {
this.triggerNewInstanceCreation = triggerNewInstanceCreation;
}
}
@Override
+ public boolean canReuse(final Module oldModule) {
+ return isReusable() && triggerNewInstanceCreation == false;
+ }
+
+ @Override
+ @SuppressWarnings("IllegalCatch")
public Closeable getInstance() {
if (instance == null) {
if (isReusable() && triggerNewInstanceCreation == false) { // simulate
if (oldCloseable != null) {
try {
oldCloseable.close();
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new RuntimeException(e);
}
}
return instance;
}
+ @Override
+ public ModuleIdentifier getIdentifier() {
+ return name;
+ }
+
}