package frame.data.meta; import java.util.HashMap; import java.util.Map; public class MetaContainer { private static MetaContainer instance; private Map metaMap; private MetaContainer() { metaMap = new HashMap(); } public static synchronized MetaContainer getInstance() { if (instance == null) { instance = new MetaContainer(); } return instance; } public static EntityMeta get(String entityName) throws Exception { return instance.doGet(entityName, false); } public static EntityMeta get(String entityName, boolean refresh) throws Exception { return instance.doGet(entityName, refresh); } public EntityMeta doGet(String tableName, boolean refresh) throws Exception { if (tableName == null) { return null; } tableName = tableName.toLowerCase(); EntityMeta meta = metaMap.get(tableName); if (refresh || meta == null) { MetaDataLoader metaDataLoader = new MetaDataLoader(tableName); EntityMeta newMeta = metaDataLoader.getEntityMeta(); metaMap.put(tableName.toLowerCase(), newMeta); meta = newMeta; } return meta; } }