Removed checkstyle warnings.
[bgpcep.git] / pcep / topology-provider-config / src / main / java / org / opendaylight / controller / config / yang / pcep / topology / provider / PCEPTopologyProviderModule.java
index 87d51e311efec5a4697de313ec79b9edf38e4f21..c31f49f37c83a920b0e10b87ead5cd10b9a66b31 100644 (file)
@@ -16,6 +16,9 @@
  */
 package org.opendaylight.controller.config.yang.pcep.topology.provider;
 
+import com.google.common.base.Charsets;
+import com.google.common.net.InetAddresses;
+
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
@@ -39,112 +42,108 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Charsets;
-import com.google.common.net.InetAddresses;
-
 /**
  *
  */
 public final class PCEPTopologyProviderModule extends
-org.opendaylight.controller.config.yang.pcep.topology.provider.AbstractPCEPTopologyProviderModule {
-       private static final Logger LOG = LoggerFactory.getLogger(PCEPTopologyProviderModule.class);
-
-       public PCEPTopologyProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-                       final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-               super(identifier, dependencyResolver);
-       }
-
-       public PCEPTopologyProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-                       final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final PCEPTopologyProviderModule oldModule,
-                       final java.lang.AutoCloseable oldInstance) {
-               super(identifier, dependencyResolver, oldModule, oldInstance);
-       }
-
-       private KeyMapping contructKeys() {
-               final KeyMapping ret =new KeyMapping();
-               if (getClient() != null) {
-                       for (Client c : getClient()) {
-                               if (c.getAddress() == null) {
-                                       LOG.warn("Client {} does not have an address skipping it", c);
-                                       continue;
-                               }
-                               if (c.getPassword() != null) {
-                                       final String s = getAddressString(c.getAddress());
-                                       ret.put(InetAddresses.forString(s), c.getPassword().getValue().getBytes(Charsets.US_ASCII));
-                               }
-                       }
-               }
-               return ret;
-       }
-
-       private String getAddressString(final IpAddress address) {
-               if (address.getIpv4Address() != null) {
-                       return address.getIpv4Address().getValue();
-               }
-               if (address.getIpv6Address() != null) {
-                       return address.getIpv6Address().getValue();
-               }
-
-               throw new IllegalArgumentException(String.format("Address %s is invalid", address));
-       }
-
-       @Override
-       public void customValidation() {
-               JmxAttributeValidationException.checkNotNull(getTopologyId(), "is not set.", topologyIdJmxAttribute);
-               JmxAttributeValidationException.checkNotNull(getListenAddress(), "is not set.", listenAddressJmxAttribute);
-               JmxAttributeValidationException.checkNotNull(getListenPort(), "is not set.", listenPortJmxAttribute);
-               JmxAttributeValidationException.checkNotNull(getStatefulPlugin(), "is not set.", statefulPluginJmxAttribute);
-
-               final KeyMapping keys = contructKeys();
-               if (!keys.isEmpty()) {
-                       /*
-                        *  This is a nasty hack, but we don't have another clean solution. We cannot allow
-                        *  password being set if the injected dispatcher does not have the optional
-                        *  md5-server-channel-factory set.
-                        *
-                        *  FIXME: this is a use case for Module interfaces, e.g. PCEPDispatcherImplModule
-                        *         should something like isMd5ServerSupported()
-                        */
-                       final MBeanServer srv = ManagementFactory.getPlatformMBeanServer();
-                       Object scf;
-                       try {
-                               final ObjectName ci = (ObjectName) srv.getAttribute(getDispatcher(), "CurrentImplementation");
-
-                               // FIXME: AbstractPCEPDispatcherImplModule.md5ServerChannelFactoryJmxAttribute.getAttributeName()
-                               scf = srv.getAttribute(ci, "Md5ServerChannelFactory");
-                               JmxAttributeValidationException.checkCondition(scf != null, "password is not compatible with selected dispatcher", clientJmxAttribute);
-                       } catch (AttributeNotFoundException | InstanceNotFoundException
-                                       | MBeanException | ReflectionException e) {
-                               JmxAttributeValidationException.wrap(e, "password support could not be validated", clientJmxAttribute);
-                       }
-               }
-       }
-
-       private InetAddress listenAddress() {
-               final IpAddress a = getListenAddress();
-               if (a.getIpv4Address() != null) {
-                       return InetAddresses.forString(a.getIpv4Address().getValue());
-               } else if (a.getIpv6Address() != null) {
-                       return InetAddresses.forString(a.getIpv6Address().getValue());
-               } else {
-                       throw new IllegalArgumentException("Address " + a + " not supported");
-               }
-       }
-
-       @Override
-       public java.lang.AutoCloseable createInstance() {
-               final InstanceIdentifier<Topology> topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class,
-                               new TopologyKey(getTopologyId())).toInstance();
-               final InetSocketAddress address = new InetSocketAddress(listenAddress(), getListenPort().getValue());
-               final KeyMapping keys = contructKeys();
-
-               try {
-                       return PCEPTopologyProvider.create(getDispatcherDependency(), address,
-                                       keys.isEmpty() ? null : keys, getSchedulerDependency(), getDataProviderDependency(),
-                                                       getRpcRegistryDependency(), topology, getStatefulPluginDependency());
-               } catch (InterruptedException | ExecutionException e) {
-                       LOG.error("Failed to instantiate topology provider at {}", address, e);
-                       throw new IllegalStateException("Failed to instantiate provider", e);
-               }
-       }
+        org.opendaylight.controller.config.yang.pcep.topology.provider.AbstractPCEPTopologyProviderModule {
+    private static final Logger LOG = LoggerFactory.getLogger(PCEPTopologyProviderModule.class);
+
+    public PCEPTopologyProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public PCEPTopologyProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final PCEPTopologyProviderModule oldModule,
+            final java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    private KeyMapping contructKeys() {
+        final KeyMapping ret = new KeyMapping();
+        if (getClient() != null) {
+            for (Client c : getClient()) {
+                if (c.getAddress() == null) {
+                    LOG.warn("Client {} does not have an address skipping it", c);
+                    continue;
+                }
+                if (c.getPassword() != null) {
+                    final String s = getAddressString(c.getAddress());
+                    ret.put(InetAddresses.forString(s), c.getPassword().getValue().getBytes(Charsets.US_ASCII));
+                }
+            }
+        }
+        return ret;
+    }
+
+    private String getAddressString(final IpAddress address) {
+        if (address.getIpv4Address() != null) {
+            return address.getIpv4Address().getValue();
+        }
+        if (address.getIpv6Address() != null) {
+            return address.getIpv6Address().getValue();
+        }
+
+        throw new IllegalArgumentException(String.format("Address %s is invalid", address));
+    }
+
+    @Override
+    public void customValidation() {
+        JmxAttributeValidationException.checkNotNull(getTopologyId(), "is not set.", topologyIdJmxAttribute);
+        JmxAttributeValidationException.checkNotNull(getListenAddress(), "is not set.", listenAddressJmxAttribute);
+        JmxAttributeValidationException.checkNotNull(getListenPort(), "is not set.", listenPortJmxAttribute);
+        JmxAttributeValidationException.checkNotNull(getStatefulPlugin(), "is not set.", statefulPluginJmxAttribute);
+
+        final KeyMapping keys = contructKeys();
+        if (!keys.isEmpty()) {
+            /*
+             *  This is a nasty hack, but we don't have another clean solution. We cannot allow
+             *  password being set if the injected dispatcher does not have the optional
+             *  md5-server-channel-factory set.
+             *
+             *  FIXME: this is a use case for Module interfaces, e.g. PCEPDispatcherImplModule
+             *         should something like isMd5ServerSupported()
+             */
+            final MBeanServer srv = ManagementFactory.getPlatformMBeanServer();
+            Object scf;
+            try {
+                final ObjectName ci = (ObjectName) srv.getAttribute(getDispatcher(), "CurrentImplementation");
+
+                // FIXME: AbstractPCEPDispatcherImplModule.md5ServerChannelFactoryJmxAttribute.getAttributeName()
+                scf = srv.getAttribute(ci, "Md5ServerChannelFactory");
+                JmxAttributeValidationException.checkCondition(scf != null, "password is not compatible with selected dispatcher",
+                        clientJmxAttribute);
+            } catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException e) {
+                JmxAttributeValidationException.wrap(e, "password support could not be validated", clientJmxAttribute);
+            }
+        }
+    }
+
+    private InetAddress listenAddress() {
+        final IpAddress a = getListenAddress();
+        if (a.getIpv4Address() != null) {
+            return InetAddresses.forString(a.getIpv4Address().getValue());
+        } else if (a.getIpv6Address() != null) {
+            return InetAddresses.forString(a.getIpv6Address().getValue());
+        } else {
+            throw new IllegalArgumentException("Address " + a + " not supported");
+        }
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        final InstanceIdentifier<Topology> topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class,
+                new TopologyKey(getTopologyId())).toInstance();
+        final InetSocketAddress address = new InetSocketAddress(listenAddress(), getListenPort().getValue());
+        final KeyMapping keys = contructKeys();
+
+        try {
+            return PCEPTopologyProvider.create(getDispatcherDependency(), address, keys.isEmpty() ? null : keys, getSchedulerDependency(),
+                    getDataProviderDependency(), getRpcRegistryDependency(), topology, getStatefulPluginDependency());
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Failed to instantiate topology provider at {}", address, e);
+            throw new IllegalStateException("Failed to instantiate provider", e);
+        }
+    }
 }