package com.eactive.eai.common.worker;

import java.util.concurrent.ConcurrentHashMap;

public class ResponseMap {

	private volatile static ResponseMap singleton;

	private static ConcurrentHashMap<String, Future> responseMap = new ConcurrentHashMap<String, Future>();

	private ResponseMap() {
//		System.out.println("Create ResponseMap...");
	}

	public static ResponseMap getInstance() {
		if (singleton == null) {
			synchronized (ResponseMap.class) {
				if (singleton == null) {
					singleton = new ResponseMap();
				}
			}
		}
		return singleton;
	}

	public void put(String key, Future future) {
		responseMap.put(key, future);
	}

	public Future get(String key) {
		return responseMap.remove(key);
	}

	public boolean containsKey(String key) {
		return responseMap.containsKey(key);
	}

}
