import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO;
import org.opendaylight.netconf.sal.connect.netconf.NetconfDeviceBuilder;
-import org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemas.NetconfStateSchemasResolverImpl;
+import org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemasResolverImpl;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer;
/**
- * Manages connect/disconnect to 1 remote device
+ * Manages connect/disconnect to 1 remote device.
*/
public class NetconfDeviceConnectionManager implements Closeable {
// TODO we receive configBuilder in order to add SessionListener, Session
// Listener should not be part of config
- public synchronized void connect(final String name, final InetSocketAddress address, final NetconfClientConfigurationBuilder configBuilder) {
+ public synchronized void connect(final String name, final InetSocketAddress address,
+ final NetconfClientConfigurationBuilder configBuilder) {
// TODO change IllegalState exceptions to custom ConnectionException
Preconditions.checkState(listener == null, "Already connected");
console, name);
final SharedSchemaRepository repository = new SharedSchemaRepository("repo");
- final SchemaContextFactory schemaContextFactory = repository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
- final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(repository, YangTextSchemaSource.class, new File(CACHE));
+ final SchemaContextFactory schemaContextFactory = repository
+ .createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
+ final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(
+ repository, YangTextSchemaSource.class, new File(CACHE));
repository.registerSchemaSourceListener(cache);
repository.registerSchemaSourceListener(TextToASTTransformer.create(repository, repository));
- final SchemaResourcesDTO schemaResourcesDTO = new SchemaResourcesDTO(repository, schemaContextFactory, new NetconfStateSchemasResolverImpl());
+ final SchemaResourcesDTO schemaResourcesDTO = new SchemaResourcesDTO(
+ repository, repository, schemaContextFactory, new NetconfStateSchemasResolverImpl());
device = new NetconfDeviceBuilder()
.setReconnectOnSchemasChange(true)
}
/**
- * Blocks thread until connection is fully established
+ * Blocks thread until connection is fully established.
*/
- public synchronized Set<String> connectBlocking(final String name, final InetSocketAddress address, final NetconfClientConfigurationBuilder configBuilder) {
+ public synchronized Set<String> connectBlocking(final String name, final InetSocketAddress address,
+ final NetconfClientConfigurationBuilder configBuilder) {
this.connect(name, address, configBuilder);
synchronized (handler) {
- while (handler.isUp() == false) {
+ while (!handler.isUp()) {
try {
// TODO implement Timeout for unsuccessful connection
handler.wait();