use of org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory in project netconf by opendaylight.
the class AggregatedNetconfOperationServiceFactory method registerCapabilityListener.
@Override
public synchronized AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
final Map<NetconfOperationServiceFactory, AutoCloseable> regs = new HashMap<>();
for (final NetconfOperationServiceFactory factory : factories) {
final AutoCloseable reg = factory.registerCapabilityListener(listener);
regs.put(factory, reg);
}
listeners.add(listener);
return () -> {
synchronized (AggregatedNetconfOperationServiceFactory.this) {
listeners.remove(listener);
CloseableUtil.closeAll(regs.values());
for (final Map.Entry<NetconfOperationServiceFactory, AutoCloseable> reg : regs.entrySet()) {
registrations.remove(reg.getKey(), reg.getValue());
}
}
};
}
use of org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory in project netconf by opendaylight.
the class NetconfDeviceSimulator method createDispatcher.
private NetconfServerDispatcherImpl createDispatcher(final Set<Capability> capabilities, final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
final Set<Capability> transformedCapabilities = new HashSet<>(Collections2.transform(capabilities, input -> {
if (sendFakeSchema) {
sendFakeSchema = false;
return new FakeCapability((YangModuleCapability) input);
} else {
return input;
}
}));
transformedCapabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
final NetconfMonitoringService monitoringService1 = new DummyMonitoringService(transformedCapabilities);
final SessionIdProvider idProvider = new SessionIdProvider();
final NetconfOperationServiceFactory aggregatedNetconfOperationServiceFactory = createOperationServiceFactory(sourceProvider, transformedCapabilities, monitoringService1, idProvider);
final Set<String> serverCapabilities = configuration.getCapabilities();
final NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new TesttoolNegotiationFactory(hashedWheelTimer, aggregatedNetconfOperationServiceFactory, idProvider, configuration.getGenerateConfigsTimeout(), monitoringService1, serverCapabilities);
final ServerChannelInitializer serverChannelInitializer = new ServerChannelInitializer(serverNegotiatorFactory);
return new NetconfServerDispatcherImpl(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup);
}
use of org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory in project netconf by opendaylight.
the class NetconfDeviceSimulator method createOperationServiceFactory.
private NetconfOperationServiceFactory createOperationServiceFactory(final SchemaSourceProvider<YangTextSchemaSource> sourceProvider, final Set<Capability> transformedCapabilities, final NetconfMonitoringService monitoringService1, final SessionIdProvider idProvider) {
final AggregatedNetconfOperationServiceFactory aggregatedNetconfOperationServiceFactory = new AggregatedNetconfOperationServiceFactory();
final NetconfOperationServiceFactory operationProvider;
if (configuration.isMdSal()) {
LOG.info("using MdsalOperationProvider.");
operationProvider = new MdsalOperationProvider(idProvider, transformedCapabilities, schemaContext, sourceProvider);
} else if (configuration.isXmlConfigurationProvided()) {
LOG.info("using SimulatedOperationProvider.");
operationProvider = new SimulatedOperationProvider(idProvider, transformedCapabilities, Optional.ofNullable(configuration.getNotificationFile()), Optional.ofNullable(configuration.getInitialConfigXMLFile()));
} else {
LOG.info("using OperationsProvider.");
operationProvider = new OperationsProvider(idProvider, transformedCapabilities, configuration.getOperationsCreator() != null ? configuration.getOperationsCreator() : DefaultOperationsCreator.getDefaultOperationServiceCreator(idProvider.getCurrentSessionId()));
}
final NetconfMonitoringOperationServiceFactory monitoringService = new NetconfMonitoringOperationServiceFactory(new NetconfMonitoringOperationService(monitoringService1));
aggregatedNetconfOperationServiceFactory.onAddNetconfOperationServiceFactory(operationProvider);
aggregatedNetconfOperationServiceFactory.onAddNetconfOperationServiceFactory(monitoringService);
if (configuration.getRpcConfigFile() != null) {
final SettableOperationProvider settableService = new SettableOperationProvider(configuration.getRpcConfigFile());
aggregatedNetconfOperationServiceFactory.onAddNetconfOperationServiceFactory(settableService);
} else {
final SettableOperationRpcProvider settableService = new SettableOperationRpcProvider(configuration.getRpcHandler());
aggregatedNetconfOperationServiceFactory.onAddNetconfOperationServiceFactory(settableService);
}
return aggregatedNetconfOperationServiceFactory;
}
Aggregations