Created
March 2, 2012 19:25
-
-
Save blangel/1960632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static net.ocheyedan.clapi.ClApi; | |
// class structure removed for brevity | |
void usageExample { | |
using(ThriftVersion.2); | |
callCodeDependingUponThriftVersion2(); | |
using(ThriftVersion.3); | |
callCodeDependingUponThriftVersion3(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class ClApi extends URLClassLoader { | |
private static final ClApi instance = new ClApi(); // or injected | |
public static void using(Version version) { | |
instance.using.set(version); | |
} | |
// created in init from some yaml file or something which links (auto-generated?) Version (i.e., ThriftVersion.2) | |
// to the appropriate ClassLoader | |
private final ImmutableMap<Version, ClassLoader> config; | |
// this class would become the system-classloader and it would contain all non-multi-versioned jars but then | |
// delegate to those ClassLoader's in {@link #config} depending upon what's set in the ThreadLocal {@link #using} variable. | |
private final ThreadLocal<Version> using; | |
private ClApi() { } | |
} | |
public interface Version { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment