From: Robert Varga Date: Mon, 7 Oct 2013 15:26:15 +0000 (+0200) Subject: Define bgp-parser-spi for parser extensibility X-Git-Tag: jenkins-bgpcep-bulk-release-prepare-only-1~237^2~207^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=f750db27e2820613e7cf8e4e1eadb26e78f1c9b6;p=bgpcep.git Define bgp-parser-spi for parser extensibility Change-Id: I0bea5c3d20f9b848895100c7d65dcf4a2feb46d6 Signed-off-by: Robert Varga --- diff --git a/bgp/parser-api/pom.xml b/bgp/parser-api/pom.xml index 9976e81032..76a8a8af09 100644 --- a/bgp/parser-api/pom.xml +++ b/bgp/parser-api/pom.xml @@ -111,7 +111,6 @@ 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.*, diff --git a/bgp/parser-impl/pom.xml b/bgp/parser-impl/pom.xml index 0a7d3fcc3a..17895e43a2 100644 --- a/bgp/parser-impl/pom.xml +++ b/bgp/parser-impl/pom.xml @@ -99,7 +99,6 @@ ${project.groupId}.${project.artifactId} - 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 index 0000000000..04bbeb5976 --- /dev/null +++ b/bgp/parser-spi/.project @@ -0,0 +1,24 @@ + + + bgp-parser-spi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bgp/parser-spi/pom.xml b/bgp/parser-spi/pom.xml new file mode 100644 index 0000000000..8975be78d4 --- /dev/null +++ b/bgp/parser-spi/pom.xml @@ -0,0 +1,86 @@ + + + + + + org.opendaylight.bgpcep + bgp-parent + 0.3.0-SNAPSHOT + + + 4.0.0 + bgp-parser-spi + BGP Parser SPI + bundle + ${project.artifactId} + + 3.0.4 + + + + + ${project.groupId} + concepts + ${project.version} + + + ${project.groupId} + util + ${project.version} + + + ${project.groupId} + framework + ${project.version} + + + ${project.groupId} + bgp-concepts + ${project.version} + + + ${project.groupId} + bgp-parser-api + ${project.version} + + + com.google.guava + guava + ${guava.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.version} + true + + + ${project.groupId}.${project.artifactId} + + org.opendaylight.protocol.bgp.parser.spi, + + + + + + + + + + ${project.artifactId} + BGP-PARSER-SPI Module site + ${basedir}/target/site/${project.artifactId} + + + + 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 index 0000000000..1f5abc6107 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeParser.java @@ -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 index 0000000000..37b816c5ad --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java @@ -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 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 index 0000000000..3241beb037 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java @@ -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 index 0000000000..50e278a221 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityParser.java @@ -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 index 0000000000..55d70dea9d --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilityRegistry.java @@ -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 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 index 0000000000..fc1d806de8 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/CapabilitySerializer.java @@ -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 index 0000000000..13bbeac8c8 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageParser.java @@ -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 index 0000000000..da48f829b8 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageRegistry.java @@ -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 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 index 0000000000..3b5cf0f4e7 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageSerializer.java @@ -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 index 0000000000..6b4c836dca --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterParser.java @@ -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 index 0000000000..ca77a1dfd0 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterRegistry.java @@ -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 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 index 0000000000..df170af051 --- /dev/null +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/ParameterSerializer.java @@ -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); +} diff --git a/bgp/pom.xml b/bgp/pom.xml index eb217cc512..157e3747dd 100644 --- a/bgp/pom.xml +++ b/bgp/pom.xml @@ -20,6 +20,7 @@ concepts linkstate parser-api + parser-spi parser-impl parser-mock rib-api diff --git a/bgp/rib-impl/pom.xml b/bgp/rib-impl/pom.xml index c52971d2cf..2f09b9d59c 100644 --- a/bgp/rib-impl/pom.xml +++ b/bgp/rib-impl/pom.xml @@ -146,7 +146,6 @@ 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, diff --git a/bgp/rib-mock/pom.xml b/bgp/rib-mock/pom.xml index c28686e557..c6440b7f1f 100644 --- a/bgp/rib-mock/pom.xml +++ b/bgp/rib-mock/pom.xml @@ -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 index 0000000000..d663e6e669 --- /dev/null +++ b/integration-tests/src/test/java/org/opendaylight/protocol/integration/BgpParserSpiBundleTest.java @@ -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 prerequisiteBundles() { + return Lists.newArrayList("bgp-concepts", "bgp-parser-api", "bgp-util", "concepts", "framework", "util"); + } + + @Override + protected Collection requiredBundles() { + return Lists.newArrayList("bgp-parser-spi"); + } +}