package com.abstratt.kirra.rest.common;

import java.net.URI;

import com.abstratt.kirra.InstanceManagement;
import com.abstratt.kirra.SchemaManagement;

public class KirraContext {
    public static URI getBaseURI() {
        return KirraContext.baseURI.get();
    }

    public static InstanceManagement getInstanceManagement() {
        return KirraContext.instanceManagement.get();
    }

    public static SchemaManagement getSchemaManagement() {
        return KirraContext.schemaManagement.get();
    }

    public static void setBaseURI(URI newValue) {
        KirraContext.setOrClear(KirraContext.baseURI, newValue);
    }

    public static void setInstanceManagement(InstanceManagement newValue) {
        KirraContext.setOrClear(KirraContext.instanceManagement, newValue);
    }

    public static void setSchemaManagement(SchemaManagement newValue) {
        KirraContext.setOrClear(KirraContext.schemaManagement, newValue);
    }

    private static <T> void setOrClear(ThreadLocal<T> slot, T newValue) {
        if (newValue == null)
            slot.remove();
        else
            slot.set(newValue);
    }

    private static ThreadLocal<URI> baseURI = new ThreadLocal<URI>();

    private static ThreadLocal<InstanceManagement> instanceManagement = new ThreadLocal<InstanceManagement>();

    private static ThreadLocal<SchemaManagement> schemaManagement = new ThreadLocal<SchemaManagement>();
}

@@ -496,32 +496,126 @@
 t.get();%0A    %7D%0A%0A
+    public static String getEnvironment() %7B%0A    %09return KirraContext.environment.get();%0A    %7D%0A
     public stati
@@ -711,32 +711,170 @@
 ewValue);%0A    %7D%0A
+    %0A    public static void setEnvironment(String newValue) %7B%0A        KirraContext.setOrClear(KirraContext.environment, newValue);%0A    %7D%0A%0A
 %0A    public stat
@@ -1345,32 +1345,117 @@
 wValue);%0A    %7D%0A%0A
+    private static ThreadLocal%3CString%3E environment = new ThreadLocal%3CString%3E();%0A    %0A
     private stat
@@ -1726,10 +1726,11 @@
 ent%3E();%0A
+%0A
 %7D%0A

allow separating prototype/production/test data sets