*/
package org.opendaylight.netconf.client;
+import static java.util.Objects.requireNonNull;
+
import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import io.netty.util.concurrent.Future;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
import org.opendaylight.netconf.nettyutil.AbstractNetconfDispatcher;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Singleton
+@Component(immediate = true, service = NetconfClientDispatcher.class, property = "type=netconf-client-dispatcher")
public class NetconfClientDispatcherImpl
extends AbstractNetconfDispatcher<NetconfClientSession, NetconfClientSessionListener>
implements NetconfClientDispatcher {
-
private static final Logger LOG = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class);
private final Timer timer;
- public NetconfClientDispatcherImpl(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup,
- final Timer timer) {
+ @Inject
+ @Activate
+ public NetconfClientDispatcherImpl(@Reference(target = "(type=global-boss-group)") final EventLoopGroup bossGroup,
+ @Reference(target = "(type=global-worker-group)") final EventLoopGroup workerGroup,
+ @Reference(target = "(type=global-timer)") final Timer timer) {
super(bossGroup, workerGroup);
- this.timer = timer;
+ this.timer = requireNonNull(timer);
}
- protected Timer getTimer() {
+ protected final Timer getTimer() {
return timer;
}
if (odlHelloCapabilities == null || odlHelloCapabilities.isEmpty()) {
return new NetconfClientSessionNegotiatorFactory(timer, cfg.getAdditionalHeader(),
cfg.getConnectionTimeoutMillis());
- } else {
- // LinkedHashSet since perhaps the device cares about order of hello message capabilities.
- // This allows user control of the order while complying with the existing interface.
- final Set<String> stringCapabilities = new LinkedHashSet<>();
- for (final Uri uri : odlHelloCapabilities) {
- stringCapabilities.add(uri.getValue());
- }
- return new NetconfClientSessionNegotiatorFactory(timer, cfg.getAdditionalHeader(),
- cfg.getConnectionTimeoutMillis(), stringCapabilities);
}
+
+ // LinkedHashSet since perhaps the device cares about order of hello message capabilities.
+ // This allows user control of the order while complying with the existing interface.
+ final Set<String> stringCapabilities = new LinkedHashSet<>();
+ for (final Uri uri : odlHelloCapabilities) {
+ stringCapabilities.add(uri.getValue());
+ }
+ return new NetconfClientSessionNegotiatorFactory(timer, cfg.getAdditionalHeader(),
+ cfg.getConnectionTimeoutMillis(), stringCapabilities);
}
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2016 Inocybe Technologies Inc. and others. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="globalBossGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-boss-group"/>
- <reference id="globalWorkerGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-worker-group"/>
- <reference id="timer" interface="io.netty.util.Timer" odl:type="global-timer"/>
-
- <bean id="netconfClientDispatcherImpl"
- class="org.opendaylight.netconf.client.NetconfClientDispatcherImpl">
- <argument ref="globalBossGroup"/>
- <argument ref="globalWorkerGroup"/>
- <argument ref="timer"/>
- </bean>
- <service ref="netconfClientDispatcherImpl"
- interface="org.opendaylight.netconf.client.NetconfClientDispatcher"
- odl:type="netconf-client-dispatcher">
- <service-properties>
- <entry key="config-module-namespace" value="urn:opendaylight:params:xml:ns:yang:controller:config:netconf"/>
- <entry key="config-module-name" value="netconf-client-dispatcher"/>
- <entry key="config-instance-name" value="global-netconf-dispatcher"/>
- </service-properties>
- </service>
-
-</blueprint>
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GlobalEventExecutor;
import io.netty.util.concurrent.Promise;
-import java.io.Closeable;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.opendaylight.netconf.api.NetconfSession;
* start method that will handle sockets in different thread.
*/
@Deprecated
-public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L extends NetconfSessionListener<? super S>>
- implements Closeable {
-
+public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L extends NetconfSessionListener<? super S>> {
protected interface ChannelPipelineInitializer<C extends Channel, S extends NetconfSession> {
/**
* Initializes channel by specifying the handlers in its pipeline. Handlers are protocol specific, therefore
}
-
private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfDispatcher.class);
private final EventLoopGroup bossGroup;
bootstrap.group(workerGroup);
}
}
-
- @Deprecated
- @Override
- public void close() {
- }
}