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 static com.google.common.base.Verify.verifyNotNull;
12 import com.google.common.annotations.Beta;
14 import java.nio.file.WatchKey;
15 import org.opendaylight.bgpcep.config.loader.spi.ConfigLoader;
16 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
17 import org.osgi.service.component.annotations.Activate;
18 import org.osgi.service.component.annotations.Component;
19 import org.osgi.service.component.annotations.Deactivate;
20 import org.osgi.service.component.annotations.Reference;
21 import org.osgi.service.component.annotations.ReferencePolicy;
24 @Component(immediate = true, service = ConfigLoader.class)
25 public final class OSGiConfigLoader extends AbstractWatchingConfigLoader {
29 private File directory;
31 @Reference(policy = ReferencePolicy.DYNAMIC, updated = "setRuntimeContext", unbind = "setRuntimeContext")
32 void setRuntimeContext(final BindingRuntimeContext runtimeContext) {
33 updateModelContext(runtimeContext.getEffectiveModelContext());
38 directory = new File(watcher.getPathFile());
53 return verifyNotNull(directory);
57 WatchKey takeEvent() throws InterruptedException {
58 return watcher.getWatchService().take();