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 org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
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.dom.api.DOMSchemaService;
15 import org.opendaylight.yangtools.concepts.ListenerRegistration;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
19 * Factory class for creating and initializing the BindingToNormalizedNodeCodec instances.
21 * @author Thomas Pantelis
23 public final class BindingToNormalizedNodeCodecFactory {
24 private BindingToNormalizedNodeCodecFactory() {
28 * Creates a new BindingToNormalizedNodeCodec instance.
30 * @param classLoadingStrategy the ClassLoadingStrategy
31 * @return the BindingToNormalizedNodeCodec instance
33 public static BindingToNormalizedNodeCodec newInstance(final ClassLoadingStrategy classLoadingStrategy) {
34 final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(
35 StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
36 return new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry, true);
40 * Registers the given instance with the SchemaService as a SchemaContextListener.
42 * @param instance the BindingToNormalizedNodeCodec instance
43 * @param schemaService the SchemaService.
44 * @return the ListenerRegistration
46 public static ListenerRegistration<SchemaContextListener> registerInstance(
47 final BindingToNormalizedNodeCodec instance, final DOMSchemaService schemaService) {
48 return schemaService.registerSchemaContextListener(instance);