2 * Copyright (c) 2014 Cisco 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.mdsal.binding.generator.impl;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
12 import org.opendaylight.mdsal.binding.model.api.Type;
13 import org.opendaylight.yangtools.util.ClassLoaderUtils;
15 public abstract class GeneratedClassLoadingStrategy implements ClassLoadingStrategy {
16 private static final class AlwaysFailClassLoadingStrategy extends GeneratedClassLoadingStrategy {
17 static final @NonNull AlwaysFailClassLoadingStrategy INSTANCE = new AlwaysFailClassLoadingStrategy();
20 public Class<?> loadClass(final String fullyQualifiedName) throws ClassNotFoundException {
21 throw new ClassNotFoundException(fullyQualifiedName);
25 private static final class TCCLClassLoadingStrategy extends GeneratedClassLoadingStrategy {
26 static final @NonNull TCCLClassLoadingStrategy INSTANCE = new TCCLClassLoadingStrategy();
29 public Class<?> loadClass(final String fullyQualifiedName) throws ClassNotFoundException {
30 return ClassLoaderUtils.loadClassWithTCCL(fullyQualifiedName);
34 protected GeneratedClassLoadingStrategy() {
38 public static final @NonNull GeneratedClassLoadingStrategy getTCCLClassLoadingStrategy() {
39 return TCCLClassLoadingStrategy.INSTANCE;
42 public static final @NonNull GeneratedClassLoadingStrategy getAlwaysFailClassLoadingStrategy() {
43 return AlwaysFailClassLoadingStrategy.INSTANCE;
47 public Class<?> loadClass(final Type type) throws ClassNotFoundException {
48 return loadClass(type.getFullyQualifiedName());