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.yangtools.sal.binding.generator.impl;
10 import org.opendaylight.yangtools.sal.binding.generator.util.ClassLoaderUtils;
11 import org.opendaylight.yangtools.sal.binding.model.api.Type;
13 public abstract class GeneratedClassLoadingStrategy {
15 private static final GeneratedClassLoadingStrategy TCCL_STRATEGY = new TCCLClassLoadingStrategy();
17 private static final GeneratedClassLoadingStrategy ALWAYS_FAIL_STRATEGY = new GeneratedClassLoadingStrategy() {
20 public Class<?> loadClass(String fullyQualifiedName) throws ClassNotFoundException {
21 throw new ClassNotFoundException(fullyQualifiedName);
25 public Class<?> loadClass(Type type) throws ClassNotFoundException {
26 return loadClass(type.getFullyQualifiedName());
29 public abstract Class<?> loadClass(String fullyQualifiedName) throws ClassNotFoundException;
31 public static final GeneratedClassLoadingStrategy getTCCLClassLoadingStrategy() {
35 public static final GeneratedClassLoadingStrategy getAlwaysFailClassLoadingStrategy() {
36 return ALWAYS_FAIL_STRATEGY;
39 private static final class TCCLClassLoadingStrategy extends GeneratedClassLoadingStrategy {
42 public Class<?> loadClass(String fullyQualifiedName) throws ClassNotFoundException {
43 return ClassLoaderUtils.loadClassWithTCCL(fullyQualifiedName);