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

com.jn.agileway.http.rr.RRLocal Maven / Gradle / Ivy

There is a newer version: 5.0.4
Show newest version
package com.jn.agileway.http.rr;

import com.jn.langx.annotation.Singleton;

@Singleton
public class RRLocal {
    private static final RRLocal instance;
    private static final ThreadLocal rr;

    static {
        rr = new ThreadLocal();
        instance = new RRLocal();
    }

    public static RRLocal getInstance() {
        return RRLocal.instance;
    }

    public static HttpResponse getResponse() {
        return rr.get().getResponse();
    }

    public static HttpRequest getRequest() {
        return rr.get().getRequest();
    }

    public static void set(final HttpRequest request, final HttpResponse response) {
        RR r = rr.get();
        if (r == null) {
            rr.set(new RR(request, response));
        } else {
            r.setRequest(request);
            r.setResponse(response);
        }
    }

    public static RR get() {
        return rr.get();
    }

    public static void remove() {
        rr.remove();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy