From 2e6c1af3dc35d5bb99d134903551c426e9867786 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sun, 25 Mar 2007 09:52:52 +0000 Subject: [PATCH] * [ 1686464 ] Lookup of PO class is not cache --- dbPort/src/org/compiere/model/MTable.java | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dbPort/src/org/compiere/model/MTable.java b/dbPort/src/org/compiere/model/MTable.java index 53c4a04a1b..c0a264d862 100644 --- a/dbPort/src/org/compiere/model/MTable.java +++ b/dbPort/src/org/compiere/model/MTable.java @@ -123,6 +123,8 @@ public class MTable extends X_AD_Table /** Cache */ private static CCache s_cache = new CCache("AD_Table", 20); + private static CCache s_classCache = new CCache("PO_Class", 20); + /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MTable.class); @@ -169,6 +171,16 @@ public class MTable extends X_AD_Table return null; } + //check cache + Class cache = s_classCache.get(tableName); + if (cache != null) + { + //Object.class indicate no PO class for tableName + if (cache.equals(Object.class)) + return null; + else + return cache; + } // Special Naming for (int i = 0; i < s_special.length; i++) @@ -177,7 +189,10 @@ public class MTable extends X_AD_Table { Class clazz = getPOclass(s_special[i]); if (clazz != null) + { + s_classCache.put(tableName, clazz); return clazz; + } break; } } @@ -207,25 +222,39 @@ public class MTable extends X_AD_Table StringBuffer name = new StringBuffer(s_packages[i]).append(".M").append(className); Class clazz = getPOclass(name.toString()); if (clazz != null) + { + s_classCache.put(tableName, clazz); return clazz; + } } // Adempiere Extension Class clazz = getPOclass("adempiere.model.X_" + tableName); if (clazz != null) + { + s_classCache.put(tableName, clazz); return clazz; + } //hengsin - allow compatibility with compiere plugins //Compiere Extension clazz = getPOclass("compiere.model.X_" + tableName); if (clazz != null) + { + s_classCache.put(tableName, clazz); return clazz; + } // Default clazz = getPOclass("org.compiere.model.X_" + tableName); if (clazz != null) + { + s_classCache.put(tableName, clazz); return clazz; + } + //Object.class to indicate no PO class for tableName + s_classCache.put(tableName, Object.class); return null; } // getClass