2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.bgpcep.config.loader.impl;
10 import com.google.common.annotations.Beta;
12 import java.nio.file.WatchKey;
13 import java.nio.file.WatchService;
14 import javax.annotation.PostConstruct;
15 import javax.annotation.PreDestroy;
16 import javax.inject.Inject;
17 import javax.inject.Singleton;
18 import org.eclipse.jdt.annotation.NonNull;
19 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
23 public final class SimpleConfigLoader extends AbstractWatchingConfigLoader implements AutoCloseable {
24 private final @NonNull WatchService watchService;
25 private final @NonNull File directory;
28 public SimpleConfigLoader(final FileWatcher fileWatcher, final BindingRuntimeContext runtimeContext) {
29 updateModelContext(runtimeContext.modelContext());
30 watchService = fileWatcher.getWatchService();
31 directory = new File(fileWatcher.getPathFile());
51 WatchKey takeEvent() throws InterruptedException {
52 return watchService.take();