2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.binding.impl;
10 import javassist.ClassPool;
11 import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator;
12 import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
13 import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
14 import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
15 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
20 * Factory class for creating and initializing the BindingToNormalizedNodeCodec instances.
22 * @author Thomas Pantelis
24 public final class BindingToNormalizedNodeCodecFactory {
25 private static final JavassistUtils JAVASSIST = JavassistUtils.forClassPool(ClassPool.getDefault());
27 private BindingToNormalizedNodeCodecFactory() {
31 * Creates a new BindingToNormalizedNodeCodec instance.
33 * @param classLoadingStrategy the ClassLoadingStrategy
34 * @return the BindingToNormalizedNodeCodec instance
36 public static BindingToNormalizedNodeCodec newInstance(final ClassLoadingStrategy classLoadingStrategy) {
37 final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(
38 StreamWriterGenerator.create(JAVASSIST));
39 return new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry, true);
43 * Registers the given instance with the SchemaService as a SchemaContextListener.
45 * @param instance the BindingToNormalizedNodeCodec instance
46 * @param schemaService the SchemaService.
47 * @return the ListenerRegistration
49 public static ListenerRegistration<SchemaContextListener> registerInstance(
50 final BindingToNormalizedNodeCodec instance, final DOMSchemaService schemaService) {
51 return schemaService.registerSchemaContextListener(instance);