* [ 1686464 ] Lookup of PO class is not cache
This commit is contained in:
parent
1a38ecddf2
commit
2e6c1af3dc
|
@ -123,6 +123,8 @@ public class MTable extends X_AD_Table
|
||||||
|
|
||||||
/** Cache */
|
/** Cache */
|
||||||
private static CCache<Integer,MTable> s_cache = new CCache<Integer,MTable>("AD_Table", 20);
|
private static CCache<Integer,MTable> s_cache = new CCache<Integer,MTable>("AD_Table", 20);
|
||||||
|
private static CCache<String,Class> s_classCache = new CCache<String,Class>("PO_Class", 20);
|
||||||
|
|
||||||
/** Static Logger */
|
/** Static Logger */
|
||||||
private static CLogger s_log = CLogger.getCLogger (MTable.class);
|
private static CLogger s_log = CLogger.getCLogger (MTable.class);
|
||||||
|
|
||||||
|
@ -169,6 +171,16 @@ public class MTable extends X_AD_Table
|
||||||
return null;
|
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
|
// Special Naming
|
||||||
for (int i = 0; i < s_special.length; i++)
|
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]);
|
Class clazz = getPOclass(s_special[i]);
|
||||||
if (clazz != null)
|
if (clazz != null)
|
||||||
|
{
|
||||||
|
s_classCache.put(tableName, clazz);
|
||||||
return clazz;
|
return clazz;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,25 +222,39 @@ public class MTable extends X_AD_Table
|
||||||
StringBuffer name = new StringBuffer(s_packages[i]).append(".M").append(className);
|
StringBuffer name = new StringBuffer(s_packages[i]).append(".M").append(className);
|
||||||
Class clazz = getPOclass(name.toString());
|
Class clazz = getPOclass(name.toString());
|
||||||
if (clazz != null)
|
if (clazz != null)
|
||||||
|
{
|
||||||
|
s_classCache.put(tableName, clazz);
|
||||||
return clazz;
|
return clazz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adempiere Extension
|
// Adempiere Extension
|
||||||
Class clazz = getPOclass("adempiere.model.X_" + tableName);
|
Class clazz = getPOclass("adempiere.model.X_" + tableName);
|
||||||
if (clazz != null)
|
if (clazz != null)
|
||||||
|
{
|
||||||
|
s_classCache.put(tableName, clazz);
|
||||||
return clazz;
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
//hengsin - allow compatibility with compiere plugins
|
//hengsin - allow compatibility with compiere plugins
|
||||||
//Compiere Extension
|
//Compiere Extension
|
||||||
clazz = getPOclass("compiere.model.X_" + tableName);
|
clazz = getPOclass("compiere.model.X_" + tableName);
|
||||||
if (clazz != null)
|
if (clazz != null)
|
||||||
|
{
|
||||||
|
s_classCache.put(tableName, clazz);
|
||||||
return clazz;
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
clazz = getPOclass("org.compiere.model.X_" + tableName);
|
clazz = getPOclass("org.compiere.model.X_" + tableName);
|
||||||
if (clazz != null)
|
if (clazz != null)
|
||||||
|
{
|
||||||
|
s_classCache.put(tableName, clazz);
|
||||||
return clazz;
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Object.class to indicate no PO class for tableName
|
||||||
|
s_classCache.put(tableName, Object.class);
|
||||||
return null;
|
return null;
|
||||||
} // getClass
|
} // getClass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue