Deprecate binding.runtime.spi constructs
[mdsal.git] / binding / mdsal-binding-runtime-spi / src / main / java / org / opendaylight / binding / runtime / spi / GeneratedClassLoadingStrategy.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.binding.runtime.spi;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.binding.runtime.api.ClassLoadingStrategy;
13 import org.opendaylight.yangtools.util.ClassLoaderUtils;
14
15 @Beta
16 @Deprecated(forRemoval = true)
17 public abstract class GeneratedClassLoadingStrategy implements ClassLoadingStrategy {
18     private static final class AlwaysFailClassLoadingStrategy extends GeneratedClassLoadingStrategy {
19         static final @NonNull AlwaysFailClassLoadingStrategy INSTANCE = new AlwaysFailClassLoadingStrategy();
20
21         @Override
22         public Class<?> loadClass(final String fullyQualifiedName) throws ClassNotFoundException {
23             throw new ClassNotFoundException(fullyQualifiedName);
24         }
25     }
26
27     private static final class TCCLClassLoadingStrategy extends GeneratedClassLoadingStrategy {
28         static final @NonNull TCCLClassLoadingStrategy INSTANCE = new TCCLClassLoadingStrategy();
29
30         @Override
31         public Class<?> loadClass(final String fullyQualifiedName) throws ClassNotFoundException {
32             return ClassLoaderUtils.loadClassWithTCCL(fullyQualifiedName);
33         }
34     }
35
36     protected GeneratedClassLoadingStrategy() {
37
38     }
39
40     public static final @NonNull GeneratedClassLoadingStrategy getTCCLClassLoadingStrategy() {
41         return TCCLClassLoadingStrategy.INSTANCE;
42     }
43
44     public static final @NonNull GeneratedClassLoadingStrategy getAlwaysFailClassLoadingStrategy() {
45         return AlwaysFailClassLoadingStrategy.INSTANCE;
46     }
47 }