All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.undefinedlabs.scope.bootstrap.ContextTrampoline Maven / Gradle / Ivy

package com.undefinedlabs.scope.bootstrap;

import java.util.concurrent.Callable;

public final class ContextTrampoline {

    private static ContextStrategy contextStrategy;

    private ContextTrampoline() {
    }

    public static void setContextStrategy(ContextStrategy contextStrategy) {
        if (ContextTrampoline.contextStrategy != null) {
            throw new IllegalStateException("contextStrategy was already set");
        }

        if (contextStrategy == null) {
            throw new NullPointerException("contextStrategy");
        }

        ContextTrampoline.contextStrategy = contextStrategy;
    }

    public static Callable wrapInCurrentContext(Callable callable) {
        return contextStrategy.wrapInCurrentContext(callable);
    }

    public static Runnable wrapInCurrentContext(Runnable runnable) {
        return contextStrategy.wrapInCurrentContext(runnable);
    }

    public static void saveContextForThread(Thread thread) {
        contextStrategy.saveContextForThread(thread);
    }

    public static void attachContextForThread(Thread thread) {
        contextStrategy.attachContextForThread(thread);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy