Hi,
Not sure if this is specific to Idempiere, but I have found the following behaviour:
Background:
I tried to be clever and separate out some utility methods. I put them in a different package in the same src folder. The code is pretty innocuous:
package au.blindmot.utils;
import java.util.ArrayList;
import org.compiere.util.DB;
public class MtmUtils {
// Prefixes for bar codes based on table_id - to shorten barcodes
public static final String MTM_PRODUCTION_PREFIX = "01";
public static final String MTM_PRODUCTION_ITEM_PREFIX = "02";
public static final String MTM_PRODUCTION_ASSEMBLEY_ITEM = "03";
public static final String MTM_HEAD_RAIL_DEDUCTION = "Head Rail Deduction";
public static final String MTM_FABRIC_DEDUCTION = "Fabric deduction";
public static final String MTM_FABRIC_ADDITION = "Fabric length addition";
public static final String MTM_BOTTOM_BAR_DEDUCTION = "Bottom bar deduction";
public MtmUtils() {
// TODO Auto-generated constructor stub
}
public String getBarcode(int table_id, int record_id) {
String prefix = getBarcodePrefix(table_id);
if (prefix != null) {
StringBuffer barCode = new StringBuffer(prefix);
return barCode.append(record_id).toString();
} else
return null;
}
private String getBarcodePrefix(int table_id) {
StringBuffer sql = new StringBuffer();
sql.append("SELECT name ");
sql.append("FROM ad_table ");
sql.append("WHERE ad_table_id = ?");
String tableName = DB.getSQLValueStringEx(null, sql.toString(), table_id);
String prefix = null;
if (tableName.equalsIgnoreCase("Made to measure production")) {
prefix = MTM_PRODUCTION_PREFIX;
} else if (tableName.equalsIgnoreCase("Made to measure items")) {
prefix = MTM_PRODUCTION_ITEM_PREFIX;
} else if (tableName.equalsIgnoreCase("Made to measure cuts")) {
prefix = MTM_PRODUCTION_ASSEMBLEY_ITEM;
}
return prefix;
}
When this code is called from the class in the
au.blindmot.model package, the system slows to a crawl, with some thread timeouts occurring. Seems like a hung thread? It does this every time the
getBarcode(int table_id, int record_id) is called from outside its own package.
When the code is placed into a class in
au.blindmot.model no slow down occurs. I tried to run the methods as static and got the same result - it seems to be where the code is located.
Anyone know why this is occurring?