4 * Generated from: yang module name: openflow-switch-connection-provider-impl yang module local name: openflow-switch-connection-provider-impl
5 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6 * Generated at: Fri Mar 28 17:50:58 PDT 2014
8 * Do not modify this file unless it is present under src/main directory
10 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328;
12 import java.net.InetAddress;
13 import java.net.UnknownHostException;
15 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
16 import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
24 public final class SwitchConnectionProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModule
27 private static Logger LOG = LoggerFactory
28 .getLogger(SwitchConnectionProviderModule.class);
32 * @param dependencyResolver
34 public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
35 super(identifier, dependencyResolver);
40 * @param dependencyResolver
44 public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
45 SwitchConnectionProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
46 super(identifier, dependencyResolver, oldModule, oldInstance);
50 protected void customValidation(){
51 // Add custom validation for module attributes here.
55 public java.lang.AutoCloseable createInstance() {
56 LOG.info("SwitchConnectionProvider started.");
57 SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl();
59 ConnectionConfiguration connConfiguration = createConnectionConfiguration();
60 switchConnectionProviderImpl.setConfiguration(connConfiguration);
61 } catch (UnknownHostException e) {
62 throw new IllegalArgumentException(e.getMessage(), e);
64 return switchConnectionProviderImpl;
69 * @throws UnknownHostException
71 private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException {
72 final InetAddress address = extractIpAddressBin(getAddress());
73 final Integer port = getPort();
74 final long switchIdleTimeout = getSwitchIdleTimeout();
76 return new ConnectionConfiguration() {
78 public InetAddress getAddress() {
82 public int getPort() {
86 public Object getTransferProtocol() {
87 // TODO Auto-generated method stub
91 public FEATURE_SUPPORT getTlsSupport() {
92 // TODO Auto-generated method stub
96 public long getSwitchIdleTimeout() {
97 return switchIdleTimeout;
100 public Object getSslContext() {
101 // TODO Auto-generated method stub
110 * @throws UnknownHostException
112 private static InetAddress extractIpAddressBin(IpAddress address) throws UnknownHostException {
113 byte[] addressBin = null;
114 if (address != null) {
115 if (address.getIpv4Address() != null) {
116 addressBin = address2bin(address.getIpv4Address().getValue());
117 } else if (address.getIpv6Address() != null) {
118 addressBin = address2bin(address.getIpv6Address().getValue());
122 if (addressBin == null) {
125 return InetAddress.getByAddress(addressBin);
133 private static byte[] address2bin(String value) {
134 //TODO: translate ipv4 or ipv6 into byte[]