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

org.specsy.bootstrap.ContextDealer Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
// Copyright © 2010-2012, Esko Luontola 
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package org.specsy.bootstrap;

import org.specsy.core.Context;

public class ContextDealer {

    private static final ThreadLocal prepared = new ThreadLocal<>();

    public static void prepare(Context context) {
        prepared.set(context);
    }

    public static Context take() {
        Context context = prepared.get();
        if (context == null) {
            throw new IllegalStateException("tried to take the context before it was prepared");
        }
        prepared.remove();
        return context;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy