@Override
 public Set<Capability> getCapabilities() {
   final HashSet<Capability> capabilities = Sets.newHashSet();
   for (final NetconfOperationServiceFactory factory : factories) {
     capabilities.addAll(factory.getCapabilities());
   }
   return capabilities;
 }
 public AggregatedNetconfOperation(
     final Set<NetconfOperationServiceFactory> factories,
     final String netconfSessionIdForReporting) {
   final Builder<NetconfOperationService> b = ImmutableSet.builder();
   for (final NetconfOperationServiceFactory factory : factories) {
     b.add(factory.createService(netconfSessionIdForReporting));
   }
   this.services = b.build();
 }
  @Override
  public synchronized void onAddNetconfOperationServiceFactory(
      NetconfOperationServiceFactory service) {
    factories.add(service);

    for (final CapabilityListener listener : listeners) {
      AutoCloseable reg = service.registerCapabilityListener(listener);
      registrations.put(service, reg);
    }
  }
  @Override
  public synchronized AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
    final Map<NetconfOperationServiceFactory, AutoCloseable> regs = Maps.newHashMap();

    for (final NetconfOperationServiceFactory factory : factories) {
      final AutoCloseable reg = factory.registerCapabilityListener(listener);
      regs.put(factory, reg);
    }
    listeners.add(listener);

    return new AutoCloseable() {
      @Override
      public void close() throws Exception {
        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());
          }
        }
      }
    };
  }