From b16cea20258ba537db7c0755208c82ab93331ff7 Mon Sep 17 00:00:00 2001 From: Michal Cmarada Date: Mon, 8 Apr 2019 11:37:45 +0200 Subject: HONEYCOMB-443: ODL bump to Neon - bumps ODL dependencies to neon - migrates guava optional to java.utils.optional Change-Id: Ibdaa365c7e21a341103aba88dfd67277e40d2969 Signed-off-by: Michal Cmarada --- .../distro/schema/LegacySerializerProvider.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/LegacySerializerProvider.java (limited to 'infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/LegacySerializerProvider.java') diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/LegacySerializerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/LegacySerializerProvider.java new file mode 100644 index 000000000..cc6c376c6 --- /dev/null +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/LegacySerializerProvider.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.distro.schema; + +import com.google.inject.Inject; +import io.fd.honeycomb.binding.init.ProviderTrait; +import javassist.ClassPool; +import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.mdsal.binding.dom.codec.gen.impl.DataObjectSerializerGenerator; +import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator; +import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext; +import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; + +public class LegacySerializerProvider extends ProviderTrait { + + @Inject + private ModuleInfoBackedContext mibCtx; + + @Override + protected BindingToNormalizedNodeCodec create() { + final DataObjectSerializerGenerator serializerGenerator = + StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault())); + + BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(serializerGenerator); + BindingRuntimeContext ctx = BindingRuntimeContext.create(mibCtx, mibCtx.getSchemaContext()); + codecRegistry.onBindingRuntimeContextUpdated(ctx); + BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(mibCtx, codecRegistry); + codec.onGlobalContextUpdated(mibCtx.getSchemaContext()); + return codec; + } +} -- cgit 1.2.3-korg