BF [ 1964738 ] MAlertProcessor should use CCache

This commit is contained in:
teo_sarca 2008-05-15 17:57:59 +00:00
parent 5d6eae4868
commit c7e00408b0
1 changed files with 10 additions and 7 deletions

View File

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -94,8 +95,8 @@ public class MAlertProcessor extends X_AD_AlertProcessor
super(ctx, rs, trxName); super(ctx, rs, trxName);
} // MAlertProcessor } // MAlertProcessor
/** The Alerts */ /** Cache: AD_AlertProcessor -> Alerts array */
private MAlert[] m_alerts = null; private static CCache<Integer, MAlert[]> s_cacheAlerts = new CCache<Integer, MAlert[]>("AD_Alert_ForProcessor", 10);
/** /**
* Get Server ID * Get Server ID
@ -176,8 +177,9 @@ public class MAlertProcessor extends X_AD_AlertProcessor
*/ */
public MAlert[] getAlerts (boolean reload) public MAlert[] getAlerts (boolean reload)
{ {
if (m_alerts != null && !reload) MAlert[] alerts = s_cacheAlerts.get(get_ID());
return m_alerts; if (alerts != null && !reload)
return alerts;
String sql = "SELECT * FROM AD_Alert " String sql = "SELECT * FROM AD_Alert "
+ "WHERE AD_AlertProcessor_ID=?"; + "WHERE AD_AlertProcessor_ID=?";
ArrayList<MAlert> list = new ArrayList<MAlert>(); ArrayList<MAlert> list = new ArrayList<MAlert>();
@ -201,9 +203,10 @@ public class MAlertProcessor extends X_AD_AlertProcessor
rs = null; pstmt = null; rs = null; pstmt = null;
} }
// //
m_alerts = new MAlert[list.size ()]; alerts = new MAlert[list.size ()];
list.toArray (m_alerts); list.toArray (alerts);
return m_alerts; s_cacheAlerts.put(get_ID(), alerts);
return alerts;
} // getAlerts } // getAlerts
} // MAlertProcessor } // MAlertProcessor