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.api.ClassLoadingStrategy;
11 import org.opendaylight.yangtools.sal.binding.generator.util.ClassLoaderUtils;
12 import org.opendaylight.yangtools.sal.binding.model.api.Type;
14 public abstract class GeneratedClassLoadingStrategy implements ClassLoadingStrategy {
16 private static final GeneratedClassLoadingStrategy TCCL_STRATEGY = new TCCLClassLoadingStrategy();
18 private static final GeneratedClassLoadingStrategy ALWAYS_FAIL_STRATEGY = new GeneratedClassLoadingStrategy() {
21 public Class<?> loadClass(String fullyQualifiedName) throws ClassNotFoundException {
22 throw new ClassNotFoundException(fullyQualifiedName);
26 public Class<?> loadClass(Type type) throws ClassNotFoundException {
27 return loadClass(type.getFullyQualifiedName());
30 public abstract Class<?> loadClass(String fullyQualifiedName) throws ClassNotFoundException;
32 public static final GeneratedClassLoadingStrategy getTCCLClassLoadingStrategy() {
36 public static final GeneratedClassLoadingStrategy getAlwaysFailClassLoadingStrategy() {
37 return ALWAYS_FAIL_STRATEGY;
40 private static final class TCCLClassLoadingStrategy extends GeneratedClassLoadingStrategy {
43 public Class<?> loadClass(String fullyQualifiedName) throws ClassNotFoundException {
44 return ClassLoaderUtils.loadClassWithTCCL(fullyQualifiedName);