diff --git a/lib/artifacts.xml b/lib/artifacts.xml new file mode 100644 index 0000000000..e71089ceb5 --- /dev/null +++ b/lib/artifacts.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/content.xml b/lib/content.xml new file mode 100644 index 0000000000..e78a905931 --- /dev/null +++ b/lib/content.xml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bundle-SymbolicName: com.springsource.javax.mail Bundle-Version: 1.4.5 + + + + + + + + + + + + + + + + + + + + + + + Bundle-SymbolicName: com.springsource.javax.activation Bundle-Version: 1.1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bundle-SymbolicName: org.apache.poi Bundle-Version: 3.7.0 + + + + + + diff --git a/lib/generatep2.txt b/lib/generatep2.txt new file mode 100644 index 0000000000..f830726d41 --- /dev/null +++ b/lib/generatep2.txt @@ -0,0 +1,2 @@ +eclipse -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file://lib -artifactRepository file://lib -source lib -publishArtifact + diff --git a/org.adempiere.base.process/src/org/compiere/process/CacheReset.java b/org.adempiere.base.process/src/org/compiere/process/CacheReset.java index 71d5f1c1c4..9a6fb2cbcf 100644 --- a/org.adempiere.base.process/src/org/compiere/process/CacheReset.java +++ b/org.adempiere.base.process/src/org/compiere/process/CacheReset.java @@ -16,6 +16,7 @@ *****************************************************************************/ package org.compiere.process; +import org.compiere.util.CacheMgt; import org.compiere.util.Env; /** @@ -43,6 +44,7 @@ public class CacheReset extends SvrProcess implements ClientProcess { log.info(""); Env.reset(false); // not final + CacheMgt.get().reset(); return "Cache Reset"; } // doIt diff --git a/org.adempiere.base.process/src/org/compiere/process/HashPasswords.java b/org.adempiere.base.process/src/org/compiere/process/HashPasswords.java index 1ecdced41c..ff195f88dc 100644 --- a/org.adempiere.base.process/src/org/compiere/process/HashPasswords.java +++ b/org.adempiere.base.process/src/org/compiere/process/HashPasswords.java @@ -23,6 +23,7 @@ import org.compiere.model.MSysConfig; import org.compiere.model.MTable; import org.compiere.model.MUser; import org.compiere.model.SystemIDs; +import org.compiere.util.CacheMgt; /** * Hash existing passwords @@ -54,7 +55,7 @@ public class HashPasswords extends SvrProcess MSysConfig conf = new MSysConfig(getCtx(), SystemIDs.SYSCONFIG_USER_HASH_PASSWORD, null); conf.setValue("Y"); conf.saveEx(); - MSysConfig.resetCache(); + CacheMgt.get().reset(MSysConfig.Table_Name); int count = 0; try { diff --git a/org.adempiere.base/META-INF/MANIFEST.MF b/org.adempiere.base/META-INF/MANIFEST.MF index 3a71ae21d1..e21a2ebef5 100644 --- a/org.adempiere.base/META-INF/MANIFEST.MF +++ b/org.adempiere.base/META-INF/MANIFEST.MF @@ -184,6 +184,7 @@ Export-Package: bsh, org.compiere.util, org.compiere.wf, org.eevolution.model, + org.idempiere.distributed, org.jfree, org.jfree.base, org.jfree.base.config, diff --git a/org.adempiere.base/src/org/adempiere/base/Core.java b/org.adempiere.base/src/org/adempiere/base/Core.java index b666371e8a..306c17980a 100644 --- a/org.adempiere.base/src/org/adempiere/base/Core.java +++ b/org.adempiere.base/src/org/adempiere/base/Core.java @@ -81,7 +81,16 @@ public class Core { * @return ProcessCall instance or null if serviceId not found */ public static ProcessCall getProcess(String serviceId) { - return Service.locator().locate(ProcessCall.class, "org.adempiere.base.Process", serviceId, null).getService(); + ProcessCall process = null; + List factories = Service.locator().list(IProcessFactory.class).getServices(); + if (factories != null && !factories.isEmpty()) { + for(IProcessFactory factory : factories) { + process = factory.newProcessInstance(serviceId); + if (process != null) + return process; + } + } + return Service.locator().locate(ProcessCall.class, "org.adempiere.base.Process", serviceId, null).getService(); } /** diff --git a/org.adempiere.base/src/org/adempiere/base/DefaultModelFactory.java b/org.adempiere.base/src/org/adempiere/base/DefaultModelFactory.java index c4c9a9fb05..cf53ee176c 100644 --- a/org.adempiere.base/src/org/adempiere/base/DefaultModelFactory.java +++ b/org.adempiere.base/src/org/adempiere/base/DefaultModelFactory.java @@ -37,7 +37,7 @@ import org.compiere.util.Util; */ public class DefaultModelFactory implements IModelFactory { - private static CCache> s_classCache = new CCache>("PO_Class", 20); + private static CCache> s_classCache = new CCache>(null, "PO_Class", 20, false); private final static CLogger s_log = CLogger.getCLogger(DefaultModelFactory.class); /** Packages for Model Classes */ diff --git a/org.adempiere.base/src/org/adempiere/base/IProcessFactory.java b/org.adempiere.base/src/org/adempiere/base/IProcessFactory.java new file mode 100644 index 0000000000..3f71656a96 --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/IProcessFactory.java @@ -0,0 +1,32 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.base; + +import org.compiere.process.ProcessCall; + +/** + * + * @author hengsin + * + */ +public interface IProcessFactory { + + /** + * Create new process instance + * @param className + * @return new process instance + */ + public ProcessCall newProcessInstance(String className); + +} diff --git a/org.adempiere.base/src/org/compiere/Adempiere.java b/org.adempiere.base/src/org/compiere/Adempiere.java index b30722ce88..73ad45a85a 100644 --- a/org.adempiere.base/src/org/compiere/Adempiere.java +++ b/org.adempiere.base/src/org/compiere/Adempiere.java @@ -686,7 +686,7 @@ public final class Adempiere m_listenerList.add(ServerStateChangeListener.class, l); } - private static void fireServerStateChanged(ServerStateChangeEvent e) + private static synchronized void fireServerStateChanged(ServerStateChangeEvent e) { ServerStateChangeListener[] listeners = m_listenerList.getListeners(ServerStateChangeListener.class); for (int i = 0; i < listeners.length; i++) diff --git a/org.adempiere.base/src/org/compiere/model/MAcctSchema.java b/org.adempiere.base/src/org/compiere/model/MAcctSchema.java index 0540f42415..9af7b4bf1a 100644 --- a/org.adempiere.base/src/org/compiere/model/MAcctSchema.java +++ b/org.adempiere.base/src/org/compiere/model/MAcctSchema.java @@ -136,9 +136,9 @@ public class MAcctSchema extends X_C_AcctSchema } // getClientAcctSchema /** Cache of Client AcctSchema Arrays **/ - private static CCache s_schema = new CCache("AD_ClientInfo", 3); // 3 clients + private static CCache s_schema = new CCache(I_AD_ClientInfo.Table_Name, 3); // 3 clients /** Cache of AcctSchemas **/ - private static CCache s_cache = new CCache("C_AcctSchema", 3); // 3 accounting schemas + private static CCache s_cache = new CCache(Table_Name, 3); // 3 accounting schemas /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java b/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java index 9c55b8f8f0..b9fd67fbb5 100644 --- a/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java +++ b/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java @@ -172,7 +172,7 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element private static CLogger s_log = CLogger.getCLogger (MAcctSchemaElement.class); /** Cache */ - private static CCache s_cache = new CCache("C_AcctSchema_Element", 10); + private static CCache s_cache = new CCache(Table_Name, 10); /************************************************************************* diff --git a/org.adempiere.base/src/org/compiere/model/MAlertProcessor.java b/org.adempiere.base/src/org/compiere/model/MAlertProcessor.java index 3c261470d0..5fea63cfad 100644 --- a/org.adempiere.base/src/org/compiere/model/MAlertProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MAlertProcessor.java @@ -82,7 +82,7 @@ public class MAlertProcessor extends X_AD_AlertProcessor } // MAlertProcessor /** Cache: AD_AlertProcessor -> Alerts array */ - private static CCache s_cacheAlerts = new CCache("AD_Alert_ForProcessor", 10); + private static CCache s_cacheAlerts = new CCache(I_AD_Alert.Table_Name, "AD_Alert_ForProcessor", 10, false); /** * Get Server ID diff --git a/org.adempiere.base/src/org/compiere/model/MAssetAcct.java b/org.adempiere.base/src/org/compiere/model/MAssetAcct.java index f5e23a3947..0b9b69848d 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetAcct.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetAcct.java @@ -43,7 +43,7 @@ public class MAssetAcct extends X_A_Asset_Acct /** Static Cache: A_Asset_Acct_ID -> MAssetAcct */ private static CCache s_cache = new CCache(Table_Name, 5); /** Static Cache: Asset,PostingType,DateAcct -> MAssetAcct */ - private static CCache s_cacheAsset = new CCache(Table_Name+"_Asset", 5); + private static CCache s_cacheAsset = new CCache(Table_Name, Table_Name+"_Asset", 5, false); /** * Get Asset Accounting (from cache) diff --git a/org.adempiere.base/src/org/compiere/model/MAssetClass.java b/org.adempiere.base/src/org/compiere/model/MAssetClass.java index 5efa563129..cf113e0fc9 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetClass.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetClass.java @@ -37,7 +37,7 @@ public class MAssetClass extends X_A_Asset_Class } // MAssetClass /** */ - private static CCache s_cache = new CCache("A_Asset_Class", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Get Asset Class from cache * @param ctx context diff --git a/org.adempiere.base/src/org/compiere/model/MAttributeSet.java b/org.adempiere.base/src/org/compiere/model/MAttributeSet.java index 9deb0bef5e..be02f0ae70 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttributeSet.java +++ b/org.adempiere.base/src/org/compiere/model/MAttributeSet.java @@ -64,7 +64,7 @@ public class MAttributeSet extends X_M_AttributeSet /** Cache */ private static CCache s_cache - = new CCache ("M_AttributeSet", 20); + = new CCache (Table_Name, 20); /** diff --git a/org.adempiere.base/src/org/compiere/model/MBOM.java b/org.adempiere.base/src/org/compiere/model/MBOM.java index ca4ed82fda..79580638f5 100644 --- a/org.adempiere.base/src/org/compiere/model/MBOM.java +++ b/org.adempiere.base/src/org/compiere/model/MBOM.java @@ -81,7 +81,7 @@ public class MBOM extends X_M_BOM /** Cache */ private static CCache s_cache - = new CCache("M_BOM", 20); + = new CCache(Table_Name, 20); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MBOM.class); diff --git a/org.adempiere.base/src/org/compiere/model/MBPGroup.java b/org.adempiere.base/src/org/compiere/model/MBPGroup.java index c2f1e68556..918e58794c 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPGroup.java +++ b/org.adempiere.base/src/org/compiere/model/MBPGroup.java @@ -158,10 +158,10 @@ public class MBPGroup extends X_C_BP_Group /** Cache */ private static CCache s_cache - = new CCache("BP_Group", 10); + = new CCache(Table_Name, 10); /** Default Cache */ private static CCache s_cacheDefault - = new CCache("BP_Group", 5); + = new CCache(Table_Name, MBPGroup.class.getName()+".Default", 5); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MBPGroup.class); diff --git a/org.adempiere.base/src/org/compiere/model/MBank.java b/org.adempiere.base/src/org/compiere/model/MBank.java index a01b066634..e3b8c9afc7 100644 --- a/org.adempiere.base/src/org/compiere/model/MBank.java +++ b/org.adempiere.base/src/org/compiere/model/MBank.java @@ -55,7 +55,7 @@ public class MBank extends X_C_Bank /** Cache */ private static CCache s_cache = - new CCache ("C_Bank", 3); + new CCache (Table_Name, 3); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MBankAccount.java b/org.adempiere.base/src/org/compiere/model/MBankAccount.java index 752b5c9c97..65fae5382d 100644 --- a/org.adempiere.base/src/org/compiere/model/MBankAccount.java +++ b/org.adempiere.base/src/org/compiere/model/MBankAccount.java @@ -56,7 +56,7 @@ public class MBankAccount extends X_C_BankAccount /** Cache */ private static CCache s_cache - = new CCache("C_BankAccount", 5); + = new CCache(Table_Name, 5); /** * Bank Account Model diff --git a/org.adempiere.base/src/org/compiere/model/MCalendar.java b/org.adempiere.base/src/org/compiere/model/MCalendar.java index c862e49d7c..f471f05e31 100644 --- a/org.adempiere.base/src/org/compiere/model/MCalendar.java +++ b/org.adempiere.base/src/org/compiere/model/MCalendar.java @@ -80,7 +80,7 @@ public class MCalendar extends X_C_Calendar /** Cache */ private static CCache s_cache - = new CCache("C_Calendar", 20); + = new CCache(Table_Name, 20); /************************************************************************* diff --git a/org.adempiere.base/src/org/compiere/model/MCashBook.java b/org.adempiere.base/src/org/compiere/model/MCashBook.java index ee630012ae..51d62a6568 100644 --- a/org.adempiere.base/src/org/compiere/model/MCashBook.java +++ b/org.adempiere.base/src/org/compiere/model/MCashBook.java @@ -102,7 +102,7 @@ public class MCashBook extends X_C_CashBook /** Cache */ private static CCache s_cache - = new CCache("", 20); + = new CCache(Table_Name, 20); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MCashBook.class); diff --git a/org.adempiere.base/src/org/compiere/model/MCharge.java b/org.adempiere.base/src/org/compiere/model/MCharge.java index 838a60839d..13ec4cb005 100644 --- a/org.adempiere.base/src/org/compiere/model/MCharge.java +++ b/org.adempiere.base/src/org/compiere/model/MCharge.java @@ -99,7 +99,7 @@ public class MCharge extends X_C_Charge /** Cache */ private static CCache s_cache - = new CCache ("C_Charge", 10); + = new CCache (Table_Name, 10); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MCharge.class); diff --git a/org.adempiere.base/src/org/compiere/model/MChatType.java b/org.adempiere.base/src/org/compiere/model/MChatType.java index dd3e61df04..1dac912ea0 100644 --- a/org.adempiere.base/src/org/compiere/model/MChatType.java +++ b/org.adempiere.base/src/org/compiere/model/MChatType.java @@ -54,7 +54,7 @@ public class MChatType extends X_CM_ChatType /** Cache */ private static CCache s_cache - = new CCache ("CM_ChatType", 20); + = new CCache (Table_Name, 20); /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MCity.java b/org.adempiere.base/src/org/compiere/model/MCity.java index 667cfc78bc..f9260e60f0 100644 --- a/org.adempiere.base/src/org/compiere/model/MCity.java +++ b/org.adempiere.base/src/org/compiere/model/MCity.java @@ -59,7 +59,7 @@ public final class MCity extends X_C_City } // get /** City Cache */ - private static CCache s_Cities = new CCache("C_City", 20);; + private static CCache s_Cities = new CCache(Table_Name, 20);; /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MCity.class); diff --git a/org.adempiere.base/src/org/compiere/model/MClient.java b/org.adempiere.base/src/org/compiere/model/MClient.java index 7ede0f8b9f..7c15657a75 100644 --- a/org.adempiere.base/src/org/compiere/model/MClient.java +++ b/org.adempiere.base/src/org/compiere/model/MClient.java @@ -107,7 +107,7 @@ public class MClient extends X_AD_Client @SuppressWarnings("unused") private static CLogger s_log = CLogger.getCLogger (MClient.class); /** Cache */ - private static CCache s_cache = new CCache("AD_Client", 3); + private static CCache s_cache = new CCache(Table_Name, 3); /************************************************************************** @@ -632,8 +632,9 @@ public class MClient extends X_AD_Client } } catch (Exception ex) - { - log.severe(getName() + " - " + ex.getLocalizedMessage()); + { + ex.printStackTrace(); + log.log(Level.SEVERE, getName() + " - " + ex.getLocalizedMessage(), ex); return false; } } // sendEMail diff --git a/org.adempiere.base/src/org/compiere/model/MClientInfo.java b/org.adempiere.base/src/org/compiere/model/MClientInfo.java index 99f4cece79..6e2833b758 100644 --- a/org.adempiere.base/src/org/compiere/model/MClientInfo.java +++ b/org.adempiere.base/src/org/compiere/model/MClientInfo.java @@ -111,7 +111,7 @@ public class MClientInfo extends X_AD_ClientInfo } // get /** Cache */ - private static CCache s_cache = new CCache("AD_ClientInfo", 2); + private static CCache s_cache = new CCache(Table_Name, 2); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MClientInfo.class); diff --git a/org.adempiere.base/src/org/compiere/model/MClientShare.java b/org.adempiere.base/src/org/compiere/model/MClientShare.java index 9334670bfb..19d69d73a7 100644 --- a/org.adempiere.base/src/org/compiere/model/MClientShare.java +++ b/org.adempiere.base/src/org/compiere/model/MClientShare.java @@ -122,7 +122,7 @@ public class MClientShare extends X_AD_ClientShare /** Shared Info */ private static CCache s_shares - = new CCache("AD_ClientShare", 10, 120); // 2h + = new CCache(Table_Name, 10, 120); // 2h /** Logger */ private static CLogger s_log = CLogger.getCLogger (MClientShare.class); diff --git a/org.adempiere.base/src/org/compiere/model/MColorSchema.java b/org.adempiere.base/src/org/compiere/model/MColorSchema.java index 12ce4b5301..e69810a679 100644 --- a/org.adempiere.base/src/org/compiere/model/MColorSchema.java +++ b/org.adempiere.base/src/org/compiere/model/MColorSchema.java @@ -100,7 +100,7 @@ public class MColorSchema extends X_PA_ColorSchema /** Cache */ private static CCache s_cache - = new CCache ("PA_ColorSchema", 20); + = new CCache (Table_Name, 20); /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MColumn.java b/org.adempiere.base/src/org/compiere/model/MColumn.java index 19faf0736d..5f3e764fcf 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MColumn.java @@ -77,7 +77,7 @@ public class MColumn extends X_AD_Column } // getColumnName /** Cache */ - private static CCache s_cache = new CCache("AD_Column", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MColumn.class); diff --git a/org.adempiere.base/src/org/compiere/model/MConversionType.java b/org.adempiere.base/src/org/compiere/model/MConversionType.java index 82c25c8c51..93b9bc42f2 100644 --- a/org.adempiere.base/src/org/compiere/model/MConversionType.java +++ b/org.adempiere.base/src/org/compiere/model/MConversionType.java @@ -71,7 +71,7 @@ public class MConversionType extends X_C_ConversionType } // getDefault /** Cache Client-ID */ - private static CCache s_cache = new CCache("C_ConversionType", 4); + private static CCache s_cache = new CCache(Table_Name, 4); /************************************************************************** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MCostElement.java b/org.adempiere.base/src/org/compiere/model/MCostElement.java index 29b4158fb2..9b319fb855 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostElement.java +++ b/org.adempiere.base/src/org/compiere/model/MCostElement.java @@ -210,7 +210,7 @@ public class MCostElement extends X_M_CostElement } /** Cache */ - private static CCache s_cache = new CCache("M_CostElement", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MCostElement.class); diff --git a/org.adempiere.base/src/org/compiere/model/MCountry.java b/org.adempiere.base/src/org/compiere/model/MCountry.java index 781ed5bdd4..f1a4674149 100644 --- a/org.adempiere.base/src/org/compiere/model/MCountry.java +++ b/org.adempiere.base/src/org/compiere/model/MCountry.java @@ -112,7 +112,7 @@ public final class MCountry extends X_C_Country MLanguage lang = MLanguage.get(ctx, client.getAD_Language()); MCountry usa = null; // - s_countries = new CCache("C_Country", 250); + s_countries = new CCache(Table_Name, 250); String sql = "SELECT * FROM C_Country WHERE IsActive='Y'"; try { diff --git a/org.adempiere.base/src/org/compiere/model/MCurrency.java b/org.adempiere.base/src/org/compiere/model/MCurrency.java index c15e923241..12f9da1bb4 100644 --- a/org.adempiere.base/src/org/compiere/model/MCurrency.java +++ b/org.adempiere.base/src/org/compiere/model/MCurrency.java @@ -87,9 +87,9 @@ public class MCurrency extends X_C_Currency /** Store System Currencies **/ - private static CCache s_currencies = new CCache("C_Currency", 50); + private static CCache s_currencies = new CCache(Table_Name, 50); /** Cache System Currencies by using ISO code as key **/ - private static CCache s_currenciesISO = new CCache("C_CurrencyISO", 50); + private static CCache s_currenciesISO = new CCache(Table_Name, "C_CurrencyISO", 50); /** * Get Currency using ISO code diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciation.java b/org.adempiere.base/src/org/compiere/model/MDepreciation.java index 67a585a2fa..21f1524153 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciation.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciation.java @@ -43,7 +43,7 @@ public class MDepreciation extends X_A_Depreciation s_cache = new CCache(Table_Name, 5); /** Cache for type */ private static CCache - s_cache_forType = new CCache(Table_Name+"_DepreciationType", 5); + s_cache_forType = new CCache(Table_Name, Table_Name+"_DepreciationType", 5); /** Static logger */ private static Logger s_log = CLogger.getCLogger(MDepreciation.class); /** The accuracy of calculation on depreciation */ diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationConvention.java b/org.adempiere.base/src/org/compiere/model/MDepreciationConvention.java index e05c82ebfc..3a626db2f0 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciationConvention.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciationConvention.java @@ -37,7 +37,7 @@ public class MDepreciationConvention extends X_A_Depreciation_Convention } // MDepreciationConvention /** Cache */ - private static CCache s_cache = new CCache("A_Depreciation_Convention", 5); + private static CCache s_cache = new CCache(Table_Name, 5); //~ /** Static logger */ //~ private static Logger s_log = CLogger.getCLogger(MDepreciationConvention.class); diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationMethod.java b/org.adempiere.base/src/org/compiere/model/MDepreciationMethod.java index c1fc145cf0..625c9d4fdd 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciationMethod.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciationMethod.java @@ -40,7 +40,7 @@ public class MDepreciationMethod extends X_A_Depreciation_Method s_cache = new CCache(Table_Name, 5); /** Cache for type */ private static CCache - s_cache_forType = new CCache(Table_Name+"_DepreciationType", 5); + s_cache_forType = new CCache(Table_Name, Table_Name+"_DepreciationType", 5); /** * diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java index de63f5d164..c20ca9d586 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java @@ -336,7 +336,7 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile } /** Static cache: Asset/PostingType -> Workfile */ private static CCache - s_cacheAsset = new CCache(Table_Name+"_Asset", 10); + s_cacheAsset = new CCache(Table_Name, Table_Name+"_Asset", 10); /** Returns the date of the last action */ diff --git a/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java b/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java index 2260fa7bcd..bb0916b2d2 100644 --- a/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java +++ b/org.adempiere.base/src/org/compiere/model/MDiscountSchema.java @@ -62,7 +62,7 @@ public class MDiscountSchema extends X_M_DiscountSchema /** Cache */ private static CCache s_cache - = new CCache("M_DiscountSchema", 20); + = new CCache(Table_Name, 20); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MDistribution.java b/org.adempiere.base/src/org/compiere/model/MDistribution.java index f479394dd2..7dfe5c0644 100644 --- a/org.adempiere.base/src/org/compiere/model/MDistribution.java +++ b/org.adempiere.base/src/org/compiere/model/MDistribution.java @@ -172,7 +172,7 @@ public class MDistribution extends X_GL_Distribution private static CLogger s_log = CLogger.getCLogger (MDistribution.class); /** Distributions by Account */ private static CCache s_accounts - = new CCache("GL_Distribution", 100); + = new CCache(Table_Name, 100); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java b/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java index 623760cdc2..f22ac3ce18 100644 --- a/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java +++ b/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java @@ -200,9 +200,9 @@ public class MDocTypeCounter extends X_C_DocTypeCounter /** Object Cache */ - private static CCache s_cache = new CCache("C_DocTypeCounter", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Counter Relationship Cache */ - private static CCache s_counter = new CCache("C_DocTypeCounter", 20); + private static CCache s_counter = new CCache(Table_Name, "C_DocTypeCounter_Relation", 20); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MDocTypeCounter.class); diff --git a/org.adempiere.base/src/org/compiere/model/MGLCategory.java b/org.adempiere.base/src/org/compiere/model/MGLCategory.java index d0838b4bc2..66b5df5697 100644 --- a/org.adempiere.base/src/org/compiere/model/MGLCategory.java +++ b/org.adempiere.base/src/org/compiere/model/MGLCategory.java @@ -133,7 +133,7 @@ public class MGLCategory extends X_GL_Category private static CLogger s_log = CLogger.getCLogger (MGLCategory.class); /** Cache */ private static CCache s_cache - = new CCache ("GL_Category", 5); + = new CCache (Table_Name, 5); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MGroup.java b/org.adempiere.base/src/org/compiere/model/MGroup.java index fe6c3a3b71..c2f602a7b1 100644 --- a/org.adempiere.base/src/org/compiere/model/MGroup.java +++ b/org.adempiere.base/src/org/compiere/model/MGroup.java @@ -53,7 +53,7 @@ public class MGroup extends X_R_Group } // get /** Cache */ - private static CCache s_cache = new CCache("R_Group", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MHierarchy.java b/org.adempiere.base/src/org/compiere/model/MHierarchy.java index d1267a9165..dd1120eb6f 100644 --- a/org.adempiere.base/src/org/compiere/model/MHierarchy.java +++ b/org.adempiere.base/src/org/compiere/model/MHierarchy.java @@ -54,7 +54,7 @@ public class MHierarchy extends X_PA_Hierarchy /** Cache */ private static CCache s_cache - = new CCache ("PA_Hierarchy_ID", 20); + = new CCache (Table_Name, 20); /** * Default Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MImage.java b/org.adempiere.base/src/org/compiere/model/MImage.java index f88f14cc2b..ae72577fb7 100644 --- a/org.adempiere.base/src/org/compiere/model/MImage.java +++ b/org.adempiere.base/src/org/compiere/model/MImage.java @@ -71,7 +71,7 @@ public class MImage extends X_AD_Image } // get /** Cache */ - private static CCache s_cache = new CCache("AD_Image", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** * Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MInterestArea.java b/org.adempiere.base/src/org/compiere/model/MInterestArea.java index 91752689ad..99a343c859 100644 --- a/org.adempiere.base/src/org/compiere/model/MInterestArea.java +++ b/org.adempiere.base/src/org/compiere/model/MInterestArea.java @@ -107,7 +107,7 @@ public class MInterestArea extends X_R_InterestArea /** Cache */ private static CCache s_cache = - new CCache("R_InterestArea", 5); + new CCache(Table_Name, 5); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MInterestArea.class); diff --git a/org.adempiere.base/src/org/compiere/model/MInventory.java b/org.adempiere.base/src/org/compiere/model/MInventory.java index fe9df801fc..19ef3c197d 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventory.java +++ b/org.adempiere.base/src/org/compiere/model/MInventory.java @@ -70,7 +70,7 @@ public class MInventory extends X_M_Inventory implements DocAction } // get /** Cache */ - private static CCache s_cache = new CCache("M_Inventory", 5, 5); + private static CCache s_cache = new CCache(Table_Name, 5, 5); /** diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index f3cc5bcbea..501b8234b2 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -250,7 +250,7 @@ public class MInvoice extends X_C_Invoice implements DocAction } // get /** Cache */ - private static CCache s_cache = new CCache("C_Invoice", 20, 2); // 2 minutes + private static CCache s_cache = new CCache(Table_Name, 20, 2); // 2 minutes /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceSchedule.java b/org.adempiere.base/src/org/compiere/model/MInvoiceSchedule.java index f1a96109a8..3f7705500a 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceSchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceSchedule.java @@ -59,7 +59,7 @@ public class MInvoiceSchedule extends X_C_InvoiceSchedule } // get /** Cache */ - private static CCache s_cache = new CCache("C_InvoiceSchedule", 5); + private static CCache s_cache = new CCache(Table_Name, 5); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MLocation.java b/org.adempiere.base/src/org/compiere/model/MLocation.java index 549d711e6e..a03457b4c4 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocation.java +++ b/org.adempiere.base/src/org/compiere/model/MLocation.java @@ -120,7 +120,7 @@ public class MLocation extends X_C_Location implements Comparator } // getBPLocation /** Cache */ - private static CCache s_cache = new CCache("C_Location", 100, 30); + private static CCache s_cache = new CCache(Table_Name, 100, 30); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger(MLocation.class); diff --git a/org.adempiere.base/src/org/compiere/model/MLocator.java b/org.adempiere.base/src/org/compiere/model/MLocator.java index 7337e70a91..67c3d306a3 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocator.java +++ b/org.adempiere.base/src/org/compiere/model/MLocator.java @@ -174,7 +174,7 @@ public class MLocator extends X_M_Locator public static MLocator get (Properties ctx, int M_Locator_ID) { if (s_cache == null) - s_cache = new CCache("M_Locator", 20); + s_cache = new CCache(Table_Name, 20); Integer key = new Integer (M_Locator_ID); MLocator retValue = (MLocator) s_cache.get (key); if (retValue != null) diff --git a/org.adempiere.base/src/org/compiere/model/MLookupCache.java b/org.adempiere.base/src/org/compiere/model/MLookupCache.java index fc0e15fd98..1e583145a1 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupCache.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupCache.java @@ -36,7 +36,7 @@ public class MLookupCache /** Static Logger */ private static CLogger s_log = CLogger.getCLogger(MLookupCache.class); /** Static Lookup data with MLookupInfo -> HashMap */ - private static CCache s_loadedLookups = new CCache("MLookupCache", 50); + private static CCache s_loadedLookups = new CCache(null, "MLookupCache", 50, false); /** * MLookup Loader starts loading - ignore for now diff --git a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java index 969ec85128..ca75e9d1d3 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java @@ -55,7 +55,7 @@ public class MLookupFactory /** Logging */ private static CLogger s_log = CLogger.getCLogger(MLookupFactory.class); /** Table Reference Cache */ - private static CCache s_cacheRefTable = new CCache("AD_Ref_Table", 30, 60); // 1h + private static CCache s_cacheRefTable = new CCache(I_AD_Ref_Table.Table_Name, 30, 60); // 1h /** diff --git a/org.adempiere.base/src/org/compiere/model/MMailText.java b/org.adempiere.base/src/org/compiere/model/MMailText.java index 62716e1752..c42a938faf 100644 --- a/org.adempiere.base/src/org/compiere/model/MMailText.java +++ b/org.adempiere.base/src/org/compiere/model/MMailText.java @@ -74,7 +74,7 @@ public class MMailText extends X_R_MailText /** Translated Text 3 */ private String m_MailText3 = null; /** Translation Cache */ - private static CCache s_cacheTrl = new CCache ("", 20); + private static CCache s_cacheTrl = new CCache (Table_Name, 20); /** * Get parsed/translated Mail Text diff --git a/org.adempiere.base/src/org/compiere/model/MMatchInv.java b/org.adempiere.base/src/org/compiere/model/MMatchInv.java index 347bd69cf8..dc1b9319f3 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchInv.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchInv.java @@ -427,7 +427,7 @@ public class MMatchInv extends X_M_MatchInv */ public boolean reverse(Timestamp reversalDate) { - if (this.isPosted()) + if (this.isPosted() && this.getReversal_ID() == 0) { MMatchInv reversal = new MMatchInv (getCtx(), 0, get_TrxName()); PO.copyValues(this, reversal); @@ -439,9 +439,11 @@ public class MMatchInv extends X_M_MatchInv reversal.set_ValueNoCheck ("DocumentNo", null); reversal.setPosted (false); reversal.setReversal_ID(getM_MatchInv_ID()); - this.setDescription("(" + this.getDocumentNo() + "<-)"); - if (reversal.save() && this.save()) - return true; + reversal.saveEx(); + this.setDescription("(" + reversal.getDocumentNo() + "<-)"); + this.setReversal_ID(reversal.getM_MatchInv_ID()); + this.saveEx(); + return true; } return false; } diff --git a/org.adempiere.base/src/org/compiere/model/MMatchPO.java b/org.adempiere.base/src/org/compiere/model/MMatchPO.java index 8a3405a591..98e3229b1b 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchPO.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchPO.java @@ -1175,7 +1175,7 @@ public class MMatchPO extends X_M_MatchPO public boolean reverse(Timestamp reversalDate) { - if (this.isPosted()) + if (this.isPosted() && this.getReversal_ID() == 0) { MMatchPO reversal = new MMatchPO (getCtx(), 0, get_TrxName()); reversal.setC_InvoiceLine_ID(getC_InvoiceLine_ID()); @@ -1189,9 +1189,11 @@ public class MMatchPO extends X_M_MatchPO reversal.set_ValueNoCheck ("DocumentNo", null); reversal.setPosted (false); reversal.setReversal_ID(getM_MatchPO_ID()); - this.setDescription("(" + this.getDocumentNo() + "<-)"); - if (reversal.save() && this.save()) - return true; + reversal.saveEx(); + this.setDescription("(" + reversal.getDocumentNo() + "<-)"); + this.setReversal_ID(reversal.getM_MatchPO_ID()); + this.saveEx(); + return true; } return false; } diff --git a/org.adempiere.base/src/org/compiere/model/MMeasure.java b/org.adempiere.base/src/org/compiere/model/MMeasure.java index 8df75f2c33..1bf09fe1e1 100644 --- a/org.adempiere.base/src/org/compiere/model/MMeasure.java +++ b/org.adempiere.base/src/org/compiere/model/MMeasure.java @@ -76,7 +76,7 @@ public class MMeasure extends X_PA_Measure /** Cache */ private static CCache s_cache - = new CCache ("PA_Measure", 10); + = new CCache (Table_Name, 10); /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java b/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java index 1c4d665c90..b8b745df45 100644 --- a/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java +++ b/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java @@ -60,7 +60,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc /** Cache */ private static CCache s_cache - = new CCache ("PA_MeasureCalc", 10); + = new CCache (Table_Name, 10); /************************************************************************** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MMessage.java b/org.adempiere.base/src/org/compiere/model/MMessage.java index 6f3276d6fa..59decbbc5b 100644 --- a/org.adempiere.base/src/org/compiere/model/MMessage.java +++ b/org.adempiere.base/src/org/compiere/model/MMessage.java @@ -118,7 +118,7 @@ public class MMessage extends X_AD_Message } // getAD_Message_ID /** Cache */ - static private CCache s_cache = new CCache("AD_Message", 100); + static private CCache s_cache = new CCache(Table_Name, 100); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger(MMessage.class); diff --git a/org.adempiere.base/src/org/compiere/model/MPOS.java b/org.adempiere.base/src/org/compiere/model/MPOS.java index 556f5dfa04..6118a68fd0 100644 --- a/org.adempiere.base/src/org/compiere/model/MPOS.java +++ b/org.adempiere.base/src/org/compiere/model/MPOS.java @@ -72,7 +72,7 @@ public class MPOS extends X_C_POS } // get /** Cache */ - private static CCache s_cache = new CCache("C_POS", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MPOSKeyLayout.java b/org.adempiere.base/src/org/compiere/model/MPOSKeyLayout.java index 90669ecc79..2ee18ec660 100644 --- a/org.adempiere.base/src/org/compiere/model/MPOSKeyLayout.java +++ b/org.adempiere.base/src/org/compiere/model/MPOSKeyLayout.java @@ -57,7 +57,7 @@ public class MPOSKeyLayout extends X_C_POSKeyLayout } // get /** Cache */ - private static CCache s_cache = new CCache("C_POSKeyLayout", 3); + private static CCache s_cache = new CCache(Table_Name, 3); /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MPOSTerminal.java b/org.adempiere.base/src/org/compiere/model/MPOSTerminal.java index 33f2e07c38..cee86a4956 100644 --- a/org.adempiere.base/src/org/compiere/model/MPOSTerminal.java +++ b/org.adempiere.base/src/org/compiere/model/MPOSTerminal.java @@ -36,7 +36,7 @@ public class MPOSTerminal extends X_U_POSTerminal */ private static final long serialVersionUID = 6972567212871993024L; /** Cache */ - static private CCache s_cache = new CCache(X_U_POSTerminal.Table_Name, 10, 60); + static private CCache s_cache = new CCache(Table_Name, 10, 60); /** * @param ctx Context diff --git a/org.adempiere.base/src/org/compiere/model/MPeriod.java b/org.adempiere.base/src/org/compiere/model/MPeriod.java index 782de2bf33..8ef3d97f72 100644 --- a/org.adempiere.base/src/org/compiere/model/MPeriod.java +++ b/org.adempiere.base/src/org/compiere/model/MPeriod.java @@ -321,7 +321,7 @@ public class MPeriod extends X_C_Period } // getFirstInYear /** Cache */ - private static CCache s_cache = new CCache("C_Period", 10); + private static CCache s_cache = new CCache(Table_Name, 10); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MPeriod.class); diff --git a/org.adempiere.base/src/org/compiere/model/MProcessPara.java b/org.adempiere.base/src/org/compiere/model/MProcessPara.java index 114d03c91c..b0c9deb44b 100644 --- a/org.adempiere.base/src/org/compiere/model/MProcessPara.java +++ b/org.adempiere.base/src/org/compiere/model/MProcessPara.java @@ -59,7 +59,7 @@ public class MProcessPara extends X_AD_Process_Para /** Cache */ private static CCache s_cache - = new CCache ("AD_Process_Para", 20); + = new CCache (Table_Name, 20); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MProductCategory.java b/org.adempiere.base/src/org/compiere/model/MProductCategory.java index b159c39e9a..ca01c72f80 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductCategory.java +++ b/org.adempiere.base/src/org/compiere/model/MProductCategory.java @@ -117,9 +117,9 @@ public class MProductCategory extends X_M_Product_Category } // isCategory /** Categopry Cache */ - private static CCache s_cache = new CCache("M_Product_Category", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Product Cache */ - private static CCache s_products = new CCache("M_Product", 100); + private static CCache s_products = new CCache(I_M_Product.Table_Name, Table_Name + ".M_Product", 100); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MProductCategory.class); diff --git a/org.adempiere.base/src/org/compiere/model/MProjectType.java b/org.adempiere.base/src/org/compiere/model/MProjectType.java index 3c910c1dd6..110f0a4b13 100644 --- a/org.adempiere.base/src/org/compiere/model/MProjectType.java +++ b/org.adempiere.base/src/org/compiere/model/MProjectType.java @@ -61,7 +61,7 @@ public class MProjectType extends X_C_ProjectType /** Cache */ private static CCache s_cache - = new CCache ("C_ProjectType", 20); + = new CCache (Table_Name, 20); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MRecentItem.java b/org.adempiere.base/src/org/compiere/model/MRecentItem.java index e425f59181..8dc7da3312 100644 --- a/org.adempiere.base/src/org/compiere/model/MRecentItem.java +++ b/org.adempiere.base/src/org/compiere/model/MRecentItem.java @@ -39,7 +39,7 @@ public class MRecentItem extends X_AD_RecentItem private static final long serialVersionUID = 8337619537799431984L; /** Recent Item Cache */ - private static CCache s_cache = new CCache("AD_RecentItem", 10); + private static CCache s_cache = new CCache(Table_Name, 10); /** Logger */ private static CLogger s_log = CLogger.getCLogger(MRecentItem.class); diff --git a/org.adempiere.base/src/org/compiere/model/MRegion.java b/org.adempiere.base/src/org/compiere/model/MRegion.java index ec6fc04e2b..b064eaf447 100644 --- a/org.adempiere.base/src/org/compiere/model/MRegion.java +++ b/org.adempiere.base/src/org/compiere/model/MRegion.java @@ -55,7 +55,7 @@ public final class MRegion extends X_C_Region */ private static void loadAllRegions (Properties ctx) { - s_regions = new CCache("C_Region", 100); + s_regions = new CCache(Table_Name, 100); String sql = "SELECT * FROM C_Region WHERE IsActive='Y'"; try { diff --git a/org.adempiere.base/src/org/compiere/model/MRegistrationAttribute.java b/org.adempiere.base/src/org/compiere/model/MRegistrationAttribute.java index af26166cad..9c49eeeaf9 100644 --- a/org.adempiere.base/src/org/compiere/model/MRegistrationAttribute.java +++ b/org.adempiere.base/src/org/compiere/model/MRegistrationAttribute.java @@ -113,7 +113,7 @@ public class MRegistrationAttribute extends X_A_RegistrationAttribute private static CLogger s_log = CLogger.getCLogger(MRegistrationAttribute.class); /** Cache */ private static CCache s_cache - = new CCache("A_RegistrationAttribute", 20); + = new CCache(Table_Name, 20); /************************************************************************** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MRequestCategory.java b/org.adempiere.base/src/org/compiere/model/MRequestCategory.java index f6b5b3cbe8..d398642d6e 100644 --- a/org.adempiere.base/src/org/compiere/model/MRequestCategory.java +++ b/org.adempiere.base/src/org/compiere/model/MRequestCategory.java @@ -54,7 +54,7 @@ public class MRequestCategory extends X_R_Category /** Cache */ private static CCache s_cache - = new CCache("R_Category", 20); + = new CCache(Table_Name, 20); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MRequestType.java b/org.adempiere.base/src/org/compiere/model/MRequestType.java index cec5b81a6d..2b158a14ad 100644 --- a/org.adempiere.base/src/org/compiere/model/MRequestType.java +++ b/org.adempiere.base/src/org/compiere/model/MRequestType.java @@ -65,7 +65,7 @@ public class MRequestType extends X_R_RequestType /** Static Logger */ private static CLogger s_log = CLogger.getCLogger(MRequestType.class); /** Cache */ - static private CCache s_cache = new CCache("R_RequestType", 10); + static private CCache s_cache = new CCache(Table_Name, 10); /** * Get Default Request Type diff --git a/org.adempiere.base/src/org/compiere/model/MResolution.java b/org.adempiere.base/src/org/compiere/model/MResolution.java index c9ea367a0d..7aee211616 100644 --- a/org.adempiere.base/src/org/compiere/model/MResolution.java +++ b/org.adempiere.base/src/org/compiere/model/MResolution.java @@ -54,7 +54,7 @@ public class MResolution extends X_R_Resolution } // get /** Cache */ - private static CCache s_cache = new CCache("R_Resolution", 10); + private static CCache s_cache = new CCache(Table_Name, 10); diff --git a/org.adempiere.base/src/org/compiere/model/MRfQ.java b/org.adempiere.base/src/org/compiere/model/MRfQ.java index 60422904d1..b4984322c7 100644 --- a/org.adempiere.base/src/org/compiere/model/MRfQ.java +++ b/org.adempiere.base/src/org/compiere/model/MRfQ.java @@ -61,7 +61,7 @@ public class MRfQ extends X_C_RfQ } // get /** Cache */ - private static CCache s_cache = new CCache("C_RfQ", 10); + private static CCache s_cache = new CCache(Table_Name, 10); /** diff --git a/org.adempiere.base/src/org/compiere/model/MRfQLine.java b/org.adempiere.base/src/org/compiere/model/MRfQLine.java index d0ef06ae8a..63842dbbc8 100644 --- a/org.adempiere.base/src/org/compiere/model/MRfQLine.java +++ b/org.adempiere.base/src/org/compiere/model/MRfQLine.java @@ -59,7 +59,7 @@ public class MRfQLine extends X_C_RfQLine } // get /** Cache */ - private static CCache s_cache = new CCache("C_RfQLine", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MRfQLineQty.java b/org.adempiere.base/src/org/compiere/model/MRfQLineQty.java index fa05d1d69c..434b2a6813 100644 --- a/org.adempiere.base/src/org/compiere/model/MRfQLineQty.java +++ b/org.adempiere.base/src/org/compiere/model/MRfQLineQty.java @@ -59,7 +59,7 @@ public class MRfQLineQty extends X_C_RfQLineQty } // get /** Cache */ - private static CCache s_cache = new CCache("C_RfQLineQty", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MRole.java b/org.adempiere.base/src/org/compiere/model/MRole.java index f2dc42877d..2ae5309b62 100644 --- a/org.adempiere.base/src/org/compiere/model/MRole.java +++ b/org.adempiere.base/src/org/compiere/model/MRole.java @@ -235,7 +235,7 @@ public final class MRole extends X_AD_Role } // getOf /** Role/User Cache */ - private static CCache s_roles = new CCache("AD_Role", 5); + private static CCache s_roles = new CCache(Table_Name, 5); /** Log */ private static CLogger s_log = CLogger.getCLogger(MRole.class); diff --git a/org.adempiere.base/src/org/compiere/model/MRule.java b/org.adempiere.base/src/org/compiere/model/MRule.java index 72d1180b8e..b4689363b0 100644 --- a/org.adempiere.base/src/org/compiere/model/MRule.java +++ b/org.adempiere.base/src/org/compiere/model/MRule.java @@ -123,7 +123,7 @@ public class MRule extends X_AD_Rule } // getModelValidatorLoginRules /** Cache */ - private static CCache s_cache = new CCache("AD_Rule", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MRule.class); diff --git a/org.adempiere.base/src/org/compiere/model/MSLACriteria.java b/org.adempiere.base/src/org/compiere/model/MSLACriteria.java index f351cd8c1a..a12327ab83 100644 --- a/org.adempiere.base/src/org/compiere/model/MSLACriteria.java +++ b/org.adempiere.base/src/org/compiere/model/MSLACriteria.java @@ -61,7 +61,7 @@ public class MSLACriteria extends X_PA_SLA_Criteria } // get /** Cache */ - private static CCache s_cache = new CCache("PA_SLA_Criteria", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** diff --git a/org.adempiere.base/src/org/compiere/model/MSalesRegion.java b/org.adempiere.base/src/org/compiere/model/MSalesRegion.java index c066a789ad..b537701167 100644 --- a/org.adempiere.base/src/org/compiere/model/MSalesRegion.java +++ b/org.adempiere.base/src/org/compiere/model/MSalesRegion.java @@ -55,7 +55,7 @@ public class MSalesRegion extends X_C_SalesRegion } // get /** Cache */ - private static CCache s_cache = new CCache("C_SalesRegion", 10); + private static CCache s_cache = new CCache(Table_Name, 10); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MSchedule.java b/org.adempiere.base/src/org/compiere/model/MSchedule.java index 26a7172983..55675f7cdb 100644 --- a/org.adempiere.base/src/org/compiere/model/MSchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MSchedule.java @@ -151,7 +151,7 @@ public class MSchedule extends X_AD_Schedule } /** Cache */ - private static CCache s_cache = new CCache ("AD_Schedule", 10); + private static CCache s_cache = new CCache (Table_Name, 10); public boolean chekIPFormat(String ipOnly) { diff --git a/org.adempiere.base/src/org/compiere/model/MSession.java b/org.adempiere.base/src/org/compiere/model/MSession.java index d185c187e7..611db98188 100644 --- a/org.adempiere.base/src/org/compiere/model/MSession.java +++ b/org.adempiere.base/src/org/compiere/model/MSession.java @@ -108,8 +108,8 @@ public class MSession extends X_AD_Session /** Sessions */ private static CCache s_sessions = Ini.isClient() - ? new CCache("AD_Session_ID", 1, 0) // one client session - : new CCache("AD_Session_ID", 30, 0); // no time-out + ? new CCache(null, "AD_Session_ID", 1, 0, false) // one client session + : new CCache(null, "AD_Session_ID", 30, 0, false); // no time-out /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MStatus.java b/org.adempiere.base/src/org/compiere/model/MStatus.java index 14704b6772..4a76795481 100644 --- a/org.adempiere.base/src/org/compiere/model/MStatus.java +++ b/org.adempiere.base/src/org/compiere/model/MStatus.java @@ -157,10 +157,10 @@ public class MStatus extends X_R_Status private static CLogger s_log = CLogger.getCLogger(MStatus.class); /** Cache */ static private CCache s_cache - = new CCache ("R_Status", 10); + = new CCache (Table_Name, 10); /** Default Cache (Key=Client) */ static private CCache s_cacheDefault - = new CCache("R_Status", 10); + = new CCache(Table_Name, "R_Status_Default", 10); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MStatusCategory.java b/org.adempiere.base/src/org/compiere/model/MStatusCategory.java index 73e6331900..3fe74e4fae 100644 --- a/org.adempiere.base/src/org/compiere/model/MStatusCategory.java +++ b/org.adempiere.base/src/org/compiere/model/MStatusCategory.java @@ -124,7 +124,7 @@ public class MStatusCategory extends X_R_StatusCategory /** Cache */ private static CCache s_cache - = new CCache ("R_StatusCategory", 20); + = new CCache (Table_Name, 20); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MStatusCategory.class); diff --git a/org.adempiere.base/src/org/compiere/model/MStore.java b/org.adempiere.base/src/org/compiere/model/MStore.java index 258fb501bf..6d26b697e9 100644 --- a/org.adempiere.base/src/org/compiere/model/MStore.java +++ b/org.adempiere.base/src/org/compiere/model/MStore.java @@ -219,7 +219,7 @@ public class MStore extends X_W_Store /** Cache */ private static CCache s_cache - = new CCache("W_Store", 2); + = new CCache(Table_Name, 2); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MStore.class); diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 12cb81d600..9c03fa6de5 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -135,17 +135,8 @@ public class MSysConfig extends X_AD_SysConfig /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MSysConfig.class); /** Cache */ - private static CCache s_cache = new CCache(Table_Name, 40, 0); - /** resetCache */ - private static boolean resetCache = false; + private static CCache s_cache = new CCache(Table_Name, 40, 0, true); - /** Reset Cache - * - */ - public static void resetCache() - { - s_cache.reset(); - } /** * Get system configuration property of type string * @param Name diff --git a/org.adempiere.base/src/org/compiere/model/MTable.java b/org.adempiere.base/src/org/compiere/model/MTable.java index b2060f1bb4..fa44e3ae64 100644 --- a/org.adempiere.base/src/org/compiere/model/MTable.java +++ b/org.adempiere.base/src/org/compiere/model/MTable.java @@ -149,7 +149,7 @@ public class MTable extends X_AD_Table /** Cache */ - private static CCache s_cache = new CCache("AD_Table", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MTable.class); diff --git a/org.adempiere.base/src/org/compiere/model/MTableScriptValidator.java b/org.adempiere.base/src/org/compiere/model/MTableScriptValidator.java index b8f9634ebf..4f5796707d 100644 --- a/org.adempiere.base/src/org/compiere/model/MTableScriptValidator.java +++ b/org.adempiere.base/src/org/compiere/model/MTableScriptValidator.java @@ -108,7 +108,7 @@ public class MTableScriptValidator extends X_AD_Table_ScriptValidator = new CCache(Table_Name, 20); /** Cache / Table Event */ private static CCache> s_cacheTableEvent - = new CCache>(Table_Name+"_TableEvent", 20); + = new CCache>(null, Table_Name+"_TableEvent", 20, false); /************************************************************************** * Standard Constructor diff --git a/org.adempiere.base/src/org/compiere/model/MTax.java b/org.adempiere.base/src/org/compiere/model/MTax.java index 4abaca8f8e..113b7f2974 100644 --- a/org.adempiere.base/src/org/compiere/model/MTax.java +++ b/org.adempiere.base/src/org/compiere/model/MTax.java @@ -45,7 +45,7 @@ public class MTax extends X_C_Tax /** Cache */ private static CCache s_cache = new CCache(Table_Name, 5); /** Cache of Client */ - private static CCache s_cacheAll = new CCache(Table_Name, 5); + private static CCache s_cacheAll = new CCache(Table_Name, Table_Name+"_Of_Client", 5); /** 100 */ private static BigDecimal ONEHUNDRED = new BigDecimal(100); diff --git a/org.adempiere.base/src/org/compiere/model/MTree_Base.java b/org.adempiere.base/src/org/compiere/model/MTree_Base.java index 5a53434c91..a16673d6bb 100644 --- a/org.adempiere.base/src/org/compiere/model/MTree_Base.java +++ b/org.adempiere.base/src/org/compiere/model/MTree_Base.java @@ -219,7 +219,7 @@ public class MTree_Base extends X_AD_Tree /** Cache */ - private static CCache s_cache = new CCache("AD_Tree", 10); + private static CCache s_cache = new CCache(Table_Name, 10); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MUOMConversion.java b/org.adempiere.base/src/org/compiere/model/MUOMConversion.java index 0829237a3c..c7ab824a77 100644 --- a/org.adempiere.base/src/org/compiere/model/MUOMConversion.java +++ b/org.adempiere.base/src/org/compiere/model/MUOMConversion.java @@ -169,7 +169,7 @@ public class MUOMConversion extends X_C_UOM_Conversion */ private static void createRates (Properties ctx) { - s_conversions = new CCache("C_UOMConversion", 20); + s_conversions = new CCache(Table_Name, 20); // String sql = MRole.getDefault(ctx, false).addAccessSQL ( "SELECT C_UOM_ID, C_UOM_To_ID, MultiplyRate, DivideRate " @@ -625,7 +625,7 @@ public class MUOMConversion extends X_C_UOM_Conversion private static CCache s_conversions = null; /** Product Conversion Map */ private static final CCache s_conversionProduct - = new CCache("C_UOMConversion", 20); + = new CCache(Table_Name, Table_Name+"_Of_Product", 20); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MUser.java b/org.adempiere.base/src/org/compiere/model/MUser.java index 7d6a1aa504..77db246ccf 100644 --- a/org.adempiere.base/src/org/compiere/model/MUser.java +++ b/org.adempiere.base/src/org/compiere/model/MUser.java @@ -275,7 +275,7 @@ public class MUser extends X_AD_User } // isSalesRep /** Cache */ - static private CCache s_cache = new CCache("AD_User", 30, 60); + static private CCache s_cache = new CCache(Table_Name, 30, 60); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MUser.class); diff --git a/org.adempiere.base/src/org/compiere/model/MUserDefWin.java b/org.adempiere.base/src/org/compiere/model/MUserDefWin.java index 1f26ed5d91..bd52bbfbb9 100644 --- a/org.adempiere.base/src/org/compiere/model/MUserDefWin.java +++ b/org.adempiere.base/src/org/compiere/model/MUserDefWin.java @@ -186,7 +186,7 @@ public class MUserDefWin extends X_AD_UserDef_Win } /** Cache of selected MUserDefWin entries **/ - private static CCache s_cache = new CCache("AD_UserDef_Win", 3); // 3 weights + private static CCache s_cache = new CCache(Table_Name, 3); // 3 weights @Override protected boolean beforeSave(boolean newRecord) { diff --git a/org.adempiere.base/src/org/compiere/model/MWarehouse.java b/org.adempiere.base/src/org/compiere/model/MWarehouse.java index c420c7d822..dd51fa1b02 100644 --- a/org.adempiere.base/src/org/compiere/model/MWarehouse.java +++ b/org.adempiere.base/src/org/compiere/model/MWarehouse.java @@ -107,7 +107,7 @@ public class MWarehouse extends X_M_Warehouse } // get /** Cache */ - private static CCache s_cache = new CCache("M_Warehouse", 50 ); + private static CCache s_cache = new CCache(Table_Name, 50 ); /** * Standard Constructor * @param ctx context diff --git a/org.adempiere.base/src/org/compiere/model/MWebProject.java b/org.adempiere.base/src/org/compiere/model/MWebProject.java index c735a0d5fb..8f8ada66c4 100644 --- a/org.adempiere.base/src/org/compiere/model/MWebProject.java +++ b/org.adempiere.base/src/org/compiere/model/MWebProject.java @@ -55,7 +55,7 @@ public class MWebProject extends X_CM_WebProject /** Cache */ private static CCache s_cache - = new CCache ("CM_WebProject", 5); + = new CCache (Table_Name, 5); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java b/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java index 117ce3592f..eff900ca2b 100644 --- a/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java +++ b/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java @@ -634,7 +634,7 @@ public class ModelValidationEngine /************************************************************************** * Add Date Import Validation Listener - * @param tableName table name + * @param data.tableName table name * @param listener listener */ public void addImportValidate (String importTableName, ImportValidator listener) diff --git a/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java b/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java index 3c9b56a041..7a9b915894 100644 --- a/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java +++ b/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java @@ -69,7 +69,7 @@ public final class NaturalAccountMap extends CCache */ public NaturalAccountMap(Properties ctx, String trxName) { - super("NaturalAccountMap", 100); + super(null, "NaturalAccountMap", 100, false); m_ctx = ctx; m_trxName = trxName; } // NaturalAccountMap diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 2cb3ee21d9..3abe129f1e 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -16,6 +16,8 @@ *****************************************************************************/ package org.compiere.model; +import java.io.IOException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.io.StringWriter; import java.math.BigDecimal; @@ -4314,5 +4316,10 @@ public abstract class PO return clone; } - + private void readObject(ObjectInputStream ois) + throws ClassNotFoundException, IOException { + // default deserialization + ois.defaultReadObject(); + log = CLogger.getCLogger(getClass()); + } } // PO diff --git a/org.adempiere.base/src/org/compiere/model/POInfo.java b/org.adempiere.base/src/org/compiere/model/POInfo.java index 3a65c5ec07..9277ad0031 100644 --- a/org.adempiere.base/src/org/compiere/model/POInfo.java +++ b/org.adempiere.base/src/org/compiere/model/POInfo.java @@ -86,7 +86,7 @@ public class POInfo implements Serializable } // getPOInfo /** Cache of POInfo */ - private static CCache s_cache = new CCache("POInfo", 200); + private static CCache s_cache = new CCache(I_AD_Table.Table_Name, "POInfo", 200); /************************************************************************** * Create Persistent Info diff --git a/org.adempiere.base/src/org/compiere/model/TranslationTable.java b/org.adempiere.base/src/org/compiere/model/TranslationTable.java index a98d7962df..912b7accda 100644 --- a/org.adempiere.base/src/org/compiere/model/TranslationTable.java +++ b/org.adempiere.base/src/org/compiere/model/TranslationTable.java @@ -105,7 +105,7 @@ public class TranslationTable private static Integer s_activeLanguages = null; /** Cache */ - private static CCache s_cache = new CCache("TranslationTable", 20); + private static CCache s_cache = new CCache(null, "TranslationTable", 20, true); /** diff --git a/org.adempiere.base/src/org/compiere/print/MPrintColor.java b/org.adempiere.base/src/org/compiere/print/MPrintColor.java index b9016df7bf..07b55ce9fc 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintColor.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintColor.java @@ -77,7 +77,7 @@ public class MPrintColor extends X_AD_PrintColor /*************************************************************************/ /** Cached Colors */ - static private CCache s_colors = new CCache("AD_PrintColor", 20); + static private CCache s_colors = new CCache(Table_Name, 20); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MPrintColor.class); diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFont.java b/org.adempiere.base/src/org/compiere/print/MPrintFont.java index 9fb48aef53..931de498bc 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFont.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFont.java @@ -190,7 +190,7 @@ public class MPrintFont extends X_AD_PrintFont /*************************************************************************/ /** Cached Fonts */ - static private CCache s_fonts = new CCache("AD_PrintFont", 20); + static private CCache s_fonts = new CCache(Table_Name, 20); /** * Get Font diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java index c9924c3428..4fe50953c6 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java @@ -1035,7 +1035,7 @@ public class MPrintFormat extends X_AD_PrintFormat /*************************************************************************/ /** Cached Formats */ - static private CCache s_formats = new CCache("AD_PrintFormat", 30); + static private CCache s_formats = new CCache(Table_Name, 30); /** * Get Format diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java b/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java index 5c9e1de0c5..7c71e683bf 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java @@ -383,7 +383,7 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem /** Lookup Map of AD_Column_ID for ColumnName */ - private static CCache s_columns = new CCache("AD_PrintFormatItem", 200); + private static CCache s_columns = new CCache(Table_Name, 200); /** * Get ColumnName from AD_Column_ID diff --git a/org.adempiere.base/src/org/compiere/print/MPrintPaper.java b/org.adempiere.base/src/org/compiere/print/MPrintPaper.java index aa19aa39d9..81b650d3d1 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintPaper.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintPaper.java @@ -93,7 +93,7 @@ public class MPrintPaper extends X_AD_PrintPaper private static CLogger s_log = CLogger.getCLogger(MPrintPaper.class); /** Cached Fonts */ static private CCache s_papers - = new CCache("AD_PrintPaper", 5); + = new CCache(Table_Name, 5); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java index 825f355cbb..22d781c165 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintTableFormat.java @@ -536,7 +536,7 @@ public class MPrintTableFormat extends X_AD_PrintTableFormat /*************************************************************************/ private static CCache s_cache - = new CCache("AD_PrintTableFormat", 3); + = new CCache(Table_Name, 3); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger(MPrintTableFormat.class); diff --git a/org.adempiere.base/src/org/compiere/print/layout/ImageElement.java b/org.adempiere.base/src/org/compiere/print/layout/ImageElement.java index 3fd49da828..2bfcaffa34 100644 --- a/org.adempiere.base/src/org/compiere/print/layout/ImageElement.java +++ b/org.adempiere.base/src/org/compiere/print/layout/ImageElement.java @@ -121,7 +121,7 @@ public class ImageElement extends PrintElement /** 60 minute Cache */ private static CCache s_cache - = new CCache("ImageElement", 10, 60); + = new CCache(null, "ImageElement", 10, 60, false); /************************************************************************** * Create from existing Image diff --git a/org.adempiere.base/src/org/compiere/report/MReportTree.java b/org.adempiere.base/src/org/compiere/report/MReportTree.java index 3b0a5a6c51..69541c30fb 100644 --- a/org.adempiere.base/src/org/compiere/report/MReportTree.java +++ b/org.adempiere.base/src/org/compiere/report/MReportTree.java @@ -91,7 +91,7 @@ public class MReportTree } // getChildIDs /** Map with Tree */ - private static CCache s_trees = new CCache("MReportTree", 20); + private static CCache s_trees = new CCache(null, "MReportTree", 20, false); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/util/CCache.java b/org.adempiere.base/src/org/compiere/util/CCache.java index 3a779314c9..c477a86271 100644 --- a/org.adempiere.base/src/org/compiere/util/CCache.java +++ b/org.adempiere.base/src/org/compiere/util/CCache.java @@ -18,49 +18,87 @@ package org.compiere.util; import java.beans.VetoableChangeListener; import java.beans.VetoableChangeSupport; +import java.io.Serializable; import java.util.Collection; -import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.adempiere.base.Service; +import org.idempiere.distributed.ICacheService; + /** - * Adempiere Cache. + * Cache for table. * @param Key * @param Value * * @author Jorg Janke * @version $Id: CCache.java,v 1.2 2006/07/30 00:54:35 jjanke Exp $ */ -public class CCache extends HashMap implements CacheInterface +public class CCache implements CacheInterface, Map, Serializable { /** * */ private static final long serialVersionUID = -2268565219001179841L; + private Map cache = null; + + private Set nullList = null; + + private String m_tableName; + + private boolean m_distributed; + + public CCache (String name, int initialCapacity) + { + this(name, name, initialCapacity); + } + + public CCache (String name, int initialCapacity, int expireMinutes) + { + this(name, initialCapacity, expireMinutes, false); + } + + public CCache (String name, int initialCapacity, int expireMinutes, boolean distributed) + { + this(name, name, initialCapacity, expireMinutes, distributed); + } + /** * Adempiere Cache - expires after 2 hours * @param name (table) name of the cache * @param initialCapacity initial capacity */ - public CCache (String name, int initialCapacity) + public CCache (String tableName, String name, int initialCapacity) { - this (name, initialCapacity, 120); + this (tableName, name, initialCapacity, false); } // CCache - + public CCache (String tableName, String name, int initialCapacity, boolean distributed) + { + this (tableName, name, initialCapacity, 120, distributed); + } + /** * Adempiere Cache * @param name (table) name of the cache * @param initialCapacity initial capacity * @param expireMinutes expire after minutes (0=no expire) */ - public CCache (String name, int initialCapacity, int expireMinutes) + public CCache (String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed) { - super(initialCapacity); +// super(initialCapacity); m_name = name; + m_tableName = tableName; setExpireMinutes(expireMinutes); - CacheMgt.get().register(this); + cache = CacheMgt.get().register(this, distributed); + m_distributed = distributed; + if (distributed) { + ICacheService provider = Service.locator().locate(ICacheService.class).getService(); + if (provider != null) { + nullList = provider.getSet(name); + } + } } // CCache /** Name */ @@ -86,6 +124,11 @@ public class CCache extends HashMap implements CacheInterface return m_name; } // getName + public String getTableName() + { + return m_tableName; + } + /** * Set Expire Minutes and start it * @param expireMinutes minutes or 0 @@ -138,7 +181,7 @@ public class CCache extends HashMap implements CacheInterface */ public int reset() { - int no = super.size(); + int no = cache.size(); clear(); return no; } // reset @@ -163,7 +206,7 @@ public class CCache extends HashMap implements CacheInterface { return "CCache[" + m_name + ",Exp=" + getExpireMinutes() - + ", #" + super.size() + "]"; + + ", #" + cache.size() + "]"; } // toString /** @@ -176,7 +219,7 @@ public class CCache extends HashMap implements CacheInterface { try { - m_changeSupport.fireVetoableChange(PROPERTYNAME, super.size(), 0); + m_changeSupport.fireVetoableChange(PROPERTYNAME, cache.size(), 0); } catch (Exception e) { @@ -185,7 +228,7 @@ public class CCache extends HashMap implements CacheInterface } } // Clear - super.clear(); + cache.clear(); if (m_expire != 0) { long addMS = 60000L * m_expire; @@ -201,7 +244,14 @@ public class CCache extends HashMap implements CacheInterface public boolean containsKey(Object key) { expire(); - return super.containsKey(key); + if (nullList != null) + { + return cache.containsKey(key) || nullList.contains(key); + } + else + { + return cache.containsKey(key); + } } // containsKey /** @@ -210,7 +260,7 @@ public class CCache extends HashMap implements CacheInterface public boolean containsValue(Object value) { expire(); - return super.containsValue(value); + return cache.containsValue(value); } // containsValue /** @@ -219,7 +269,7 @@ public class CCache extends HashMap implements CacheInterface public Set> entrySet() { expire(); - return super.entrySet(); + return cache.entrySet(); } // entrySet /** @@ -228,7 +278,7 @@ public class CCache extends HashMap implements CacheInterface public V get(Object key) { expire(); - return super.get(key); + return cache.get(key); } // get /** @@ -241,7 +291,13 @@ public class CCache extends HashMap implements CacheInterface { expire(); m_justReset = false; - return super.put (key, value); + if (value == null && m_distributed && nullList != null) { + cache.remove(key); + if (!nullList.contains(key)) + nullList.add(key); + return null; + } + return cache.put (key, value); } // put /** @@ -252,7 +308,7 @@ public class CCache extends HashMap implements CacheInterface { expire(); m_justReset = false; - super.putAll (m); + cache.putAll (m); } // putAll /** @@ -261,7 +317,7 @@ public class CCache extends HashMap implements CacheInterface public boolean isEmpty() { expire(); - return super.isEmpty(); + return cache.isEmpty(); } // isEmpty /** @@ -270,7 +326,7 @@ public class CCache extends HashMap implements CacheInterface public Set keySet() { expire(); - return super.keySet(); + return cache.keySet(); } // keySet /** @@ -279,7 +335,7 @@ public class CCache extends HashMap implements CacheInterface public int size() { expire(); - return super.size(); + return cache.size(); } // size /** @@ -289,7 +345,7 @@ public class CCache extends HashMap implements CacheInterface */ public int sizeNoExpire() { - return super.size(); + return cache.size(); } // size /** @@ -298,7 +354,7 @@ public class CCache extends HashMap implements CacheInterface public Collection values() { expire(); - return super.values(); + return cache.values(); } // values @@ -323,5 +379,20 @@ public class CCache extends HashMap implements CacheInterface if (m_changeSupport != null && listener != null) m_changeSupport.removeVetoableChangeListener(listener); } // removeVetoableChangeListener + + + @Override + public V remove(Object key) { + return cache.remove(key); + } + + @Override + public int reset(int recordId) { + if (recordId < 0) + return reset(); + + V removed = cache.remove(recordId); + return removed != null ? 1 : 0; + } } // CCache diff --git a/org.adempiere.base/src/org/compiere/util/CacheInterface.java b/org.adempiere.base/src/org/compiere/util/CacheInterface.java index 1d1c888405..44ee8ebd3a 100644 --- a/org.adempiere.base/src/org/compiere/util/CacheInterface.java +++ b/org.adempiere.base/src/org/compiere/util/CacheInterface.java @@ -29,6 +29,12 @@ public interface CacheInterface * @return number of items reset */ public int reset(); + + /** + * Reset Cache + * @return number of items reset + */ + public int reset(int recordId); /** * Get Size of Cache diff --git a/org.adempiere.base/src/org/compiere/util/CacheMgt.java b/org.adempiere.base/src/org/compiere/util/CacheMgt.java index 3689e85fd1..8c07f87a42 100644 --- a/org.adempiere.base/src/org/compiere/util/CacheMgt.java +++ b/org.adempiere.base/src/org/compiere/util/CacheMgt.java @@ -16,7 +16,19 @@ *****************************************************************************/ package org.compiere.util; +import java.io.Serializable; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import org.adempiere.base.IServiceHolder; +import org.adempiere.base.Service; +import org.idempiere.distributed.ICacheService; +import org.idempiere.distributed.IClusterService; /** * Adempiere Cache Management @@ -56,21 +68,35 @@ public class CacheMgt /************************************************************************** - * Register Cache Instance + * Create Cache Instance * @param instance Cache + * @param distributed * @return true if added */ - @SuppressWarnings("unchecked") - public synchronized boolean register (CacheInterface instance) + public synchronized Map register (CCache instance, boolean distributed) { if (instance == null) - return false; - if (instance instanceof CCache) - { - String tableName = ((CCache)instance).getName(); + return null; + + String name = instance.getName(); + String tableName = instance.getTableName(); + if (tableName != null) m_tableNames.add(tableName); + + m_instances.add (instance); + Map map = null; + if (distributed) + { + ICacheService provider = Service.locator().locate(ICacheService.class).getService(); + if (provider != null) + map = provider.getMap(name); } - return m_instances.add (instance); + + if (map == null) + { + map = new HashMap(); + } + return map; } // register /** @@ -96,11 +122,81 @@ public class CacheMgt return found; } // unregister - /************************************************************************** - * Reset All registered Cache + /** + * do a cluster wide cache reset + * @return number of deleted cache entries + */ + private int clusterReset() { + return clusterReset(null, -1); + } + + /** + * do a cluster wide cache reset for tableName with recordId key + * @param tableName + * @param recordId record id for the cache entries to delete. pass -1 if you don't want to delete + * cache entries by record id + * @return number of deleted cache entries + */ + private int clusterReset(String tableName, int recordId) { + IServiceHolder holder = Service.locator().locate(IClusterService.class); + IClusterService service = holder.getService(); + if (service != null) { + ResetCacheCallable callable = new ResetCacheCallable(tableName, recordId); + Future> future = service.execute(callable, service.getMembers()); + int total = 0; + try { + Collection results = future.get(); + for(Integer i : results) + { + total += i.intValue(); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + return total; + } else { + return resetLocalCache(tableName, recordId); + } + } + + /** + * do a cluster wide cache reset + * @return number of deleted cache entries + */ + public int reset() + { + return clusterReset(); + } + + /** + * do a cluster wide cache reset for tableName + * @param tableName table name * @return number of deleted cache entries */ - public int reset() + public int reset (String tableName) + { + return reset(tableName, -1); + } + + /** + * do a cluster wide cache reset for tableName with recordId key + * @param tableName + * @param Record_ID record id for the cache entries to delete. pass -1 if you don't want to delete + * cache entries by record id + * @return number of deleted cache entries + */ + public int reset (String tableName, int Record_ID) + { + return clusterReset(tableName, Record_ID); + } + + /************************************************************************** + * Reset local Cache + * @return number of deleted cache entries + */ + public int resetLocalCache() { int counter = 0; int total = 0; @@ -116,31 +212,19 @@ public class CacheMgt } log.fine("#" + counter + " (" + total + ")"); return total; - } // reset - - /** - * Reset registered Cache - * @param tableName table name - * @return number of deleted cache entries - */ - public int reset (String tableName) - { - return reset (tableName, 0); - } // reset + } /** - * Reset registered Cache + * Reset local Cache * @param tableName table name * @param Record_ID record if applicable or 0 for all * @return number of deleted cache entries */ @SuppressWarnings("unchecked") - public int reset (String tableName, int Record_ID) + protected int resetLocalCache (String tableName, int Record_ID) { if (tableName == null) - return reset(); - // if (tableName.endsWith("Set")) - // tableName = tableName.substring(0, tableName.length()-3); + return resetLocalCache(); if (!m_tableNames.contains(tableName)) return 0; // @@ -152,12 +236,11 @@ public class CacheMgt if (stored != null && stored instanceof CCache) { CCache cc = (CCache)stored; - if (cc.getName().startsWith(tableName)) // reset lines/dependent too + if (cc.getTableName() != null && cc.getTableName().startsWith(tableName)) // reset lines/dependent too { - // if (Record_ID == 0) { log.fine("(all) - " + stored); - total += stored.reset(); + total += stored.reset(Record_ID); counter++; } } @@ -166,7 +249,7 @@ public class CacheMgt log.fine(tableName + ": #" + counter + " (" + total + ")"); return total; - } // reset + } /** * Total Cached Elements @@ -218,6 +301,5 @@ public class CacheMgt .append(getElementCount()) .append("]"); return sb.toString (); - } // toString - + } // toString } // CCache diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index 0985c7564d..33f175d035 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -51,6 +51,7 @@ import org.adempiere.util.IProcessUI; import org.adempiere.util.ServerContextProvider; import org.compiere.db.CConnection; import org.compiere.model.GridWindowVO; +import org.compiere.model.I_AD_Window; import org.compiere.model.MClient; import org.compiere.model.MLookupCache; import org.compiere.model.MRole; @@ -176,16 +177,19 @@ public final class Env getCtx().remove(keys[i]); } } - - // Cache - CacheMgt.get().reset(); - if (Ini.isClient()) + + if (Ini.isClient()) { DB.closeTarget(); + } + // Reset Role Access if (!finalCall) { - if (Ini.isClient()) + if (Ini.isClient()) { + // Cache + CacheMgt.get().resetLocalCache(); DB.setDBTarget(CConnection.get()); + } MRole defaultRole = MRole.getDefault(getCtx(), false); if (defaultRole != null) defaultRole.loadAccess(true); // Reload @@ -1694,7 +1698,7 @@ public final class Env /** Window Cache */ private static CCache s_windowsvo - = new CCache("AD_Window", 10); + = new CCache(I_AD_Window.Table_Name, 10); /** * Get Window Model diff --git a/org.adempiere.base/src/org/compiere/util/Msg.java b/org.adempiere.base/src/org/compiere/util/Msg.java index a5f5efbbd4..07bac85192 100644 --- a/org.adempiere.base/src/org/compiere/util/Msg.java +++ b/org.adempiere.base/src/org/compiere/util/Msg.java @@ -26,6 +26,7 @@ import java.util.Properties; import java.util.logging.Level; import org.compiere.Adempiere; +import org.compiere.model.I_AD_Message; /** * Reads all Messages and stores them in a HashMap @@ -67,7 +68,7 @@ public final class Msg /** The Map */ private CCache> m_languages - = new CCache>("msg_lang", 2, 0); + = new CCache>(null, "msg_lang", 2, 0, false); /** * Get Language specific Message Map @@ -105,7 +106,7 @@ public final class Msg private CCache initMsg (String AD_Language) { // Trace.printStack(); - CCache msg = new CCache("AD_Message", MAP_SIZE, 0); + CCache msg = new CCache(I_AD_Message.Table_Name, MAP_SIZE, 0); // if (!DB.isConnected()) { diff --git a/org.adempiere.base/src/org/compiere/util/ResetCacheCallable.java b/org.adempiere.base/src/org/compiere/util/ResetCacheCallable.java new file mode 100644 index 0000000000..cb817bf1a9 --- /dev/null +++ b/org.adempiere.base/src/org/compiere/util/ResetCacheCallable.java @@ -0,0 +1,46 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.compiere.util; + +import java.io.Serializable; +import java.util.concurrent.Callable; + +/** + * + * @author hengsin + * + */ +public class ResetCacheCallable implements Callable, Serializable +{ + + /** + * generated serial id + */ + private static final long serialVersionUID = 6669645804211785491L; + + private String tableName; + private int Record_ID; + + protected ResetCacheCallable(String tableName, int Record_ID) + { + this.tableName = tableName; + this.Record_ID = Record_ID; + } + + @Override + public Integer call() throws Exception { + return CacheMgt.get().resetLocalCache(tableName, Record_ID); + } + +} \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/util/Trx.java b/org.adempiere.base/src/org/compiere/util/Trx.java index 98ab7cbe11..5a03896eb1 100644 --- a/org.adempiere.base/src/org/compiere/util/Trx.java +++ b/org.adempiere.base/src/org/compiere/util/Trx.java @@ -16,14 +16,13 @@ *****************************************************************************/ package org.compiere.util; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; import java.sql.Connection; import java.sql.SQLException; import java.sql.Savepoint; import java.util.Collection; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -54,7 +53,7 @@ import org.compiere.model.PO; *
  • BF [ 2849122 ] PO.AfterSave is not rollback on error - add releaseSavepoint method * https://sourceforge.net/tracker/index.php?func=detail&aid=2849122&group_id=176962&atid=879332# */ -public class Trx implements VetoableChangeListener +public class Trx { /** * Get Transaction @@ -69,8 +68,7 @@ public class Trx implements VetoableChangeListener if (s_cache == null) { - s_cache = new CCache("Trx", 10, -1); // no expiration - s_cache.addVetoableChangeListener(new Trx("controller_" + "_" + UUID.randomUUID())); + s_cache = new HashMap(10); } Trx retValue = (Trx)s_cache.get(trxName); @@ -83,7 +81,7 @@ public class Trx implements VetoableChangeListener } // get /** Transaction Cache */ - private static CCache s_cache = null; // create change listener + private static Map s_cache = null; // create change listener private static Trx.TrxMonitor s_monitor = new Trx.TrxMonitor(); @@ -484,19 +482,6 @@ public class Trx implements VetoableChangeListener return sb.toString(); } // toString - /** - * Vetoable Change. - * Called from CCache to close connections - * @param evt event - * @throws PropertyVetoException - */ - public void vetoableChange (PropertyChangeEvent evt) - throws PropertyVetoException - { - log.info(evt.toString()); - throw new PropertyVetoException("Skip reset for trx entries cache", evt); - } // vetoableChange - /** * @return Trx[] */ diff --git a/org.adempiere.base/src/org/compiere/util/WebSessionCtx.java b/org.adempiere.base/src/org/compiere/util/WebSessionCtx.java index 5e71e4e88e..943b8beaaa 100644 --- a/org.adempiere.base/src/org/compiere/util/WebSessionCtx.java +++ b/org.adempiere.base/src/org/compiere/util/WebSessionCtx.java @@ -99,7 +99,7 @@ public class WebSessionCtx implements Serializable /** Logger */ static private CLogger log = CLogger.getCLogger (WebSessionCtx.class); /** Cache 60 minutes */ - static private CCache s_cacheCtx = new CCache("WebSessionCtx", 30, 60); + static private CCache s_cacheCtx = new CCache(null, "WebSessionCtx", 30, 60, false); /************************************************************************** * Web Session Context diff --git a/org.adempiere.base/src/org/compiere/wf/MWFBlock.java b/org.adempiere.base/src/org/compiere/wf/MWFBlock.java index 793870b473..aad279f718 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWFBlock.java +++ b/org.adempiere.base/src/org/compiere/wf/MWFBlock.java @@ -56,7 +56,7 @@ public class MWFBlock extends X_AD_WF_Block } // get /** Cache */ - private static CCache s_cache = new CCache("AD_WF_Block", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** diff --git a/org.adempiere.base/src/org/compiere/wf/MWFResponsible.java b/org.adempiere.base/src/org/compiere/wf/MWFResponsible.java index 298665e370..8e99803d4a 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWFResponsible.java +++ b/org.adempiere.base/src/org/compiere/wf/MWFResponsible.java @@ -58,7 +58,7 @@ public class MWFResponsible extends X_AD_WF_Responsible } // get /** Cache */ - private static CCache s_cache = new CCache("AD_WF_Responsible", 10); + private static CCache s_cache = new CCache(Table_Name, 10); /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/wf/MWorkflow.java b/org.adempiere.base/src/org/compiere/wf/MWorkflow.java index a82422577c..305fb057ce 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWorkflow.java +++ b/org.adempiere.base/src/org/compiere/wf/MWorkflow.java @@ -140,9 +140,9 @@ public class MWorkflow extends X_AD_Workflow /** Single Cache */ - private static CCache s_cache = new CCache("AD_Workflow", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Document Value Cache */ - private static CCache s_cacheDocValue = new CCache ("AD_Workflow", 5); + private static CCache s_cacheDocValue = new CCache (Table_Name, Table_Name+"_Document_Value", 5); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MWorkflow.class); diff --git a/org.adempiere.base/src/org/eevolution/process/EnableNativeSequence.java b/org.adempiere.base/src/org/eevolution/process/EnableNativeSequence.java index 91e243437e..e3d2244325 100644 --- a/org.adempiere.base/src/org/eevolution/process/EnableNativeSequence.java +++ b/org.adempiere.base/src/org/eevolution/process/EnableNativeSequence.java @@ -36,6 +36,7 @@ import org.compiere.model.X_AD_Table; import org.compiere.process.ProcessInfo; import org.compiere.process.SvrProcess; import org.compiere.util.CLogMgt; +import org.compiere.util.CacheMgt; import org.compiere.util.Env; /** @@ -66,7 +67,7 @@ public class EnableNativeSequence extends SvrProcess MSysConfig conf = new MSysConfig(getCtx(), SystemIDs.SYSCONFIG_SYSTEM_NATIVE_SEQUENCE, null); conf.setValue("Y"); conf.saveEx(); - MSysConfig.resetCache(); + CacheMgt.get().reset(MSysConfig.Table_Name); try { diff --git a/org.adempiere.base/src/org/idempiere/distributed/ICacheService.java b/org.adempiere.base/src/org/idempiere/distributed/ICacheService.java new file mode 100644 index 0000000000..28261d29ba --- /dev/null +++ b/org.adempiere.base/src/org/idempiere/distributed/ICacheService.java @@ -0,0 +1,14 @@ +package org.idempiere.distributed; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public interface ICacheService { + + public Map getMap(String name); + + public List getList(String name); + + public Set getSet(String name); +} diff --git a/org.adempiere.base/src/org/idempiere/distributed/IClusterMember.java b/org.adempiere.base/src/org/idempiere/distributed/IClusterMember.java new file mode 100644 index 0000000000..0e9362796c --- /dev/null +++ b/org.adempiere.base/src/org/idempiere/distributed/IClusterMember.java @@ -0,0 +1,8 @@ +package org.idempiere.distributed; + +import java.net.InetAddress; + +public interface IClusterMember { + public String getId(); + public InetAddress getAddress(); +} diff --git a/org.adempiere.base/src/org/idempiere/distributed/IClusterService.java b/org.adempiere.base/src/org/idempiere/distributed/IClusterService.java new file mode 100644 index 0000000000..7d154acb50 --- /dev/null +++ b/org.adempiere.base/src/org/idempiere/distributed/IClusterService.java @@ -0,0 +1,14 @@ +package org.idempiere.distributed; + +import java.util.Collection; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; + +public interface IClusterService { + + public Collection getMembers(); + public IClusterMember getLocalMember(); + + public Future execute(Callable task, IClusterMember member); + public Future> execute(Callable task, Collection members); +} diff --git a/org.adempiere.base/src/org/idempiere/distributed/IMessageService.java b/org.adempiere.base/src/org/idempiere/distributed/IMessageService.java new file mode 100644 index 0000000000..16a7a9d0c1 --- /dev/null +++ b/org.adempiere.base/src/org/idempiere/distributed/IMessageService.java @@ -0,0 +1,5 @@ +package org.idempiere.distributed; + +public interface IMessageService { + public ITopic getTopic(String name); +} diff --git a/org.adempiere.base/src/org/idempiere/distributed/ITopic.java b/org.adempiere.base/src/org/idempiere/distributed/ITopic.java new file mode 100644 index 0000000000..615a708a06 --- /dev/null +++ b/org.adempiere.base/src/org/idempiere/distributed/ITopic.java @@ -0,0 +1,15 @@ +/** + * + */ +package org.idempiere.distributed; + +/** + * @author hengsin + * + */ +public interface ITopic { + public String getName(); + public void subscribe(ITopicSubscriber subscriber); + public void unsubscribe(ITopicSubscriber subscriber); + public void publish(T message); +} diff --git a/org.adempiere.base/src/org/idempiere/distributed/ITopicSubscriber.java b/org.adempiere.base/src/org/idempiere/distributed/ITopicSubscriber.java new file mode 100644 index 0000000000..adce012642 --- /dev/null +++ b/org.adempiere.base/src/org/idempiere/distributed/ITopicSubscriber.java @@ -0,0 +1,5 @@ +package org.idempiere.distributed; + +public interface ITopicSubscriber { + public void onMessage(T message); +} diff --git a/org.adempiere.sdk-feature/adempiere.cquery b/org.adempiere.sdk-feature/adempiere.cquery index dc79537c40..08b340bc21 100644 --- a/org.adempiere.sdk-feature/adempiere.cquery +++ b/org.adempiere.sdk-feature/adempiere.cquery @@ -6,13 +6,7 @@ - - - - - - - - - + + + diff --git a/org.adempiere.sdk-feature/adempiere.rmap b/org.adempiere.sdk-feature/adempiere.rmap index 677d7d3152..2e641ef2f2 100644 --- a/org.adempiere.sdk-feature/adempiere.rmap +++ b/org.adempiere.sdk-feature/adempiere.rmap @@ -3,6 +3,7 @@ + @@ -13,7 +14,6 @@ - @@ -35,16 +35,14 @@ - + - + - - diff --git a/org.adempiere.sdk-feature/feature.xml b/org.adempiere.sdk-feature/feature.xml index e704f8af66..0f7fa007c8 100644 --- a/org.adempiere.sdk-feature/feature.xml +++ b/org.adempiere.sdk-feature/feature.xml @@ -29,6 +29,11 @@ id="org.adempiere.ui.swing" version="0.0.0"/> + + + @@ -52,6 +53,7 @@ + diff --git a/org.adempiere.server-feature/server.product.launch b/org.adempiere.server-feature/server.product.launch index 9dc3ec5989..5e499556e9 100644 --- a/org.adempiere.server-feature/server.product.launch +++ b/org.adempiere.server-feature/server.product.launch @@ -21,8 +21,8 @@ - - + + diff --git a/org.adempiere.ui.swing-feature/buckminster_linux_gtk_x86_64.properties b/org.adempiere.ui.swing-feature/buckminster_linux_gtk_x86_64.properties new file mode 100644 index 0000000000..aec56eaf81 --- /dev/null +++ b/org.adempiere.ui.swing-feature/buckminster_linux_gtk_x86_64.properties @@ -0,0 +1,15 @@ +## buckminster.properties ## +#Where all the output should go +buckminster.output.root=${user.home}/buckminster.output +# Where the temp files should go +buckminster.temp.root=${user.home}/tmp +# How .qualifier in versions should be replaced +qualifier.replacement.*=generator:buildTimestamp +generator.buildTimestamp.format='v'yyyyMMdd-HHmm +target.os=linux +target.ws=gtk +target.arch=x86_64 + +product.features=org.idempiere.eclipse.platform.feature.group +product.profile=DefaultProfile +product.id=org.adempiere.ui.swing.product diff --git a/org.adempiere.ui.swing-feature/swingclient.product b/org.adempiere.ui.swing-feature/swingclient.product index a860309522..0d40ead680 100644 --- a/org.adempiere.ui.swing-feature/swingclient.product +++ b/org.adempiere.ui.swing-feature/swingclient.product @@ -28,6 +28,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/org.adempiere.ui.swing-feature/swingclient.product.launch b/org.adempiere.ui.swing-feature/swingclient.product.launch index 6aa65fba3d..d94907060b 100644 --- a/org.adempiere.ui.swing-feature/swingclient.product.launch +++ b/org.adempiere.ui.swing-feature/swingclient.product.launch @@ -21,8 +21,8 @@ - - + + diff --git a/org.adempiere.ui.swing/src/org/adempiere/client/Application.java b/org.adempiere.ui.swing/src/org/adempiere/client/Application.java index aaeee2adf6..beaf8560cf 100644 --- a/org.adempiere.ui.swing/src/org/adempiere/client/Application.java +++ b/org.adempiere.ui.swing/src/org/adempiere/client/Application.java @@ -6,6 +6,7 @@ import java.util.List; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; +import org.compiere.Adempiere; import org.compiere.util.CLogger; import org.eclipse.equinox.app.IApplication; @@ -41,6 +42,7 @@ public class Application implements IApplication { context.setClientDispatcher(client); client.start(); + Adempiere.startup(true); org.compiere.AdempiereClient.main(new String[]{}); return IApplication.EXIT_OK; } diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ALogin.java b/org.adempiere.ui.swing/src/org/compiere/apps/ALogin.java index 56754ae554..2d29e534b5 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ALogin.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/ALogin.java @@ -31,6 +31,7 @@ import java.sql.Timestamp; import java.util.Locale; import java.util.Properties; import java.util.ResourceBundle; +import java.util.logging.Level; import javax.swing.JOptionPane; import javax.swing.JPasswordField; @@ -890,7 +891,7 @@ public final class ALogin extends CDialog } else { - log.severe(CLogger.getRootCause(e).getLocalizedMessage()); + log.log(Level.SEVERE, CLogger.getRootCause(e).getLocalizedMessage(), CLogger.getRootCause(e)); statusBar.setStatusLine(CLogger.getRootCause(e).getLocalizedMessage(), true); return NOT_CONNECTED; } diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java index a2c1bcea76..1f359a365d 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java @@ -784,8 +784,6 @@ public class VLocationDialog extends CDialog if (region.save()) { log.fine("Added new region from web service: " + values.getRegion()); - // clears cache - Env.reset(false); //reload regions to combo box fRegion = new CComboBoxEditable(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())); // select region diff --git a/org.adempiere.ui.zk/META-INF/MANIFEST.MF b/org.adempiere.ui.zk/META-INF/MANIFEST.MF index c1aa808ed8..45c5b862bb 100644 --- a/org.adempiere.ui.zk/META-INF/MANIFEST.MF +++ b/org.adempiere.ui.zk/META-INF/MANIFEST.MF @@ -57,4 +57,4 @@ Bundle-Activator: org.adempiere.webui.WebUIActivator Eclipse-ExtensibleAPI: true Eclipse-RegisterBuddy: org.zkoss.zk.library Web-ContextPath: webui -Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml, OSGI-INF/defaultpaymentformfactory.xml +Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml, OSGI-INF/defaultpaymentformfactory.xml, OSGI-INF/processfactory.xml diff --git a/org.adempiere.ui.zk/OSGI-INF/processfactory.xml b/org.adempiere.ui.zk/OSGI-INF/processfactory.xml new file mode 100644 index 0000000000..04cbf3c7da --- /dev/null +++ b/org.adempiere.ui.zk/OSGI-INF/processfactory.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java index af81929214..87e70ea264 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java @@ -29,8 +29,8 @@ import org.zkoss.image.AImage; public class Actions { private static final String ACTION_IMAGES_PATH = "/action/images/"; - private static CCache> trackerCache = new CCache>("ActionsServiceTracker", 5); - private static CCache imageCache = new CCache("ActionsImages",5); + private static CCache> trackerCache = new CCache>(null, "ActionsServiceTracker", 5, false); + private static CCache imageCache = new CCache(null, "ActionsImages",5, false); public static IServiceHolder getAction(String actionId) { IServiceHolder action = null; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java index 9836a95a4f..b20681883a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java @@ -48,7 +48,7 @@ public class ADWindow extends AbstractUIPart private Component windowPanelComponent; private MImage image; - private static final CCache imageCache = new CCache("WindowImageCache", 5); + private static final CCache imageCache = new CCache(null, "WindowImageCache", 5, false); public ADWindow(Properties ctx, int adWindowId) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index 3b51c94fc3..c3c5cebe07 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -45,6 +45,7 @@ import org.adempiere.webui.util.IServerPushCallback; import org.adempiere.webui.util.ServerPushTemplate; import org.compiere.acct.Doc; import org.compiere.model.GridWindowVO; +import org.compiere.model.I_AD_Window; import org.compiere.model.Lookup; import org.compiere.model.MAcctSchema; import org.compiere.model.MLookup; @@ -288,7 +289,7 @@ public final class AEnv CCache cache = windowCache.get(sessionID); if (cache == null) { - cache = new CCache("AD_Window", 10); + cache = new CCache(I_AD_Window.Table_Name, 10); windowCache.put(sessionID, cache); } cache.put(AD_Window_ID, mWindowVO); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java index 7386f9b1ef..41e2cbe133 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java @@ -234,7 +234,7 @@ public class WDocActionPanel extends Window implements EventListener, Dia lstDocAction.setId("lstDocAction"); lstDocAction.setRows(0); lstDocAction.setMold("select"); - lstDocAction.setWidth("100px"); + lstDocAction.setWidth("200px"); lstDocAction.addEventListener(Events.ON_SELECT, this); confirmPanel = new ConfirmPanel(true); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/CacheReset.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/CacheReset.java index 0525663dce..e973eb573f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/CacheReset.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/CacheReset.java @@ -42,8 +42,8 @@ public class CacheReset extends SvrProcess */ protected String doIt() throws java.lang.Exception { - CacheMgt.get().reset(); - return "Cache Reset"; + int count = CacheMgt.get().reset(); + return "Cache Reset #" + count; } // doIt } // CacheReset diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/ProcessFactoryImpl.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/ProcessFactoryImpl.java new file mode 100644 index 0000000000..9a553df352 --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/ProcessFactoryImpl.java @@ -0,0 +1,45 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.webui.util; + +import org.adempiere.base.IProcessFactory; +import org.compiere.process.ProcessCall; + +/** + * @author hengsin + * + */ +public class ProcessFactoryImpl implements IProcessFactory { + + /** + * default constructor + */ + public ProcessFactoryImpl() { + } + + /* (non-Javadoc) + * @see org.adempiere.base.IProcessFactory#newProcessInstance(java.lang.String) + */ + @Override + public ProcessCall newProcessInstance(String className) { + ProcessCall process = null; + try { + Class clazz = getClass().getClassLoader().loadClass(className); + process = (ProcessCall) clazz.newInstance(); + } catch (Exception e) { + } + return process; + } + +} diff --git a/org.adempiere.ui.zk/build.properties b/org.adempiere.ui.zk/build.properties index 1359ade0ba..3ac783b6fc 100644 --- a/org.adempiere.ui.zk/build.properties +++ b/org.adempiere.ui.zk/build.properties @@ -1,52 +1,53 @@ -output.. = WEB-INF/classes/ -bin.includes = META-INF/,\ - WEB-INF/,\ - css/,\ - images/,\ - index.zul,\ - js/,\ - theme/,\ - theme.zs,\ - zul/,\ - timeout.zul,\ - plugin.xml,\ - WEB-INF/classes/,\ - WEB-INF/lib/atmosphere-runtime-0.9.jar,\ - WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\ - WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\ - WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\ - metainfo/,\ - WEB-INF/lib/calendar.jar,\ - calendar.css,\ - calendar.zul,\ - calendar_mini.zul,\ - divarrow.zul,\ - divtab.zul,\ - OSGI-INF/,\ - OSGI-INF/reportviewerprovider.xml,\ - OSGI-INF/defaultinfofactory.xml,\ - OSGI-INF/defaulteditorfactory.xml,\ - OSGI-INF/jrviewerprovider.xml,\ - OSGI-INF/resourcefinder.xml,\ - OSGI-INF/defaultpaymentformfactory.xml -src.includes = WEB-INF/classes/,\ - WEB-INF/tld/,\ - WEB-INF/web.xml,\ - WEB-INF/xsd/,\ - WEB-INF/zk.xml,\ - css/,\ - images/,\ - index.zul,\ - js/,\ - theme/,\ - theme.zs,\ - zul/,\ - metainfo/,\ - calendar.css,\ - calendar.zul,\ - calendar_mini.zul,\ - divarrow.zul,\ - divtab.zul -source.. = WEB-INF/src/ -bin.excludes = WEB-INF/src/,\ - WEB-INF/web-2.5.xml +output.. = WEB-INF/classes/ +bin.includes = META-INF/,\ + WEB-INF/,\ + css/,\ + images/,\ + index.zul,\ + js/,\ + theme/,\ + theme.zs,\ + zul/,\ + timeout.zul,\ + plugin.xml,\ + WEB-INF/classes/,\ + WEB-INF/lib/atmosphere-runtime-0.9.jar,\ + WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\ + WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\ + WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\ + metainfo/,\ + WEB-INF/lib/calendar.jar,\ + calendar.css,\ + calendar.zul,\ + calendar_mini.zul,\ + divarrow.zul,\ + divtab.zul,\ + OSGI-INF/,\ + OSGI-INF/reportviewerprovider.xml,\ + OSGI-INF/defaultinfofactory.xml,\ + OSGI-INF/defaulteditorfactory.xml,\ + OSGI-INF/jrviewerprovider.xml,\ + OSGI-INF/resourcefinder.xml,\ + OSGI-INF/defaultpaymentformfactory.xml,\ + OSGI-INF/processfactory.xml +src.includes = WEB-INF/classes/,\ + WEB-INF/tld/,\ + WEB-INF/web.xml,\ + WEB-INF/xsd/,\ + WEB-INF/zk.xml,\ + css/,\ + images/,\ + index.zul,\ + js/,\ + theme/,\ + theme.zs,\ + zul/,\ + metainfo/,\ + calendar.css,\ + calendar.zul,\ + calendar_mini.zul,\ + divarrow.zul,\ + divtab.zul +source.. = WEB-INF/src/ +bin.excludes = WEB-INF/src/,\ + WEB-INF/web-2.5.xml diff --git a/org.adempiere.webstore.servlet/src/org/compiere/wstore/PriceList.java b/org.adempiere.webstore.servlet/src/org/compiere/wstore/PriceList.java index 3b42811559..ee145b2611 100644 --- a/org.adempiere.webstore.servlet/src/org/compiere/wstore/PriceList.java +++ b/org.adempiere.webstore.servlet/src/org/compiere/wstore/PriceList.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Properties; import java.util.logging.Level; +import org.compiere.model.I_M_PriceList; import org.compiere.model.MProductCategory; import org.compiere.util.CCache; import org.compiere.util.CLogger; @@ -95,7 +96,7 @@ public class PriceList /** Price List Cache */ private static CCache s_cache - = new CCache("PriceList", 5, 60); // 1h Cache + = new CCache(I_M_PriceList.Table_Name, "PriceList", 5, 60, true); // 1h Cache /** Maximum Lines to be displayed */ public static int MAX_LINES = 50; diff --git a/org.adempiere.webstore.servlet/src/org/compiere/wstore/ProductCategoryListTag.java b/org.adempiere.webstore.servlet/src/org/compiere/wstore/ProductCategoryListTag.java index af7e8da10c..b3e58ca03c 100644 --- a/org.adempiere.webstore.servlet/src/org/compiere/wstore/ProductCategoryListTag.java +++ b/org.adempiere.webstore.servlet/src/org/compiere/wstore/ProductCategoryListTag.java @@ -25,6 +25,8 @@ import javax.servlet.jsp.tagext.TagSupport; import org.apache.ecs.xhtml.option; import org.apache.ecs.xhtml.select; +import org.compiere.model.I_M_Product; +import org.compiere.model.I_M_Product_Category; import org.compiere.util.CCache; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -129,7 +131,7 @@ public class ProductCategoryListTag extends TagSupport /** Client Category Cache */ static CCache s_categories - = new CCache("ProductCategory", 10, 60); + = new CCache(I_M_Product_Category.Table_Name, "ProductCategory", 10, 60, true); } // ProductCategoryListTag diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index 2488bbe053..c97321af89 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -108,7 +108,7 @@ public class DB_PostgreSQL implements AdempiereDatabase public static final String NATIVE_MARKER = "NATIVE_"+Database.DB_POSTGRESQL+"_KEYWORK"; - private CCache convertCache = new CCache("SQLConvertCache", 100, 0); + private CCache convertCache = new CCache(null, "DB_PostgreSQL_Convert_Cache", 1000, 0, true); private Random rand = new Random(); diff --git a/org.idempiere.hazelcast.service-feature/.project b/org.idempiere.hazelcast.service-feature/.project new file mode 100644 index 0000000000..9aaedf9d05 --- /dev/null +++ b/org.idempiere.hazelcast.service-feature/.project @@ -0,0 +1,17 @@ + + + org.idempiere.hazelcast.service-feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/org.idempiere.hazelcast.service-feature/build.properties b/org.idempiere.hazelcast.service-feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/org.idempiere.hazelcast.service-feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/org.idempiere.hazelcast.service-feature/feature.xml b/org.idempiere.hazelcast.service-feature/feature.xml new file mode 100644 index 0000000000..522de724ce --- /dev/null +++ b/org.idempiere.hazelcast.service-feature/feature.xml @@ -0,0 +1,41 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + + + + + diff --git a/org.idempiere.hazelcast.service/.classpath b/org.idempiere.hazelcast.service/.classpath new file mode 100644 index 0000000000..6fe134c47c --- /dev/null +++ b/org.idempiere.hazelcast.service/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/org.idempiere.hazelcast.service/.project b/org.idempiere.hazelcast.service/.project new file mode 100644 index 0000000000..e83f8016aa --- /dev/null +++ b/org.idempiere.hazelcast.service/.project @@ -0,0 +1,33 @@ + + + org.idempiere.hazelcast.service + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.ds.core.builder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.idempiere.hazelcast.service/.settings/org.eclipse.jdt.core.prefs b/org.idempiere.hazelcast.service/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..c537b63063 --- /dev/null +++ b/org.idempiere.hazelcast.service/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.idempiere.hazelcast.service/.settings/org.eclipse.pde.core.prefs b/org.idempiere.hazelcast.service/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000000..f29e940a00 --- /dev/null +++ b/org.idempiere.hazelcast.service/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/org.idempiere.hazelcast.service/META-INF/MANIFEST.MF b/org.idempiere.hazelcast.service/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..e22ebaf44c --- /dev/null +++ b/org.idempiere.hazelcast.service/META-INF/MANIFEST.MF @@ -0,0 +1,31 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: iDempiere Hazelcast Service +Bundle-SymbolicName: org.idempiere.hazelcast.service +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.idempiere.hazelcast.service.Activator +Bundle-ActivationPolicy: lazy +Import-Package: javax.crypto, + javax.crypto.spec, + javax.management, + javax.net.ssl, + javax.security.auth, + javax.security.auth.login, + javax.xml.namespace, + javax.xml.parsers, + javax.xml.transform, + javax.xml.transform.dom, + javax.xml.transform.stream, + javax.xml.xpath, + org.adempiere.base, + org.compiere, + org.compiere.model, + org.idempiere.distributed, + org.osgi.framework;version="1.3.0", + org.slf4j;version="1.6.1", + org.w3c.dom +DynamicImport-Package: * +Bundle-ClassPath: ., + hazelcast-2.4.jar, + hazelcast-cloud-2.4.jar +Service-Component: OSGI-INF/clusterservice.xml, OSGI-INF/cacheservice.xml, OSGI-INF/messageservice.xml diff --git a/org.idempiere.hazelcast.service/OSGI-INF/cacheservice.xml b/org.idempiere.hazelcast.service/OSGI-INF/cacheservice.xml new file mode 100644 index 0000000000..5b1e36ec51 --- /dev/null +++ b/org.idempiere.hazelcast.service/OSGI-INF/cacheservice.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.idempiere.hazelcast.service/OSGI-INF/clusterservice.xml b/org.idempiere.hazelcast.service/OSGI-INF/clusterservice.xml new file mode 100644 index 0000000000..80236ee452 --- /dev/null +++ b/org.idempiere.hazelcast.service/OSGI-INF/clusterservice.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.idempiere.hazelcast.service/OSGI-INF/messageservice.xml b/org.idempiere.hazelcast.service/OSGI-INF/messageservice.xml new file mode 100644 index 0000000000..47af916129 --- /dev/null +++ b/org.idempiere.hazelcast.service/OSGI-INF/messageservice.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.idempiere.hazelcast.service/build.properties b/org.idempiere.hazelcast.service/build.properties new file mode 100644 index 0000000000..936c70cd91 --- /dev/null +++ b/org.idempiere.hazelcast.service/build.properties @@ -0,0 +1,9 @@ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + hazelcast-2.4.jar,\ + hazelcast-cloud-2.4.jar,\ + OSGI-INF/clusterservice.xml,\ + OSGI-INF/cacheservice.xml,\ + OSGI-INF/messageservice.xml +source.. = src/ diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java new file mode 100644 index 0000000000..780fd0f5ea --- /dev/null +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java @@ -0,0 +1,89 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.hazelcast.service; + +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledThreadPoolExecutor; + +import org.compiere.Adempiere; +import org.compiere.model.ServerStateChangeEvent; +import org.compiere.model.ServerStateChangeListener; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +import com.hazelcast.config.*; +import com.hazelcast.core.*; + +/** + * + * @author hengsin + * + */ +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + protected static HazelcastInstance hazelcastInstance; + private Future future; + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + + if (Adempiere.isStarted()) + createHazelCastInstance(); + else { + Adempiere.addServerStateChangeListener(new ServerStateChangeListener() { + + @Override + public void stateChange(ServerStateChangeEvent event) { + if (event.getEventType() == ServerStateChangeEvent.SERVER_START) + createHazelCastInstance(); + } + }); + } + } + + private void createHazelCastInstance() { + ScheduledThreadPoolExecutor executor = Adempiere.getThreadPoolExecutor(); + future = executor.submit(new Runnable() { + @Override + public void run() { + Config config = new Config(); + hazelcastInstance = Hazelcast.newHazelcastInstance(config); + } + }); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + if (future != null && !future.isDone()) { + future.cancel(true); + } else if (hazelcastInstance != null) { + hazelcastInstance.getLifecycleService().shutdown(); + hazelcastInstance = null; + } + } +} diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java new file mode 100644 index 0000000000..c9f9b10301 --- /dev/null +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java @@ -0,0 +1,52 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.hazelcast.service; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.idempiere.distributed.ICacheService; + +/** + * @author hengsin + * + */ +public class CacheServiceImpl implements ICacheService { + + /** + * default constructor + */ + public CacheServiceImpl() { + } + + /* (non-Javadoc) + * @see org.idempiere.distributed.ICacheService#getCache(java.lang.String) + */ + @Override + public Map getMap(String name) { + return Activator.hazelcastInstance.getMap(name); + } + + @Override + public List getList(String name) { + return Activator.hazelcastInstance.getList(name); + } + + @Override + public Set getSet(String name) { + return Activator.hazelcastInstance.getSet(name); + } + +} diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterMember.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterMember.java new file mode 100644 index 0000000000..cbd8f1bb71 --- /dev/null +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterMember.java @@ -0,0 +1,54 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.hazelcast.service; + +import java.net.InetAddress; + +import org.idempiere.distributed.IClusterMember; + +/** + * @author hengsin + * + */ +public class ClusterMember implements IClusterMember { + + private String id; + private InetAddress address; + + /** + * @param id + * @param address + */ + public ClusterMember(String id, InetAddress address) { + this.id = id; + this.address = address; + } + + /* (non-Javadoc) + * @see org.idempiere.distributed.IClusterMember#getId() + */ + @Override + public String getId() { + return id; + } + + /* (non-Javadoc) + * @see org.idempiere.distributed.IClusterMember#getAddress() + */ + @Override + public InetAddress getAddress() { + return address; + } + +} diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterServiceImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterServiceImpl.java new file mode 100644 index 0000000000..a99947e261 --- /dev/null +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterServiceImpl.java @@ -0,0 +1,99 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.hazelcast.service; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; + +import org.idempiere.distributed.IClusterMember; +import org.idempiere.distributed.IClusterService; + +import com.hazelcast.core.DistributedTask; +import com.hazelcast.core.Member; +import com.hazelcast.core.MultiTask; + +/** + * @author hengsin + * + */ +public class ClusterServiceImpl implements IClusterService { + + /* (non-Javadoc) + * @see org.idempiere.distributed.IClusterService#getMembers() + */ + @Override + public Collection getMembers() { + Set members = Activator.hazelcastInstance.getCluster().getMembers(); + Set clusterMembers = new HashSet(); + for(Member member : members) { + clusterMembers.add(new ClusterMember(member.getUuid(), member.getInetSocketAddress().getAddress())); + } + return clusterMembers; + } + + /* (non-Javadoc) + * @see org.idempiere.distributed.IClusterService#getLocalMember() + */ + @Override + public IClusterMember getLocalMember() { + Member member = Activator.hazelcastInstance.getCluster().getLocalMember(); + return new ClusterMember(member.getUuid(), member.getInetSocketAddress().getAddress()); + } + + /* (non-Javadoc) + * @see org.idempiere.distributed.IClusterService#execute(java.util.concurrent.Callable, org.idempiere.distributed.IClusterMember) + */ + @Override + public Future execute(Callable task, IClusterMember clusterMember) { + Set members = Activator.hazelcastInstance.getCluster().getMembers(); + for(Member member : members) { + if (member.getUuid().equals(clusterMember.getId())) { + DistributedTask distributedTask = new DistributedTask(task, member); + Activator.hazelcastInstance.getExecutorService().execute(distributedTask); + return distributedTask; + } + } + return null; + } + + /* (non-Javadoc) + * @see org.idempiere.distributed.IClusterService#execute(java.util.concurrent.Callable, java.util.Collection) + */ + @SuppressWarnings("unchecked") + @Override + public Future> execute(Callable task, + Collection clusterMembers) { + Set selectedIds = new HashSet(); + for(IClusterMember clusterMember : clusterMembers) { + selectedIds.add(clusterMember.getId()); + } + Set members = Activator.hazelcastInstance.getCluster().getMembers(); + Set selectedMembers = new HashSet(); + for(Member member : members) { + if (selectedIds.contains(member.getUuid())) { + selectedMembers.add(member); + } + } + if (selectedMembers.size() > 0) { + MultiTask multiTask = new MultiTask(task, selectedMembers); + Activator.hazelcastInstance.getExecutorService().execute(multiTask); + return multiTask; + } + return null; + } + +} diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/MessageServiceImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/MessageServiceImpl.java new file mode 100644 index 0000000000..5c6e1fa70f --- /dev/null +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/MessageServiceImpl.java @@ -0,0 +1,36 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.hazelcast.service; + +import org.idempiere.distributed.IMessageService; +import org.idempiere.distributed.ITopic; + +/** + * @author hengsin + * + */ +public class MessageServiceImpl implements IMessageService { + + /** + * Default constructor + */ + public MessageServiceImpl() { + } + + @Override + public ITopic getTopic(String name) { + com.hazelcast.core.ITopic topic = Activator.hazelcastInstance.getTopic(name); + return new TopicImpl(topic); + } +} diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java new file mode 100644 index 0000000000..fa6347121b --- /dev/null +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java @@ -0,0 +1,86 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.hazelcast.service; + +import java.util.ArrayList; +import java.util.List; + +import org.idempiere.distributed.ITopic; +import org.idempiere.distributed.ITopicSubscriber; + +import com.hazelcast.core.Message; +import com.hazelcast.core.MessageListener; + +/** + * @author hengsin + * + */ +public class TopicImpl implements ITopic { + + private com.hazelcast.core.ITopic topic; + + private List> adapters; + + /** + * + */ + public TopicImpl(com.hazelcast.core.ITopic topic) { + this.topic = topic; + adapters = new ArrayList>(); + } + + @Override + public String getName() { + return topic.getName(); + } + + @Override + public void subscribe(final ITopicSubscriber subscriber) { + TopicSubscriberAdapter adapter = new TopicSubscriberAdapter(subscriber); + topic.addMessageListener(adapter); + adapters.add(adapter); + } + + @Override + public void unsubscribe(ITopicSubscriber subscriber) { + TopicSubscriberAdapter found = null; + for(TopicSubscriberAdapter adapter : adapters) { + if (adapter.subscriber == subscriber) { + found = adapter; + topic.removeMessageListener(adapter); + break; + } + } + if (found != null) + adapters.remove(found); + } + + @Override + public void publish(E message) { + topic.publish(message); + } + + class TopicSubscriberAdapter implements MessageListener { + protected ITopicSubscriber subscriber; + + protected TopicSubscriberAdapter(ITopicSubscriber subscriber) { + this.subscriber = subscriber; + } + + @Override + public void onMessage(Message message) { + subscriber.onMessage(message.getMessageObject()); + } + } +} diff --git a/org.idempiere.webservices/WEB-INF/src/org/compiere/model/MWebService.java b/org.idempiere.webservices/WEB-INF/src/org/compiere/model/MWebService.java index d4af46b820..2c40dfbc0a 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/compiere/model/MWebService.java +++ b/org.idempiere.webservices/WEB-INF/src/org/compiere/model/MWebService.java @@ -178,7 +178,7 @@ public class MWebService extends X_WS_WebService } // getMethod /** Cache */ - private static CCache s_cache = new CCache("WS_WebService", 20); + private static CCache s_cache = new CCache(Table_Name, 20); /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MWebService.class);