final MonitoringToMdsalWriter monitoringToMdsalWriter = new MonitoringToMdsalWriter(serverMonitoringDependency);
getBindingAwareBrokerDependency().registerProvider(monitoringToMdsalWriter);
- final MdSalMonitoringMapperFactory mdSalMonitoringMapperFactory = new MdSalMonitoringMapperFactory(new MdsalMonitoringMapper(serverMonitoringDependency)) {
- @Override
- public void close() {
- super.close();
- monitoringToMdsalWriter.close();
- getAggregatorDependency().onRemoveNetconfOperationServiceFactory(this);
- }
- };
+ final MdSalMonitoringMapperFactory mdSalMonitoringMapperFactory = new MdSalMonitoringMapperFactory(new MdsalMonitoringMapper(serverMonitoringDependency),
+ this, monitoringToMdsalWriter);
getAggregatorDependency().onAddNetconfOperationServiceFactory(mdSalMonitoringMapperFactory);
return mdSalMonitoringMapperFactory;
}
- // FIXME almost exactly same code as in netconf-monitoring, refactor
private static class MdSalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
private final NetconfOperationService operationService;
+ private final NetconfMdsalMonitoringMapperModule module;
+ private final MonitoringToMdsalWriter monitoringToMdsalWriter;
+ private static final Set<Capability> CAPABILITIES = Collections.emptySet();
private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
@Override
public void close() throws Exception {
}
};
- public MdSalMonitoringMapperFactory(final NetconfOperationService operationService) {
+ public MdSalMonitoringMapperFactory(
+ final NetconfOperationService operationService,
+ final NetconfMdsalMonitoringMapperModule module,
+ final MonitoringToMdsalWriter monitoringToMdsalWriter
+ ) {
this.operationService = operationService;
+ this.module = module;
+ this.monitoringToMdsalWriter = monitoringToMdsalWriter;
}
@Override
// TODO
// No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the schemas)
// If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring related models
- return Collections.emptySet();
+ return CAPABILITIES;
}
@Override
}
@Override
- public void close() {}
+ public void close() {
+ monitoringToMdsalWriter.close();
+ module.getAggregatorDependency().onRemoveNetconfOperationServiceFactory(this);
+ }
+
}
+++ /dev/null
-/*
- * Copyright (c) 2015 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.monitoring;
-
-import com.google.common.collect.Sets;
-import java.util.Set;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-
-public class NetconfMonitoringOperationService implements NetconfOperationService {
-
- private final NetconfMonitoringService monitor;
-
- public NetconfMonitoringOperationService(final NetconfMonitoringService monitor) {
- this.monitor = monitor;
- }
-
- @Override
- public Set<NetconfOperation> getNetconfOperations() {
- return Sets.<NetconfOperation>newHashSet(new Get(monitor), new GetSchema(monitor));
- }
-
- @Override
- public void close() {
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.monitoring;
-
-import java.util.Collections;
-import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-
-public class NetconfMonitoringOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
-
- private final NetconfMonitoringOperationService operationService;
-
- private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
- @Override
- public void close() throws Exception {
- // NOOP
- }
- };
-
- public NetconfMonitoringOperationServiceFactory(final NetconfMonitoringOperationService operationService) {
- this.operationService = operationService;
- }
-
- @Override
- public NetconfOperationService createService(final String netconfSessionIdForReporting) {
- return operationService;
- }
-
- @Override
- public Set<Capability> getCapabilities() {
- // TODO
- // No capabilities exposed to prevent clashes with schemas from config-netconf-connector (it exposes all the schemas)
- // If the schemas exposed by config-netconf-connector are filtered, this class would expose monitoring related models
- return Collections.emptySet();
- }
-
- @Override
- public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- return AUTO_CLOSEABLE;
- }
-
- @Override
- public void close() {}
-}