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

com.mg.common.context.MgServerContext Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.mg.common.context;

import com.mg.common.entity.InstanceEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * 缓存单台服务器的一些上下文对象
 */
public class MgServerContext {
    private static Logger logger = LoggerFactory.getLogger(MgServerContext.class);

    protected static Map instanceMap = new HashMap<>();

    public static Map getInstanceMap() {
        return instanceMap;
    }

    public static InstanceEntity getInstance(String id) {
        if(instanceMap.containsKey(id)) {
            return instanceMap.get(id);
        }
        else {
            return null;
        }
    }

    public static void setInstance(String id,InstanceEntity instanceEntity) {
        instanceMap.put(id,instanceEntity);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy