import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import java.util.Set;
+import org.opendaylight.protocol.bgp.rib.impl.spi.Codecs;
import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.ClusterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.OriginatorId;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-public final class Codecs {
+public final class CodecsImpl implements Codecs {
private static final Set<Class<? extends DataObject>> ATTRIBUTE_CACHEABLES;
private static final InstanceIdentifier<Tables> TABLE_BASE_II = InstanceIdentifier.builder(BgpRib.class)
private final RIBSupport ribSupport;
- public Codecs(final RIBSupport ribSupport) {
+ public CodecsImpl(final RIBSupport ribSupport) {
this.ribSupport = Preconditions.checkNotNull(ribSupport);
final Builder<Class<? extends DataObject>> acb = ImmutableSet.builder();
acb.addAll(ATTRIBUTE_CACHEABLES);
this.cacheableAttributes = acb.build();
}
+ @Override
@SuppressWarnings("unchecked")
- void onCodecTreeUpdated(final BindingCodecTree tree) {
+ public void onCodecTreeUpdated(final BindingCodecTree tree) {
@SuppressWarnings("rawtypes")
final BindingCodecTreeNode tableCodecContext = tree.getSubtreeCodec(TABLE_BASE_II);
this.unreachNlriCodec = tree.getSubtreeCodec(MP_UNREACH_NLRI_II).createCachingCodec(this.ribSupport.cacheableNlriObjects());
}
- ContainerNode serializeUnreachNlri(final MpUnreachNlri nlri) {
+ @Override
+ public ContainerNode serializeUnreachNlri(final MpUnreachNlri nlri) {
Preconditions.checkState(this.unreachNlriCodec != null, "MpReachNlri codec not available");
return (ContainerNode) this.unreachNlriCodec.serialize(nlri);
}
- ContainerNode serializeReachNlri(final MpReachNlri nlri) {
+ @Override
+ public ContainerNode serializeReachNlri(final MpReachNlri nlri) {
Preconditions.checkState(this.reachNlriCodec != null, "MpReachNlri codec not available");
return (ContainerNode) this.reachNlriCodec.serialize(nlri);
}
- Attributes deserializeAttributes(final NormalizedNode<?,?> attributes) {
+ @Override
+ public Attributes deserializeAttributes(final NormalizedNode<?,?> attributes) {
Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
return this.attributesCodec.deserialize(attributes);
}
- ContainerNode serializeAttributes(final Attributes pathAttr) {
+ @Override
+ public ContainerNode serializeAttributes(final Attributes pathAttr) {
Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
final AttributesBuilder a = new AttributesBuilder(pathAttr);
a.addAugmentation(Attributes1.class, null);
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import org.opendaylight.protocol.bgp.rib.impl.spi.Codecs;
import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTree;
}
private Codecs createContext(final RIBSupport ribSupport) {
- final Codecs codecs = new Codecs(ribSupport);
+ final Codecs codecs = new CodecsImpl(ribSupport);
if (this.latestCodecTree != null) {
// FIXME: Do we need to recalculate latestCodecTree? E.g. new rib support was added
// after bgp was started.
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rib.impl.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTree;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Common interface for Codecs classes.
+ *
+ */
+public interface Codecs {
+ /**
+ * Called when Codec tree is updated. Implementations should
+ * refresh codec context.
+ *
+ * @param tree BindingCodecTree
+ */
+ void onCodecTreeUpdated(final BindingCodecTree tree);
+
+ ContainerNode serializeUnreachNlri(final MpUnreachNlri nlri);
+
+ ContainerNode serializeReachNlri(final MpReachNlri nlri);
+
+ Attributes deserializeAttributes(final NormalizedNode<?,?> attributes);
+
+ ContainerNode serializeAttributes(final Attributes pathAttr);
+}