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.api.connection.ThreadConfiguration;
17 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
18 import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 import com.google.common.base.Objects;
29 public final class SwitchConnectionProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModule
32 private static Logger LOG = LoggerFactory
33 .getLogger(SwitchConnectionProviderModule.class);
37 * @param dependencyResolver
39 public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
40 super(identifier, dependencyResolver);
45 * @param dependencyResolver
49 public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
50 SwitchConnectionProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
51 super(identifier, dependencyResolver, oldModule, oldInstance);
55 protected void customValidation(){
56 // Add custom validation for module attributes here.
60 public java.lang.AutoCloseable createInstance() {
61 LOG.info("SwitchConnectionProvider started.");
62 SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl();
64 ConnectionConfiguration connConfiguration = createConnectionConfiguration();
65 switchConnectionProviderImpl.setConfiguration(connConfiguration);
66 } catch (UnknownHostException e) {
67 throw new IllegalArgumentException(e.getMessage(), e);
69 return switchConnectionProviderImpl;
73 * @return instance configuration object
74 * @throws UnknownHostException
76 private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException {
77 final InetAddress address = extractIpAddressBin(getAddress());
78 final Integer port = getPort();
79 final long switchIdleTimeout = getSwitchIdleTimeout();
80 final Tls tlsConfig = getTls();
81 final Threads threads = getThreads();
83 return new ConnectionConfiguration() {
85 public InetAddress getAddress() {
89 public int getPort() {
93 public Object getTransferProtocol() {
94 // TODO Auto-generated method stub
98 public TlsConfiguration getTlsConfiguration() {
99 if (tlsConfig == null) {
102 return new TlsConfiguration() {
104 public KeystoreType getTlsTruststoreType() {
105 return Objects.firstNonNull(tlsConfig.getTruststoreType(), null);
108 public String getTlsTruststore() {
109 return Objects.firstNonNull(tlsConfig.getTruststore(), null);
112 public KeystoreType getTlsKeystoreType() {
113 return Objects.firstNonNull(tlsConfig.getKeystoreType(), null);
116 public String getTlsKeystore() {
117 return Objects.firstNonNull(tlsConfig.getKeystore(), null);
120 public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsKeystorePathType() {
121 return Objects.firstNonNull(tlsConfig.getKeystorePathType(), null);
124 public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() {
125 return Objects.firstNonNull(tlsConfig.getTruststorePathType(), null);
128 public String getKeystorePassword() {
129 return Objects.firstNonNull(tlsConfig.getKeystorePassword(), null);
132 public String getCertificatePassword() {
133 return Objects.firstNonNull(tlsConfig.getCertificatePassword(), null);
136 public String getTruststorePassword() {
137 return Objects.firstNonNull(tlsConfig.getTruststorePassword(), null);
142 public long getSwitchIdleTimeout() {
143 return switchIdleTimeout;
146 public Object getSslContext() {
147 // TODO Auto-generated method stub
151 public ThreadConfiguration getThreadConfiguration() {
152 if (threads == null) {
155 return new ThreadConfiguration() {
158 public int getWorkerThreadCount() {
159 return threads.getWorkerThreads();
163 public int getBossThreadCount() {
164 return threads.getBossThreads();
174 * @throws UnknownHostException
176 private static InetAddress extractIpAddressBin(IpAddress address) throws UnknownHostException {
177 byte[] addressBin = null;
178 if (address != null) {
179 if (address.getIpv4Address() != null) {
180 addressBin = address2bin(address.getIpv4Address().getValue());
181 } else if (address.getIpv6Address() != null) {
182 addressBin = address2bin(address.getIpv6Address().getValue());
186 if (addressBin == null) {
189 return InetAddress.getByAddress(addressBin);
197 private static byte[] address2bin(String value) {
198 //TODO: translate ipv4 or ipv6 into byte[]