import javax.management.ObjectName;
import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.annotations.RequireInterface;
import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
private final DependencyResolver dependencyResolver;
private final AutoCloseable oldCloseable;
private final TestingParallelAPSPImpl oldInstance;
- private final ModuleIdentifier name;
+ private final ModuleIdentifier identifier;
private ObjectName threadPoolON;
private TestingParallelAPSPImpl instance;
private String someParam;
- public TestingParallelAPSPModule(ModuleIdentifier name,
+ public TestingParallelAPSPModule(ModuleIdentifier identifier,
DependencyResolver dependencyResolver,
@Nullable AutoCloseable oldCloseable,
@Nullable TestingParallelAPSPImpl oldInstance) {
- this.name = name;
+ this.identifier = identifier;
this.dependencyResolver = dependencyResolver;
this.oldCloseable = oldCloseable;
this.oldInstance = oldInstance;
}
- @Override
- public ModuleIdentifier getName() {
- return name;
- }
-
@Override
public ObjectName getThreadPool() {
return threadPoolON;
return instance.getMaxNumberOfThreads();
}
+ // this would be generated:
+ private final JmxAttribute threadPoolONJMXAttribute = new JmxAttribute("threadPoolON");
+
@Override
public void validate() {
checkNotNull(threadPoolON, "Parameter 'threadPool' must be set");
dependencyResolver.validateDependency(
TestingThreadPoolServiceInterface.class, threadPoolON,
- "threadPoolON");
+ threadPoolONJMXAttribute);
checkState(Strings.isNullOrEmpty(someParam) == false,
"Parameter 'SomeParam' is blank");
// check that calling resolveInstance fails
try {
dependencyResolver.resolveInstance(TestingThreadPoolIfc.class,
- threadPoolON);
+ threadPoolON, threadPoolONJMXAttribute);
throw new RuntimeException("fail");
} catch (IllegalStateException e) {
checkState("Commit was not triggered".equals(e.getMessage()),
public Closeable getInstance() {
if (instance == null) {
TestingThreadPoolIfc threadPoolInstance = dependencyResolver
- .resolveInstance(TestingThreadPoolIfc.class, threadPoolON);
+ .resolveInstance(TestingThreadPoolIfc.class, threadPoolON, threadPoolONJMXAttribute);
if (oldInstance != null) {
// changing thread pool is not supported
- boolean reuse = threadPoolInstance.equals(oldInstance
- .getThreadPool());
+ boolean reuse = threadPoolInstance == oldInstance.getThreadPool();
if (reuse) {
logger.debug("Reusing old instance");
instance = oldInstance;
}
return instance;
}
+
+ @Override
+ public ModuleIdentifier getIdentifier() {
+ return identifier;
+ }
+
+
}