Remove reliance on BGPMessageFactory 18/3018/1
authorRobert Varga <rovarga@cisco.com>
Fri, 22 Nov 2013 16:51:47 +0000 (17:51 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 22 Nov 2013 16:51:47 +0000 (17:51 +0100)
Change-Id: I99d5ae0cc1e3aff3921bfeb7f0dc1813fe43ccfc
Signed-off-by: Robert Varga <rovarga@cisco.com>
14 files changed:
bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModule.java
bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModule.java [deleted file]
bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleFactory.java [deleted file]
bgp/rib-impl-config/src/main/yang/bgp-rib-impl.yang
bgp/rib-impl-config/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModuleTest.java
bgp/rib-impl-config/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPImplModuleTest.java
bgp/rib-impl-config/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleTest.java [deleted file]
bgp/rib-impl-config/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModuleTest.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPByteToMessageDecoder.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPHandlerFactory.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageToByteEncoder.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/Main.java
bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java

index 7b8ad263cf052c4eb42ace162025d1101e6eaac8..18310c84f10a08d7b3a4b2505f6f80ee44668807 100644 (file)
@@ -9,27 +9,27 @@
  */
 package org.opendaylight.controller.config.yang.bgp.rib.impl;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext;
 import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl;
 
 /**
-*
-*/
+ *
+ */
 public final class BGPDispatcherImplModule
-               extends
-               org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPDispatcherImplModule {
+extends
+org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPDispatcherImplModule {
 
        public BGPDispatcherImplModule(
-                       org.opendaylight.controller.config.api.ModuleIdentifier name,
-                       org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+                       final org.opendaylight.controller.config.api.ModuleIdentifier name,
+                       final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
                super(name, dependencyResolver);
        }
 
        public BGPDispatcherImplModule(
-                       org.opendaylight.controller.config.api.ModuleIdentifier name,
-                       org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-                       BGPDispatcherImplModule oldModule,
-                       java.lang.AutoCloseable oldInstance) {
+                       final org.opendaylight.controller.config.api.ModuleIdentifier name,
+                       final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+                       final BGPDispatcherImplModule oldModule,
+                       final java.lang.AutoCloseable oldInstance) {
                super(name, dependencyResolver, oldModule, oldInstance);
        }
 
@@ -40,8 +40,8 @@ public final class BGPDispatcherImplModule
 
        @Override
        public java.lang.AutoCloseable createInstance() {
-               final BGPMessageFactory messageFactoryDependency = getMessageFactoryDependency();
-               return new BGPDispatcherImpl(messageFactoryDependency,
+               final BGPExtensionConsumerContext bgpExtensions = getBgpExtensionsDependency();
+               return new BGPDispatcherImpl(bgpExtensions.getMessageRegistry(),
                                getBossGroupDependency(), getWorkerGroupDependency());
        }
 }
diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModule.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModule.java
deleted file mode 100644 (file)
index dfbd70c..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Generated file
-
- * Generated from: yang module name: bgp-rib-impl  yang module local name: bgp-message-factory-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 13:02:31 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
-import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- *
- */
-public final class BGPMessageFactoryImplModule
-extends
-org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryImplModule {
-
-       public BGPMessageFactoryImplModule(
-                       final org.opendaylight.controller.config.api.ModuleIdentifier name,
-                       final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-               super(name, dependencyResolver);
-       }
-
-       public BGPMessageFactoryImplModule(
-                       final org.opendaylight.controller.config.api.ModuleIdentifier name,
-                       final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-                       final BGPMessageFactoryImplModule oldModule,
-                       final java.lang.AutoCloseable oldInstance) {
-               super(name, dependencyResolver, oldModule, oldInstance);
-       }
-
-       @Override
-       public void validate() {
-               super.validate();
-               // Add custom validation for module attributes here.
-       }
-
-       @Override
-       public java.lang.AutoCloseable createInstance() {
-               try {
-                       return new BGPMessageFactoryCloseable(new BGPMessageFactoryImpl(
-                                       getBgpExtensionsDependency().getMessageRegistry()));
-               } catch (Exception e) {
-                       throw new RuntimeException("Failed to create consumer context.", e);
-               }
-       }
-
-       private static class BGPMessageFactoryCloseable implements
-       BGPMessageFactory, AutoCloseable {
-               private final BGPMessageFactoryImpl inner;
-
-               public BGPMessageFactoryCloseable(
-                               final BGPMessageFactoryImpl bgpMessageFactory) {
-                       this.inner = bgpMessageFactory;
-               }
-
-               @Override
-               public void close() throws Exception {
-                       // NOOP
-               }
-
-               @Override
-               public Notification parse(final byte[] bytes) throws BGPParsingException, BGPDocumentedException {
-                       return inner.parse(bytes);
-               }
-
-               @Override
-               public byte[] put(final Notification bgpMessage) {
-                       return inner.put(bgpMessage);
-               }
-       }
-}
diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleFactory.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleFactory.java
deleted file mode 100644 (file)
index bbe69ae..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Generated file
-
- * Generated from: yang module name: bgp-rib-impl  yang module local name: bgp-message-factory-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 13:02:31 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-/**
-*
-*/
-public class BGPMessageFactoryImplModuleFactory
-               extends
-               org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryImplModuleFactory {
-
-}
index 1b16597be0440524fd4c0033e53202c5273b06dd..0e6654fe0f02badf27e7bf21465488d2bc7f9e69 100644 (file)
@@ -53,35 +53,6 @@ module bgp-rib-impl {
         }
     }
 
-    identity bgp-message-factory {
-        description
-            "Service representing a BGP proposal.";
-
-        base "config:service-type";
-        config:java-class "org.opendaylight.protocol.bgp.parser.BGPMessageFactory";
-    }
-
-    identity bgp-message-factory-impl {
-        base config:module-type;
-        config:provided-service bgp-message-factory;
-        config:java-name-prefix BGPMessageFactoryImpl;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case bgp-message-factory-impl {
-            when "/config:modules/config:module/config:type = 'bgp-message-factory-impl'";
-
-            container bgp-extensions {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity bgpspi:consumer-extensions;
-                    }
-                }
-            }
-        }
-    }
-
     identity bgp-rib-extensions-impl {
         base config:module-type;
         config:provided-service ribspi:extensions;
@@ -147,11 +118,11 @@ module bgp-rib-impl {
         case bgp-dispatcher-impl {
             when "/config:modules/config:module/config:type = 'bgp-dispatcher-impl'";
 
-            container message-factory {
+            container bgp-extensions {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
-                        config:required-identity bgp-message-factory;
+                        config:required-identity bgpspi:consumer-extensions;
                     }
                 }
             }
index e6d2e50df26da6c42f8ef6499cb242c71d295e4d..3ad596e9adea296a6f8c7c68c5991e29e8500c0b 100644 (file)
@@ -21,19 +21,19 @@ public class BGPDispatcherImplModuleTest extends AbstractConfigTest {
        private final String instanceName = "bgp-message-fct";
 
        private BGPDispatcherImplModuleFactory factory;
-       
+
        private NettyThreadgroupModuleFactory threadgroupFactory;
-       
-       private BGPMessageFactoryImplModuleFactory messageFactory;
-       
+
+       private RIBExtensionsImplModuleFactory messageFactory;
+
        @Before
        public void setUp() throws Exception {
                this.factory = new BGPDispatcherImplModuleFactory();
                this.threadgroupFactory = new NettyThreadgroupModuleFactory();
-               this.messageFactory = new BGPMessageFactoryImplModuleFactory();
+               this.messageFactory = new RIBExtensionsImplModuleFactory();
                super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, threadgroupFactory, messageFactory));
        }
-       
+
        @Test
        public void testCreateBean() throws Exception {
                ConfigTransactionJMXClient transaction = configRegistryClient
@@ -44,10 +44,10 @@ public class BGPDispatcherImplModuleTest extends AbstractConfigTest {
                assertBeanCount(1, factory.getImplementationName());
                assertStatus(status, 4, 0, 0);
        }
-       
+
        @Test
        public void testReusingOldInstance() throws InstanceAlreadyExistsException,
-                       ConflictingVersionException, ValidationException {
+       ConflictingVersionException, ValidationException {
                ConfigTransactionJMXClient transaction = configRegistryClient
                                .createTransaction();
                createInstance(transaction, this.factory.getImplementationName(), instanceName, this.threadgroupFactory.getImplementationName(), this.messageFactory.getImplementationName());
@@ -58,7 +58,7 @@ public class BGPDispatcherImplModuleTest extends AbstractConfigTest {
                assertBeanCount(1, factory.getImplementationName());
                assertStatus(status, 0, 0, 4);
        }
-       
+
        public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
                        final String instanceName, final String threadgropuModuleName, final String messageFactoryModuleName) throws InstanceAlreadyExistsException {
                ObjectName nameCreated = transaction.createModule(
@@ -68,9 +68,9 @@ public class BGPDispatcherImplModuleTest extends AbstractConfigTest {
                mxBean.setBossGroup(createThreadgroupInstance(transaction, threadgropuModuleName, "boss-threadgroup", 10));
                mxBean.setWorkerGroup(createThreadgroupInstance(transaction, threadgropuModuleName, "worker-threadgroup", 10));
                //mxBean.setMessageFactory(BGPMessageFactoryImplModuleTest.createInstance(transaction, messageFactoryModuleName, "bgp-msg-fct"));
-               return nameCreated;     
+               return nameCreated;
        }
-       
+
        public static ObjectName createThreadgroupInstance(
                        final ConfigTransactionJMXClient transaction,
                        final String moduleName, final String instanceName,
index 040542a36ea311be0b0d4063f6e0a7dac3d52e06..061790147c4ee8adf7021d694f41a157c9a751fa 100644 (file)
@@ -22,27 +22,27 @@ import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgrou
 public class BGPImplModuleTest extends AbstractConfigTest {
 
        private final String instanceName = "bgp-impl1";
-       
+
        private BGPImplModuleFactory factory;
-       
+
        private BGPSessionProposalImplModuleFactory sessionFacotry;
-       
+
        private BGPDispatcherImplModuleFactory dispactherFactory;
-       
+
        private NettyThreadgroupModuleFactory threadgropFactory;
-       
-       private BGPMessageFactoryImplModuleFactory messageFactory;
-       
+
+       private RIBExtensionsImplModuleFactory messageFactory;
+
        @Before
        public void setUp() throws Exception {
                this.factory = new BGPImplModuleFactory();
                this.dispactherFactory = new BGPDispatcherImplModuleFactory();
                this.sessionFacotry = new BGPSessionProposalImplModuleFactory();
                this.threadgropFactory = new NettyThreadgroupModuleFactory();
-               this.messageFactory = new BGPMessageFactoryImplModuleFactory();
+               this.messageFactory = new RIBExtensionsImplModuleFactory();
                super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, this.dispactherFactory, this.sessionFacotry, this.messageFactory, this.threadgropFactory));
        }
-       
+
        @Test
        public void testValidationExceptionPortNotSet()
                        throws InstanceAlreadyExistsException {
@@ -56,7 +56,7 @@ public class BGPImplModuleTest extends AbstractConfigTest {
                        assertTrue(e.getMessage().contains("Port value is not set."));
                }
        }
-       
+
        @Test
        public void testValidationExceptionPortOutOfRange()
                        throws InstanceAlreadyExistsException {
@@ -70,7 +70,7 @@ public class BGPImplModuleTest extends AbstractConfigTest {
                        assertTrue(e.getMessage().contains("is out of range (0-65535)."));
                }
        }
-       
+
        @Test
        public void testValidationExceptionHostNotSet()
                        throws InstanceAlreadyExistsException {
@@ -84,7 +84,7 @@ public class BGPImplModuleTest extends AbstractConfigTest {
                        assertTrue(e.getMessage().contains("Host value is not set."));
                }
        }
-       
+
        @Test
        public void testCreateBean() throws Exception {
                ConfigTransactionJMXClient transaction = configRegistryClient
@@ -95,10 +95,10 @@ public class BGPImplModuleTest extends AbstractConfigTest {
                assertBeanCount(1, factory.getImplementationName());
                assertStatus(status, 6, 0, 0);
        }
-       
+
        @Test
        public void testReusingOldInstance() throws InstanceAlreadyExistsException,
-                       ConflictingVersionException, ValidationException {
+       ConflictingVersionException, ValidationException {
                ConfigTransactionJMXClient transaction = configRegistryClient
                                .createTransaction();
                createInstance(transaction, this.factory.getImplementationName(), instanceName, "localhost", 1, sessionFacotry.getImplementationName(), dispactherFactory.getImplementationName(), threadgropFactory.getImplementationName(), messageFactory.getImplementationName());
@@ -112,8 +112,8 @@ public class BGPImplModuleTest extends AbstractConfigTest {
 
        @Test
        public void testReconfigure() throws InstanceAlreadyExistsException,
-                       ConflictingVersionException, ValidationException,
-                       InstanceNotFoundException {
+       ConflictingVersionException, ValidationException,
+       InstanceNotFoundException {
                ConfigTransactionJMXClient transaction = configRegistryClient
                                .createTransaction();
                createInstance(transaction, this.factory.getImplementationName(), instanceName, "localhost", 1, sessionFacotry.getImplementationName(), dispactherFactory.getImplementationName(), threadgropFactory.getImplementationName(), messageFactory.getImplementationName());
@@ -129,7 +129,7 @@ public class BGPImplModuleTest extends AbstractConfigTest {
                assertBeanCount(1, factory.getImplementationName());
                assertStatus(status, 0, 1, 5);
        }
-       
+
        public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
                        final String instanceName, final String host, final Integer port, final String sessionModuleName, final String dispatcherModuleName, final String threadgroupModuleName, final String messageFactoryModuleName) throws InstanceAlreadyExistsException {
                ObjectName nameCreated = transaction.createModule(
@@ -142,5 +142,5 @@ public class BGPImplModuleTest extends AbstractConfigTest {
                mxBean.setBgpDispatcher(BGPDispatcherImplModuleTest.createInstance(transaction, dispatcherModuleName, "bgp-dispatcher1", threadgroupModuleName, messageFactoryModuleName));
                return nameCreated;
        }
-       
+
 }
diff --git a/bgp/rib-impl-config/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleTest.java b/bgp/rib-impl-config/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleTest.java
deleted file mode 100644 (file)
index 46eb690..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleMXBean;
-
-@Ignore
-public class BGPMessageFactoryImplModuleTest extends AbstractConfigTest {
-       
-       private final String instanceName = "bgp-message-fct";
-
-       private BGPMessageFactoryImplModuleFactory factory;
-       
-       private SimpleBGPExtensionProviderContextModuleFactory bgpEPCFactory;
-       
-       @Before
-       public void setUp() throws Exception {
-               this.factory = new BGPMessageFactoryImplModuleFactory();
-               this.bgpEPCFactory = new SimpleBGPExtensionProviderContextModuleFactory();
-               super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, this.bgpEPCFactory));
-       }
-       
-       @Test
-       public void testCreateBean() throws Exception {
-               ConfigTransactionJMXClient transaction = configRegistryClient
-                               .createTransaction();
-               createInstance(transaction, this.factory.getImplementationName(), instanceName, this.bgpEPCFactory.getImplementationName());
-               transaction.validateConfig();
-               CommitStatus status = transaction.commit();
-               assertBeanCount(1, factory.getImplementationName());
-               assertStatus(status, 1, 0, 0);
-       }
-       
-       @Test
-       public void testReusingOldInstance() throws InstanceAlreadyExistsException,
-                       ConflictingVersionException, ValidationException {
-               ConfigTransactionJMXClient transaction = configRegistryClient
-                               .createTransaction();
-               createInstance(transaction, this.factory.getImplementationName(), instanceName, this.bgpEPCFactory.getImplementationName());
-               transaction.commit();
-               transaction = configRegistryClient.createTransaction();
-               assertBeanCount(1, factory.getImplementationName());
-               CommitStatus status = transaction.commit();
-               assertBeanCount(1, factory.getImplementationName());
-               assertStatus(status, 0, 0, 1);
-       }
-       
-       public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
-                       final String instanceName, final String extensionsModuleName) throws InstanceAlreadyExistsException {
-               ObjectName nameCreated = transaction.createModule(
-                               moduleName, instanceName);
-               BGPMessageFactoryImplModuleMXBean mxBean = transaction.newMBeanProxy(
-                               nameCreated, BGPMessageFactoryImplModuleMXBean.class);
-               //mxBean.setBgpExtensions(createBgpExtensionsInstance(transaction, extensionsModuleName, "bgp-extension"));
-               return nameCreated;     
-       }
-       
-       public static ObjectName createBgpExtensionsInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
-                       final String instanceName) throws InstanceAlreadyExistsException {
-               ObjectName nameCreated = transaction.createModule(
-                               moduleName, instanceName);
-               transaction.newMBeanProxy(
-                               nameCreated, SimpleBGPExtensionProviderContextModuleMXBean.class);
-               return nameCreated;                     
-       }
-       
-}
index b01ff8ecd13d7601f123a65870d871cf74c35d0a..d4d1b0fa43b018ce0baf168a93e722ad81112d04 100644 (file)
@@ -30,27 +30,27 @@ import org.osgi.framework.ServiceReference;
 
 @Ignore
 public class RIBImplModuleTest extends AbstractConfigTest {
-       
+
        private final String instanceName = "bgp-rib-impl";
 
        private RIBImplModuleFactory factory;
-       
+
        private BindingBrokerImplSingletonModuleFactory brokerFactory;
-       
+
        private TimedReconnectStrategyModuleFactory reconnectFactory;
-       
+
        private BGPImplModuleFactory bgpFactory;
-       
+
        private BGPSessionProposalImplModuleFactory sessionFacotry;
-       
+
        private BGPDispatcherImplModuleFactory dispactherFactory;
-       
+
        private NettyThreadgroupModuleFactory threadgropFactory;
-       
-       private BGPMessageFactoryImplModuleFactory messageFactory;
-       
+
+       private RIBExtensionsImplModuleFactory messageFactory;
+
        private GlobalEventExecutorModuleFactory executorFactory;
-       
+
        @Before
        public void setUp() throws Exception {
                this.factory = new RIBImplModuleFactory();
@@ -60,32 +60,32 @@ public class RIBImplModuleTest extends AbstractConfigTest {
                this.dispactherFactory = new BGPDispatcherImplModuleFactory();
                this.sessionFacotry = new BGPSessionProposalImplModuleFactory();
                this.threadgropFactory = new NettyThreadgroupModuleFactory();
-               this.messageFactory = new BGPMessageFactoryImplModuleFactory();
+               this.messageFactory = new RIBExtensionsImplModuleFactory();
                this.reconnectFactory = new TimedReconnectStrategyModuleFactory();
-               super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, 
-                               this.dispactherFactory, this.sessionFacotry, this.messageFactory, 
+               super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory,
+                               this.dispactherFactory, this.sessionFacotry, this.messageFactory,
                                this.threadgropFactory, this.bgpFactory, this.reconnectFactory, this.brokerFactory, this.executorFactory));
                Mockito.doReturn(mockedServiceRegistration).when(mockedContext).registerService(
-                Matchers.any(String.class), Mockito.any(Closeable.class),
-                Mockito.any(Dictionary.class));
+                               Matchers.any(String.class), Mockito.any(Closeable.class),
+                               Mockito.any(Dictionary.class));
                Mockito.doReturn(mockedServiceRegistration).when(mockedContext).registerService(
-                Matchers.any(Class.class), Mockito.any(Closeable.class),
-                Mockito.any(Dictionary.class));
+                               Matchers.any(Class.class), Mockito.any(Closeable.class),
+                               Mockito.any(Dictionary.class));
                Filter mockedFilter = Mockito.mock(Filter.class);
                Mockito.doReturn(mockedFilter).when(mockedContext).createFilter(Mockito.anyString());
-               
+
                Mockito.doNothing().when(mockedContext).addServiceListener(Mockito.any(ServiceListener.class), Mockito.anyString());
-               
+
                Mockito.doReturn(new ServiceReference[]{}).when(mockedContext).getServiceReferences(Matchers.anyString(), Matchers.anyString());
-               
+
                ServiceReference<?> mockedserviceReference = Mockito.mock(ServiceReference.class);
                Mockito.doReturn(new String()).when(mockedserviceReference).toString();
                Mockito.doReturn(mockedserviceReference).when(mockedContext).getServiceReference(Matchers.any(Class.class));
-               
+
                DataProviderService mockedService = Mockito.mock(DataProviderService.class);
                Mockito.doReturn(mockedService).when(mockedContext).getService(Matchers.any(ServiceReference.class));
        }
-       
+
        @Test
        public void testCreateBean() throws Exception {
                ConfigTransactionJMXClient transaction = configRegistryClient
@@ -98,7 +98,7 @@ public class RIBImplModuleTest extends AbstractConfigTest {
                assertBeanCount(1, factory.getImplementationName());
                assertStatus(status, 6, 0, 0);
        }
-       
+
        public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
                        final String instanceName, final ObjectName bindingDataModule, final String reconnectModueName, final String executorModuleName, final String bgpModuleName,
                        final String sessionModuleName, final String dispatcherModuleName, final String threadgroupModuleName, final String messageFactoryModuleName) throws InstanceAlreadyExistsException, MalformedObjectNameException {
@@ -113,7 +113,7 @@ public class RIBImplModuleTest extends AbstractConfigTest {
                mxBean.setBgp(BGPImplModuleTest.createInstance(transaction, bgpModuleName, "bgp-impl1", "localhost", 1, sessionModuleName, dispatcherModuleName, threadgroupModuleName, messageFactoryModuleName));
                return nameCreated;
        }
-       
+
        public static ObjectName createBindingBrokerInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
                        final String instanceName) throws InstanceAlreadyExistsException {
                ObjectName nameCreated = transaction.createModule(
index 7cca4d4bb84d08cd80e52938a3adbc84a1bfde83..c5d9f4c7be88d68d1706db8316d9b8a5be23e11f 100644 (file)
@@ -15,8 +15,8 @@ import io.netty.handler.codec.ByteToMessageDecoder;
 import java.util.List;
 
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,10 +27,10 @@ import com.google.common.base.Preconditions;
  */
 final class BGPByteToMessageDecoder extends ByteToMessageDecoder {
        private final static Logger LOG = LoggerFactory.getLogger(BGPByteToMessageDecoder.class);
-       private final BGPMessageFactory factory;
+       private final MessageRegistry registry;
 
-       public BGPByteToMessageDecoder(final BGPMessageFactory factory) {
-               this.factory = Preconditions.checkNotNull(factory);
+       public BGPByteToMessageDecoder(final MessageRegistry registry) {
+               this.registry = Preconditions.checkNotNull(registry);
        }
 
        @Override
@@ -44,7 +44,7 @@ final class BGPByteToMessageDecoder extends ByteToMessageDecoder {
                        LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
                        final byte[] bytes = new byte[in.readableBytes()];
                        in.readBytes(bytes);
-                       out.add(this.factory.parse(bytes));
+                       out.add(this.registry.parseMessage(bytes));
                } catch (BGPParsingException | BGPDocumentedException e) {
                        LOG.debug("Failed to decode protocol message", e);
                        this.exceptionCaught(ctx, e);
index 13b17b090b157a843f08e9fdd49391301b6a000f..e159c7568e7b77d94631e9dbd8f1ca997f985464 100644 (file)
@@ -16,8 +16,8 @@ import io.netty.util.concurrent.Promise;
 
 import java.net.InetSocketAddress;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
 import org.opendaylight.protocol.framework.AbstractDispatcher;
@@ -33,9 +33,9 @@ public final class BGPDispatcherImpl extends AbstractDispatcher<BGPSessionImpl,
 
        private final BGPHandlerFactory hf;
 
-       public BGPDispatcherImpl(final BGPMessageFactory parser, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
+       public BGPDispatcherImpl(final MessageRegistry messageRegistry, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
                super(bossGroup, workerGroup);
-               this.hf = new BGPHandlerFactory(parser);
+               this.hf = new BGPHandlerFactory(messageRegistry);
        }
 
        @Override
index d931fa56ae3569c3e9dbb9a2df504ae90defa058..961ff90d4d431a6185310716c3b2c7ffd6d296a4 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.bgp.rib.impl;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelOutboundHandler;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 
 import com.google.common.base.Preconditions;
 
@@ -19,11 +19,11 @@ import com.google.common.base.Preconditions;
  */
 public class BGPHandlerFactory  {
        private final ChannelOutboundHandler encoder;
-       private final BGPMessageFactory msgFactory;
+       private final MessageRegistry registry;
 
-       public BGPHandlerFactory(final BGPMessageFactory msgFactory) {
-               this.msgFactory = Preconditions.checkNotNull(msgFactory);
-               this.encoder = new BGPMessageToByteEncoder(msgFactory);
+       public BGPHandlerFactory(final MessageRegistry registry) {
+               this.registry = Preconditions.checkNotNull(registry);
+               this.encoder = new BGPMessageToByteEncoder(registry);
        }
 
        public ChannelHandler[] getEncoders() {
@@ -35,7 +35,7 @@ public class BGPHandlerFactory  {
        public ChannelHandler[] getDecoders() {
                return new ChannelHandler[] {
                                new BGPMessageHeaderDecoder(),
-                               new BGPByteToMessageDecoder(this.msgFactory),
+                               new BGPByteToMessageDecoder(this.registry),
                };
        }
 }
index abd4376fdfbdd3923d1a6e20778e934f9e513f53..7960ed916faffe63eee24720c503ef65b7c5ab14 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.channel.ChannelHandler.Sharable;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToByteEncoder;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -25,15 +25,15 @@ import com.google.common.base.Preconditions;
 @Sharable
 final class BGPMessageToByteEncoder extends MessageToByteEncoder<Notification> {
        private final static Logger LOG = LoggerFactory.getLogger(BGPMessageToByteEncoder.class);
-       private final BGPMessageFactory factory;
+       private final MessageRegistry registry;
 
-       BGPMessageToByteEncoder(final BGPMessageFactory factory) {
-               this.factory = Preconditions.checkNotNull(factory);
+       BGPMessageToByteEncoder(final MessageRegistry registry) {
+               this.registry = Preconditions.checkNotNull(registry);
        }
 
        @Override
        protected void encode(final ChannelHandlerContext ctx, final Notification msg, final ByteBuf out) throws Exception {
                LOG.debug("Sent to encode : {}", msg);
-               out.writeBytes(this.factory.put(msg));
+               out.writeBytes(this.registry.serializeMessage(msg));
        }
 }
index a4a69c01b14414d13562697a418f0b9759b340d7..059788c5a24445cb1a28a047a70c9ce87d4a1038 100644 (file)
@@ -14,7 +14,6 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
-import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
 import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl;
 import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
@@ -55,7 +54,7 @@ public class Main {
        private static final int RECONNECT_MILLIS = 5000;
 
        private Main() throws Exception {
-               this.dispatcher = new BGPDispatcherImpl(new BGPMessageFactoryImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry()), new NioEventLoopGroup(), new NioEventLoopGroup());
+               this.dispatcher = new BGPDispatcherImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry(), new NioEventLoopGroup(), new NioEventLoopGroup());
        }
 
        public static void main(final String[] args) throws Exception {
index e2e57f657e62716577ce34a3646c6bd42e4ddba4..8f7a63cea2f1bc9b551608fe3a1db2ba9c5fb7e2 100644 (file)
@@ -17,7 +17,6 @@ import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
-import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
 import org.opendaylight.protocol.bgp.rib.impl.BGPHandlerFactory;
 import org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl;
@@ -73,7 +72,7 @@ public class BGPSpeakerMock<M, S extends ProtocolSession<M>, L extends SessionLi
                final SessionNegotiatorFactory<Notification, BGPSessionImpl, BGPSessionListener> snf = new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs);
 
                final BGPSpeakerMock<Notification, BGPSessionImpl, BGPSessionListener> mock = new BGPSpeakerMock<>(snf,
-                               new BGPHandlerFactory(new BGPMessageFactoryImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry())),
+                               new BGPHandlerFactory(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry()),
                                new DefaultPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE));
 
                mock.createServer(new InetSocketAddress("127.0.0.2", 12345), f);