Define bgp-parser-spi for parser extensibility 27/1727/1
authorRobert Varga <rovarga@cisco.com>
Mon, 7 Oct 2013 15:26:15 +0000 (17:26 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 7 Oct 2013 15:26:15 +0000 (17:26 +0200)
Change-Id: I0bea5c3d20f9b848895100c7d65dcf4a2feb46d6
Signed-off-by: Robert Varga <rovarga@cisco.com>
20 files changed:
bgp/parser-api/pom.xml
bgp/parser-impl/pom.xml
bgp/parser-spi/.project [new file with mode: 0644]
bgp/parser-spi/pom.xml [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeParser.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityParser.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityRegistry.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilitySerializer.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageParser.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageRegistry.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageSerializer.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterParser.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterRegistry.java [new file with mode: 0644]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterSerializer.java [new file with mode: 0644]
bgp/pom.xml
bgp/rib-impl/pom.xml
bgp/rib-mock/pom.xml
integration-tests/src/test/java/org/opendaylight/protocol/integration/BgpParserSpiBundleTest.java [new file with mode: 0644]

index 9976e8103257a2bebb861514879da3b68d110356..76a8a8af091fac2b50997606e55b9f3bc9aaf0de 100644 (file)
                                                </Import-Package>
                                                <Export-Package>
                             org.opendaylight.protocol.bgp.parser,
-                            org.opendaylight.protocol.bgp.parser.message,
                             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.*,
                             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.*,
                                                </Export-Package>
index 0a7d3fcc3ae1fce9914628b2e017ae708cd98f53..17895e43a209971ba6a2f0e6fee30387c42aa0b7 100644 (file)
@@ -99,7 +99,6 @@
                                        <instructions>
                                                <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
                                                <Import-Package>
-                                                       org.opendaylight.protocol.bgp.parser.message,
                                                        org.opendaylight.protocol.bgp.concepts,
                             org.opendaylight.protocol.bgp.parser,
                             org.opendaylight.protocol.bgp.util,
diff --git a/bgp/parser-spi/.project b/bgp/parser-spi/.project
new file mode 100644 (file)
index 0000000..04bbeb5
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>bgp-parser-spi</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+       </natures>
+</projectDescription>
diff --git a/bgp/parser-spi/pom.xml b/bgp/parser-spi/pom.xml
new file mode 100644 (file)
index 0000000..8975be7
--- /dev/null
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+       <parent>
+               <groupId>org.opendaylight.bgpcep</groupId>
+               <artifactId>bgp-parent</artifactId>
+               <version>0.3.0-SNAPSHOT</version>
+       </parent>
+
+       <modelVersion>4.0.0</modelVersion>
+       <artifactId>bgp-parser-spi</artifactId>
+       <description>BGP Parser SPI</description>
+       <packaging>bundle</packaging>
+       <name>${project.artifactId}</name>
+       <prerequisites>
+               <maven>3.0.4</maven>
+       </prerequisites>
+
+       <dependencies>
+               <dependency>
+                       <groupId>${project.groupId}</groupId>
+                       <artifactId>concepts</artifactId>
+            <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>${project.groupId}</groupId>
+                       <artifactId>util</artifactId>
+            <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>${project.groupId}</groupId>
+                       <artifactId>framework</artifactId>
+            <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>${project.groupId}</groupId>
+                       <artifactId>bgp-concepts</artifactId>
+            <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>${project.groupId}</groupId>
+                       <artifactId>bgp-parser-api</artifactId>
+            <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.google.guava</groupId>
+                       <artifactId>guava</artifactId>
+                       <version>${guava.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-api</artifactId>
+                       <version>${slf4j.version}</version>
+        </dependency>
+       </dependencies>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>${maven.bundle.version}</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                                               <Export-Package>
+                            org.opendaylight.protocol.bgp.parser.spi,
+                                               </Export-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <distributionManagement>
+               <site>
+                       <id>${project.artifactId}</id>
+                       <name>BGP-PARSER-SPI Module site</name>
+                       <url>${basedir}/target/site/${project.artifactId}</url>
+               </site>
+       </distributionManagement>
+
+</project>
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeParser.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeParser.java
new file mode 100644 (file)
index 0000000..1f5abc6
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
+
+public interface AttributeParser {
+       public void parseAttribute(final byte[] bytes, PathAttributesBuilder builder) throws BGPDocumentedException;
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java
new file mode 100644 (file)
index 0000000..37b816c
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public interface AttributeRegistry {
+       public AutoCloseable registerAttributeParser(int attributeType, AttributeParser parser);
+       public AttributeParser getAttributeParser(int attributeType);
+
+       public AutoCloseable registerAttributeSerializer(Class<? extends DataObject> attrClass, AttributeSerializer serializer);
+       public AttributeSerializer getAttributeSerializer(DataObject object);
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java
new file mode 100644 (file)
index 0000000..3241beb
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public interface AttributeSerializer {
+       public byte[] serializeMessage(final DataObject message);
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityParser.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityParser.java
new file mode 100644 (file)
index 0000000..50e278a
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
+
+public interface CapabilityParser {
+       public CParameters parseMessage(final byte[] bytes) throws BGPDocumentedException;
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityRegistry.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityRegistry.java
new file mode 100644 (file)
index 0000000..55d70de
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
+
+public interface CapabilityRegistry {
+       public AutoCloseable registerCapabilityParser(int capabilityType, CapabilityParser parser);
+       public CapabilityParser getCapabilityParser(int capabilityType);
+
+       public AutoCloseable registerCapabilitySerializer(Class<? extends CParameters> capabilityClass, CapabilitySerializer serializer);
+       public CapabilitySerializer getCapabilitySerializer(CParameters object);
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilitySerializer.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilitySerializer.java
new file mode 100644 (file)
index 0000000..fc1d806
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
+
+public interface CapabilitySerializer {
+       public byte[] serializeCapability(final CParameters capability);
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageParser.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageParser.java
new file mode 100644 (file)
index 0000000..13bbeac
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface MessageParser {
+       public Notification parseMessage(final byte[] bytes) throws BGPDocumentedException;
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageRegistry.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageRegistry.java
new file mode 100644 (file)
index 0000000..da48f82
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface MessageRegistry {
+       public AutoCloseable registerMessageParser(int messageType, MessageParser parser);
+       public MessageParser getMessageParser(int messageType);
+
+       public AutoCloseable registerMessageSerializer(Class<? extends Notification> msgClass, MessageSerializer serializer);
+       public MessageSerializer getMessageSerializer(Notification message);
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageSerializer.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageSerializer.java
new file mode 100644 (file)
index 0000000..3b5cf0f
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface MessageSerializer {
+       public byte[] serializeMessage(final Notification message);
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterParser.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterParser.java
new file mode 100644 (file)
index 0000000..6b4c836
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+
+public interface ParameterParser {
+       public BgpParameters parseParameter(final byte[] bytes) throws BGPParsingException;
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterRegistry.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterRegistry.java
new file mode 100644 (file)
index 0000000..ca77a1d
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+
+public interface ParameterRegistry {
+       public AutoCloseable registerParameterParser(int parameterType, ParameterParser parser);
+       public ParameterParser getParameterParser(int parameterType);
+
+       public AutoCloseable registerParameterSerializer(Class<? extends BgpParameters> paramClass, ParameterSerializer serializer);
+       public ParameterSerializer getParameterSerializer(BgpParameters object);
+}
diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterSerializer.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterSerializer.java
new file mode 100644 (file)
index 0000000..df170af
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+
+public interface ParameterSerializer {
+       public byte[] serializeParameter(final BgpParameters parameter);
+}
index eb217cc51261909c2bedeb58ed8674d07412ded0..157e3747ddb8310480a5f8eccbad9e9333cb3583 100644 (file)
@@ -20,6 +20,7 @@
                <module>concepts</module>
                <module>linkstate</module>
         <module>parser-api</module>
+        <module>parser-spi</module>
         <module>parser-impl</module>
         <module>parser-mock</module>
         <module>rib-api</module>
index c52971d2cf5bf5c7b7449800ed06a0cde62b03d9..2f09b9d59cfec9388d1df4adea44df3f705cbf78 100644 (file)
                             org.opendaylight.protocol.bgp.concepts,
                             org.opendaylight.protocol.bgp.parser,
                             org.opendaylight.protocol.bgp.parser.impl,
-                            org.opendaylight.protocol.bgp.parser.message,
                             org.opendaylight.protocol.bgp.util,
                             org.opendaylight.protocol.util,
                                                        org.slf4j,
index c28686e55755e4c287c48e6165f2befc7b2dd80e..c6440b7f1f8d3f1204b0265504f006d4465dc5f0 100644 (file)
@@ -89,7 +89,6 @@
                                                        com.google.common.*,
                                                        org.opendaylight.protocol.bgp.parser,
                             org.opendaylight.protocol.bgp.parser.impl,
-                                                       org.opendaylight.protocol.bgp.parser.message,
                             org.opendaylight.protocol.bgp.rib.impl,
                                                        org.opendaylight.protocol.concepts,
                                                        org.opendaylight.protocol.framework,
diff --git a/integration-tests/src/test/java/org/opendaylight/protocol/integration/BgpParserSpiBundleTest.java b/integration-tests/src/test/java/org/opendaylight/protocol/integration/BgpParserSpiBundleTest.java
new file mode 100644 (file)
index 0000000..d663e6e
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, 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
+ */
+package org.opendaylight.protocol.integration;
+
+import java.util.Collection;
+
+import com.google.common.collect.Lists;
+
+public final class BgpParserSpiBundleTest extends AbstractBundleTest {
+       @Override
+       protected Collection<String> prerequisiteBundles() {
+               return Lists.newArrayList("bgp-concepts", "bgp-parser-api", "bgp-util", "concepts", "framework", "util");
+       }
+
+       @Override
+       protected Collection<String> requiredBundles() {
+               return Lists.newArrayList("bgp-parser-spi");
+       }
+}