IDEMPIERE-4498 Performance: add cache for osgi services factory (#321)
* IDEMPIERE-4498 Performance: add cache for osgi services factory add cache for tableName -> IModelFactory * IDEMPIERE-4498 Performance: add cache for osgi services factory implement cache for the discovery of osgi services * IDEMPIERE-4498 Performance: add cache for osgi services factory added unit test
This commit is contained in:
parent
e7fda64110
commit
9162b60af7
|
@ -45,9 +45,13 @@ import org.compiere.model.PaymentInterface;
|
|||
import org.compiere.model.PaymentProcessor;
|
||||
import org.compiere.model.StandardTaxProvider;
|
||||
import org.compiere.process.ProcessCall;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.PaymentExport;
|
||||
import org.compiere.util.ReplenishInterface;
|
||||
import org.idempiere.distributed.ICacheService;
|
||||
import org.idempiere.distributed.IClusterService;
|
||||
import org.idempiere.distributed.IMessageService;
|
||||
import org.idempiere.fa.service.api.DepreciationFactoryLookupDTO;
|
||||
import org.idempiere.fa.service.api.IDepreciationMethod;
|
||||
import org.idempiere.fa.service.api.IDepreciationMethodFactory;
|
||||
|
@ -63,6 +67,8 @@ public class Core {
|
|||
|
||||
private final static CLogger s_log = CLogger.getCLogger(Core.class);
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IResourceFinder>> s_resourceFinderCache = new CCache<>(null, "IResourceFinder", 100, false);
|
||||
|
||||
/**
|
||||
* @return list of active resource finder
|
||||
*/
|
||||
|
@ -70,16 +76,33 @@ public class Core {
|
|||
return new IResourceFinder() {
|
||||
|
||||
public URL getResource(String name) {
|
||||
List<IResourceFinder> f = Service.locator().list(IResourceFinder.class).getServices();
|
||||
for (IResourceFinder finder : f) {
|
||||
URL url = finder.getResource(name);
|
||||
if (url!=null)
|
||||
return url;
|
||||
IServiceReferenceHolder<IResourceFinder> cache = s_resourceFinderCache.get(name);
|
||||
if (cache != null) {
|
||||
IResourceFinder service = cache.getService();
|
||||
if (service != null) {
|
||||
URL url = service.getResource(name);
|
||||
if (url!=null)
|
||||
return url;
|
||||
}
|
||||
s_resourceFinderCache.remove(name);
|
||||
}
|
||||
List<IServiceReferenceHolder<IResourceFinder>> f = Service.locator().list(IResourceFinder.class).getServiceReferences();
|
||||
for (IServiceReferenceHolder<IResourceFinder> finder : f) {
|
||||
IResourceFinder service = finder.getService();
|
||||
if (service != null) {
|
||||
URL url = service.getResource(name);
|
||||
if (url!=null) {
|
||||
s_resourceFinderCache.put(name, finder);
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static final CCache<String, List<IServiceReferenceHolder<IColumnCalloutFactory>>> s_columnCalloutFactoryCache = new CCache<>(null, "List<IColumnCalloutFactory>", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -89,20 +112,56 @@ public class Core {
|
|||
*/
|
||||
public static List<IColumnCallout> findCallout(String tableName, String columnName) {
|
||||
List<IColumnCallout> list = new ArrayList<IColumnCallout>();
|
||||
List<IColumnCalloutFactory> factories = Service.locator().list(IColumnCalloutFactory.class).getServices();
|
||||
|
||||
String cacheKey = tableName + "." + columnName;
|
||||
List<IServiceReferenceHolder<IColumnCalloutFactory>> cache = s_columnCalloutFactoryCache.get(cacheKey);
|
||||
if (cache != null) {
|
||||
boolean staleReference = false;
|
||||
for (IServiceReferenceHolder<IColumnCalloutFactory> factory : cache) {
|
||||
IColumnCalloutFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
IColumnCallout[] callouts = service.getColumnCallouts(tableName, columnName);
|
||||
if (callouts != null && callouts.length > 0) {
|
||||
for(IColumnCallout callout : callouts) {
|
||||
list.add(callout);
|
||||
}
|
||||
} else {
|
||||
staleReference = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
staleReference = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!staleReference)
|
||||
return list;
|
||||
else
|
||||
s_columnCalloutFactoryCache.remove(cacheKey);
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IColumnCalloutFactory>> factories = Service.locator().list(IColumnCalloutFactory.class).getServiceReferences();
|
||||
List<IServiceReferenceHolder<IColumnCalloutFactory>> found = new ArrayList<>();
|
||||
if (factories != null) {
|
||||
for(IColumnCalloutFactory factory : factories) {
|
||||
IColumnCallout[] callouts = factory.getColumnCallouts(tableName, columnName);
|
||||
if (callouts != null && callouts.length > 0) {
|
||||
for(IColumnCallout callout : callouts) {
|
||||
list.add(callout);
|
||||
for(IServiceReferenceHolder<IColumnCalloutFactory> factory : factories) {
|
||||
IColumnCalloutFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
IColumnCallout[] callouts = service.getColumnCallouts(tableName, columnName);
|
||||
if (callouts != null && callouts.length > 0) {
|
||||
for(IColumnCallout callout : callouts) {
|
||||
list.add(callout);
|
||||
}
|
||||
found.add(factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
s_columnCalloutFactoryCache.put(cacheKey, found);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<ICalloutFactory>> s_calloutFactoryCache = new CCache<>(null, "ICalloutFactory", 100, false);
|
||||
|
||||
// IDEMPIERE-2732
|
||||
/**
|
||||
*
|
||||
|
@ -111,31 +170,65 @@ public class Core {
|
|||
* @return callout for className
|
||||
*/
|
||||
public static Callout getCallout(String className, String methodName) {
|
||||
List<ICalloutFactory> factories = Service.locator().list(ICalloutFactory.class).getServices();
|
||||
if (factories != null) {
|
||||
for(ICalloutFactory factory : factories) {
|
||||
Callout callout = factory.getCallout(className, methodName);
|
||||
String cacheKey = className + "::" + methodName;
|
||||
IServiceReferenceHolder<ICalloutFactory> cache = s_calloutFactoryCache.get(cacheKey);
|
||||
if (cache != null) {
|
||||
ICalloutFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
Callout callout = service.getCallout(className, methodName);
|
||||
if (callout != null) {
|
||||
return callout;
|
||||
}
|
||||
}
|
||||
s_calloutFactoryCache.remove(cacheKey);
|
||||
}
|
||||
List<IServiceReferenceHolder<ICalloutFactory>> factories = Service.locator().list(ICalloutFactory.class).getServiceReferences();
|
||||
if (factories != null) {
|
||||
for(IServiceReferenceHolder<ICalloutFactory> factory : factories) {
|
||||
ICalloutFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
Callout callout = service.getCallout(className, methodName);
|
||||
if (callout != null) {
|
||||
s_calloutFactoryCache.put(cacheKey, factory);
|
||||
return callout;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IProcessFactory>> s_processFactoryCache = new CCache<>(null, "IProcessFactory", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param processId Java class name or equinox extension id
|
||||
* @return ProcessCall instance or null if processId not found
|
||||
*/
|
||||
public static ProcessCall getProcess(String processId) {
|
||||
List<IProcessFactory> factories = getProcessFactories();
|
||||
if (factories != null && !factories.isEmpty()) {
|
||||
for(IProcessFactory factory : factories) {
|
||||
ProcessCall process = factory.newProcessInstance(processId);
|
||||
IServiceReferenceHolder<IProcessFactory> cache = s_processFactoryCache.get(processId);
|
||||
if (cache != null) {
|
||||
IProcessFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
ProcessCall process = service.newProcessInstance(processId);
|
||||
if (process != null)
|
||||
return process;
|
||||
}
|
||||
s_processFactoryCache.remove(processId);
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IProcessFactory>> factories = getProcessFactories();
|
||||
if (factories != null && !factories.isEmpty()) {
|
||||
for(IServiceReferenceHolder<IProcessFactory> factory : factories) {
|
||||
IProcessFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
ProcessCall process = service.newProcessInstance(processId);
|
||||
if (process != null) {
|
||||
s_processFactoryCache.put(processId, factory);
|
||||
return process;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -144,18 +237,19 @@ public class Core {
|
|||
* This method load the process factories waiting until the DefaultProcessFactory on base is loaded (IDEMPIERE-3829)
|
||||
* @return List of factories implementing IProcessFactory
|
||||
*/
|
||||
private static List<IProcessFactory> getProcessFactories() {
|
||||
List<IProcessFactory> factories = null;
|
||||
private static List<IServiceReferenceHolder<IProcessFactory>> getProcessFactories() {
|
||||
List<IServiceReferenceHolder<IProcessFactory>> factories = null;
|
||||
int maxIterations = 5;
|
||||
int waitMillis = 1000;
|
||||
int iterations = 0;
|
||||
boolean foundDefault = false;
|
||||
while (true) {
|
||||
factories = Service.locator().list(IProcessFactory.class).getServices();
|
||||
factories = Service.locator().list(IProcessFactory.class).getServiceReferences();
|
||||
if (factories != null && !factories.isEmpty()) {
|
||||
for(IProcessFactory factory : factories) {
|
||||
for(IServiceReferenceHolder<IProcessFactory> factory : factories) {
|
||||
// wait until DefaultProcessFactory is loaded
|
||||
if (factory instanceof DefaultProcessFactory) {
|
||||
IProcessFactory service = factory.getService();
|
||||
if (service instanceof DefaultProcessFactory) {
|
||||
foundDefault = true;
|
||||
break;
|
||||
}
|
||||
|
@ -173,32 +267,64 @@ public class Core {
|
|||
return factories;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IModelValidatorFactory>> s_modelValidatorFactoryCache = new CCache<>(null, "IModelValidatorFactory", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param validatorId Java class name or equinox extension Id
|
||||
* @return ModelValidator instance of null if validatorId not found
|
||||
*/
|
||||
public static ModelValidator getModelValidator(String validatorId) {
|
||||
List<IModelValidatorFactory> factoryList = Service.locator().list(IModelValidatorFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IModelValidatorFactory factory : factoryList) {
|
||||
ModelValidator validator = factory.newModelValidatorInstance(validatorId);
|
||||
IServiceReferenceHolder<IModelValidatorFactory> cache = s_modelValidatorFactoryCache.get(validatorId);
|
||||
if (cache != null) {
|
||||
IModelValidatorFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
ModelValidator validator = service.newModelValidatorInstance(validatorId);
|
||||
if (validator != null)
|
||||
return validator;
|
||||
}
|
||||
s_modelValidatorFactoryCache.remove(validatorId);
|
||||
}
|
||||
List<IServiceReferenceHolder<IModelValidatorFactory>> factoryList = Service.locator().list(IModelValidatorFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(IServiceReferenceHolder<IModelValidatorFactory> factory : factoryList) {
|
||||
IModelValidatorFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
ModelValidator validator = service.newModelValidatorInstance(validatorId);
|
||||
if (validator != null) {
|
||||
s_modelValidatorFactoryCache.put(validatorId, factory);
|
||||
return validator;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<IKeyStore> s_keystoreServiceReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return keystore
|
||||
* @return {@link IKeyStore}
|
||||
*/
|
||||
public static IKeyStore getKeyStore(){
|
||||
return Service.locator().locate(IKeyStore.class).getService();
|
||||
IKeyStore keystoreService = null;
|
||||
if (s_keystoreServiceReference != null) {
|
||||
keystoreService = s_keystoreServiceReference.getService();
|
||||
if (keystoreService != null)
|
||||
return keystoreService;
|
||||
}
|
||||
IServiceReferenceHolder<IKeyStore> serviceReference = Service.locator().locate(IKeyStore.class).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
keystoreService = serviceReference.getService();
|
||||
s_keystoreServiceReference = serviceReference;
|
||||
}
|
||||
return keystoreService;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IPaymentProcessorFactory>> s_paymentProcessorFactoryCache = new CCache<>(null, "IPaymentProcessorFactory", 100, false);
|
||||
|
||||
/**
|
||||
* Get payment processor instance
|
||||
* @param mbap payment processor model
|
||||
|
@ -216,14 +342,31 @@ public class Core {
|
|||
}
|
||||
//
|
||||
PaymentProcessor myProcessor = null;
|
||||
|
||||
List<IPaymentProcessorFactory> factoryList = Service.locator().list(IPaymentProcessorFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IPaymentProcessorFactory factory : factoryList) {
|
||||
PaymentProcessor processor = factory.newPaymentProcessorInstance(className);
|
||||
if (processor != null) {
|
||||
IServiceReferenceHolder<IPaymentProcessorFactory> cache = s_paymentProcessorFactoryCache.get(className);
|
||||
if (cache != null) {
|
||||
IPaymentProcessorFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
PaymentProcessor processor = service.newPaymentProcessorInstance(className);
|
||||
if (processor != null)
|
||||
myProcessor = processor;
|
||||
break;
|
||||
}
|
||||
if (myProcessor == null)
|
||||
s_paymentProcessorFactoryCache.remove(className);
|
||||
}
|
||||
|
||||
if (myProcessor == null) {
|
||||
List<IServiceReferenceHolder<IPaymentProcessorFactory>> factoryList = Service.locator().list(IPaymentProcessorFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(IServiceReferenceHolder<IPaymentProcessorFactory> factory : factoryList) {
|
||||
IPaymentProcessorFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
PaymentProcessor processor = service.newPaymentProcessorInstance(className);
|
||||
if (processor != null) {
|
||||
myProcessor = processor;
|
||||
s_paymentProcessorFactoryCache.put(className, factory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +382,8 @@ public class Core {
|
|||
return myProcessor;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IBankStatementLoaderFactory>> s_bankStatementLoaderFactoryCache = new CCache<>(null, "IBankStatementLoaderFactory", 100, false);
|
||||
|
||||
/**
|
||||
* get BankStatementLoader instance
|
||||
*
|
||||
|
@ -252,15 +397,30 @@ public class Core {
|
|||
}
|
||||
|
||||
BankStatementLoaderInterface myBankStatementLoader = null;
|
||||
|
||||
List<IBankStatementLoaderFactory> factoryList =
|
||||
Service.locator().list(IBankStatementLoaderFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IBankStatementLoaderFactory factory : factoryList) {
|
||||
BankStatementLoaderInterface loader = factory.newBankStatementLoaderInstance(className);
|
||||
if (loader != null) {
|
||||
IServiceReferenceHolder<IBankStatementLoaderFactory> cache = s_bankStatementLoaderFactoryCache.get(className);
|
||||
if (cache != null) {
|
||||
IBankStatementLoaderFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
BankStatementLoaderInterface loader = service.newBankStatementLoaderInstance(className);
|
||||
if (loader != null)
|
||||
myBankStatementLoader = loader;
|
||||
break;
|
||||
}
|
||||
if (myBankStatementLoader == null)
|
||||
s_bankStatementLoaderFactoryCache.remove(className);
|
||||
}
|
||||
if (myBankStatementLoader == null) {
|
||||
List<IServiceReferenceHolder<IBankStatementLoaderFactory>> factoryList = Service.locator().list(IBankStatementLoaderFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(IServiceReferenceHolder<IBankStatementLoaderFactory> factory : factoryList) {
|
||||
IBankStatementLoaderFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
BankStatementLoaderInterface loader = service.newBankStatementLoaderInstance(className);
|
||||
if (loader != null) {
|
||||
myBankStatementLoader = loader;
|
||||
s_bankStatementLoaderFactoryCache.put(className, factory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,6 +433,8 @@ public class Core {
|
|||
return myBankStatementLoader;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IBankStatementMatcherFactory>> s_bankStatementMatcherFactoryCache = new CCache<>(null, "IBankStatementMatcherFactory", 100, false);
|
||||
|
||||
/**
|
||||
* get BankStatementMatcher instance
|
||||
*
|
||||
|
@ -286,15 +448,30 @@ public class Core {
|
|||
}
|
||||
|
||||
BankStatementMatcherInterface myBankStatementMatcher = null;
|
||||
|
||||
List<IBankStatementMatcherFactory> factoryList =
|
||||
Service.locator().list(IBankStatementMatcherFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IBankStatementMatcherFactory factory : factoryList) {
|
||||
BankStatementMatcherInterface matcher = factory.newBankStatementMatcherInstance(className);
|
||||
if (matcher != null) {
|
||||
IServiceReferenceHolder<IBankStatementMatcherFactory> cache = s_bankStatementMatcherFactoryCache.get(className);
|
||||
if (cache != null) {
|
||||
IBankStatementMatcherFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
BankStatementMatcherInterface matcher = service.newBankStatementMatcherInstance(className);
|
||||
if (matcher != null)
|
||||
myBankStatementMatcher = matcher;
|
||||
break;
|
||||
}
|
||||
if (myBankStatementMatcher == null)
|
||||
s_bankStatementMatcherFactoryCache.remove(className);
|
||||
}
|
||||
if (myBankStatementMatcher == null) {
|
||||
List<IServiceReferenceHolder<IBankStatementMatcherFactory>> factoryList = Service.locator().list(IBankStatementMatcherFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(IServiceReferenceHolder<IBankStatementMatcherFactory> factory : factoryList) {
|
||||
IBankStatementMatcherFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
BankStatementMatcherInterface matcher = service.newBankStatementMatcherInstance(className);
|
||||
if (matcher != null) {
|
||||
myBankStatementMatcher = matcher;
|
||||
s_bankStatementMatcherFactoryCache.put(className, factory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -307,6 +484,8 @@ public class Core {
|
|||
return myBankStatementMatcher;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IShipmentProcessorFactory>> s_shipmentProcessorFactoryCache = new CCache<>(null, "IShipmentProcessorFactory", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sf
|
||||
|
@ -322,20 +501,37 @@ public class Core {
|
|||
s_log.log(Level.SEVERE, "Shipment processor or class not defined for shipper " + sf);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<IShipmentProcessorFactory> factoryList = Service.locator().list(IShipmentProcessorFactory.class).getServices();
|
||||
|
||||
IServiceReferenceHolder<IShipmentProcessorFactory> cache = s_shipmentProcessorFactoryCache.get(className);
|
||||
if (cache != null) {
|
||||
IShipmentProcessorFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
IShipmentProcessor processor = service.newShipmentProcessorInstance(className);
|
||||
if (processor != null)
|
||||
return processor;
|
||||
}
|
||||
s_shipmentProcessorFactoryCache.remove(className);
|
||||
}
|
||||
List<IServiceReferenceHolder<IShipmentProcessorFactory>> factoryList = Service.locator().list(IShipmentProcessorFactory.class).getServiceReferences();
|
||||
if (factoryList == null)
|
||||
return null;
|
||||
for (IShipmentProcessorFactory factory : factoryList)
|
||||
for (IServiceReferenceHolder<IShipmentProcessorFactory> factory : factoryList)
|
||||
{
|
||||
IShipmentProcessor processor = factory.newShipmentProcessorInstance(className);
|
||||
if (processor != null)
|
||||
return processor;
|
||||
IShipmentProcessorFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
IShipmentProcessor processor = service.newShipmentProcessorInstance(className);
|
||||
if (processor != null) {
|
||||
s_shipmentProcessorFactoryCache.put(className, factory);
|
||||
return processor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IAddressValidationFactory>> s_addressValidationFactoryCache = new CCache<>(null, "IAddressValidationFactory", 100, false);
|
||||
|
||||
/**
|
||||
* Get address validation instance
|
||||
* @param validation
|
||||
|
@ -350,19 +546,36 @@ public class Core {
|
|||
return null;
|
||||
}
|
||||
|
||||
List<IAddressValidationFactory> factoryList = Service.locator().list(IAddressValidationFactory.class).getServices();
|
||||
IServiceReferenceHolder<IAddressValidationFactory> cache = s_addressValidationFactoryCache.get(className);
|
||||
if (cache != null) {
|
||||
IAddressValidationFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
IAddressValidation processor = service.newAddressValidationInstance(className);
|
||||
if (processor != null)
|
||||
return processor;
|
||||
}
|
||||
s_addressValidationFactoryCache.remove(className);
|
||||
}
|
||||
List<IServiceReferenceHolder<IAddressValidationFactory>> factoryList = Service.locator().list(IAddressValidationFactory.class).getServiceReferences();
|
||||
if (factoryList == null)
|
||||
return null;
|
||||
for (IAddressValidationFactory factory : factoryList)
|
||||
for (IServiceReferenceHolder<IAddressValidationFactory> factory : factoryList)
|
||||
{
|
||||
IAddressValidation processor = factory.newAddressValidationInstance(className);
|
||||
if (processor != null)
|
||||
return processor;
|
||||
IAddressValidationFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
IAddressValidation processor = service.newAddressValidationInstance(className);
|
||||
if (processor != null) {
|
||||
s_addressValidationFactoryCache.put(className, factory);
|
||||
return processor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<ITaxProviderFactory>> s_taxProviderFactoryCache = new CCache<>(null, "ITaxProviderFactory", 100, false);
|
||||
|
||||
/**
|
||||
* Get tax provider instance
|
||||
* @param provider
|
||||
|
@ -388,43 +601,75 @@ public class Core {
|
|||
s_log.log(Level.SEVERE, "Tax provider class not defined: " + provider);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ITaxProviderFactory> factoryList = Service.locator().list(ITaxProviderFactory.class).getServices();
|
||||
|
||||
IServiceReferenceHolder<ITaxProviderFactory> cache = s_taxProviderFactoryCache.get(className);
|
||||
if (cache != null) {
|
||||
ITaxProviderFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
calculator = service.newTaxProviderInstance(className);
|
||||
if (calculator != null)
|
||||
return calculator;
|
||||
}
|
||||
s_taxProviderFactoryCache.remove(className);
|
||||
}
|
||||
List<IServiceReferenceHolder<ITaxProviderFactory>> factoryList = Service.locator().list(ITaxProviderFactory.class).getServiceReferences();
|
||||
if (factoryList == null)
|
||||
return null;
|
||||
for (ITaxProviderFactory factory : factoryList)
|
||||
for (IServiceReferenceHolder<ITaxProviderFactory> factory : factoryList)
|
||||
{
|
||||
calculator = factory.newTaxProviderInstance(className);
|
||||
if (calculator != null)
|
||||
return calculator;
|
||||
ITaxProviderFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
calculator = service.newTaxProviderInstance(className);
|
||||
if (calculator != null) {
|
||||
s_taxProviderFactoryCache.put(className, factory);
|
||||
return calculator;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IReplenishFactory>> s_replenishFactoryCache = new CCache<>(null, "IReplenishFactory", 100, false);
|
||||
|
||||
/**
|
||||
* get Custom Replenish instance
|
||||
*
|
||||
* @param className
|
||||
* @return instance of the ReplenishInterface or null
|
||||
*/
|
||||
public static ReplenishInterface getReplenish(String className){
|
||||
public static ReplenishInterface getReplenish(String className) {
|
||||
if (className == null || className.length() == 0) {
|
||||
s_log.log(Level.SEVERE, "No ReplenishInterface class name");
|
||||
return null;
|
||||
}
|
||||
|
||||
ReplenishInterface myReplenishInstance = null;
|
||||
|
||||
List<IReplenishFactory> factoryList =
|
||||
Service.locator().list(IReplenishFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IReplenishFactory factory : factoryList) {
|
||||
ReplenishInterface loader = factory.newReplenishInstance(className);
|
||||
if (loader != null) {
|
||||
IServiceReferenceHolder<IReplenishFactory> cache = s_replenishFactoryCache.get(className);
|
||||
if (cache != null) {
|
||||
IReplenishFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
ReplenishInterface loader = service.newReplenishInstance(className);
|
||||
if (loader != null)
|
||||
myReplenishInstance = loader;
|
||||
break;
|
||||
}
|
||||
if (myReplenishInstance == null)
|
||||
s_replenishFactoryCache.remove(className);
|
||||
}
|
||||
if (myReplenishInstance == null) {
|
||||
List<IServiceReferenceHolder<IReplenishFactory>> factoryList = Service.locator().list(IReplenishFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(IServiceReferenceHolder<IReplenishFactory> factory : factoryList) {
|
||||
IReplenishFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
ReplenishInterface loader = service.newReplenishInstance(className);
|
||||
if (loader != null) {
|
||||
myReplenishInstance = loader;
|
||||
s_replenishFactoryCache.put(className, factory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +682,8 @@ public class Core {
|
|||
return myReplenishInstance;
|
||||
}
|
||||
|
||||
|
||||
private final static CCache<String, IServiceReferenceHolder<ScriptEngineFactory>> s_scriptEngineFactoryCache = new CCache<>(null, "ScriptEngineFactory", 100, false);
|
||||
|
||||
/** Get script engine
|
||||
*
|
||||
* @param engineName
|
||||
|
@ -450,13 +696,23 @@ public class Core {
|
|||
if (engine != null)
|
||||
return engine;
|
||||
|
||||
List<ScriptEngineFactory> factoryList =
|
||||
Service.locator().list(ScriptEngineFactory.class).getServices();
|
||||
IServiceReferenceHolder<ScriptEngineFactory> cache = s_scriptEngineFactoryCache.get(engineName);
|
||||
if (cache != null) {
|
||||
ScriptEngineFactory service = cache.getService();
|
||||
if (service != null)
|
||||
return service.getScriptEngine();
|
||||
s_scriptEngineFactoryCache.remove(engineName);
|
||||
}
|
||||
List<IServiceReferenceHolder<ScriptEngineFactory>> factoryList = Service.locator().list(ScriptEngineFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(ScriptEngineFactory factory : factoryList) {
|
||||
for (String name : factory.getNames()) {
|
||||
if (engineName.equals(name)) {
|
||||
return factory.getScriptEngine();
|
||||
for(IServiceReferenceHolder<ScriptEngineFactory> factory : factoryList) {
|
||||
ScriptEngineFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
for (String name : service.getNames()) {
|
||||
if (engineName.equals(name)) {
|
||||
s_scriptEngineFactoryCache.put(engineName, factory);
|
||||
return service.getScriptEngine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,6 +721,8 @@ public class Core {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IPaymentExporterFactory>> s_paymentExporterFactory = new CCache<>(null, "IPaymentExporterFactory", 100, false);
|
||||
|
||||
/**
|
||||
* get PaymentExporter instance
|
||||
*
|
||||
|
@ -478,15 +736,30 @@ public class Core {
|
|||
}
|
||||
|
||||
PaymentExport myPaymentExporter = null;
|
||||
|
||||
List<IPaymentExporterFactory> factoryList =
|
||||
Service.locator().list(IPaymentExporterFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IPaymentExporterFactory factory : factoryList) {
|
||||
PaymentExport exporter = factory.newPaymentExporterInstance(className);
|
||||
if (exporter != null) {
|
||||
IServiceReferenceHolder<IPaymentExporterFactory> cache = s_paymentExporterFactory.get(className);
|
||||
if (cache != null) {
|
||||
IPaymentExporterFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
PaymentExport exporter = service.newPaymentExporterInstance(className);
|
||||
if (exporter != null)
|
||||
myPaymentExporter = exporter;
|
||||
break;
|
||||
}
|
||||
if (myPaymentExporter == null)
|
||||
s_paymentExporterFactory.remove(className);
|
||||
}
|
||||
if (myPaymentExporter == null) {
|
||||
List<IServiceReferenceHolder<IPaymentExporterFactory>> factoryList = Service.locator().list(IPaymentExporterFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(IServiceReferenceHolder<IPaymentExporterFactory> factory : factoryList) {
|
||||
IPaymentExporterFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
PaymentExport exporter = service.newPaymentExporterInstance(className);
|
||||
if (exporter != null) {
|
||||
myPaymentExporter = exporter;
|
||||
s_paymentExporterFactory.put(className, factory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -499,19 +772,30 @@ public class Core {
|
|||
return myPaymentExporter;
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<IProductPricingFactory> s_productPricingFactoryCache = null;
|
||||
|
||||
/**
|
||||
* get ProductPricing instance
|
||||
*
|
||||
* @return instance of the IProductPricing or null
|
||||
*/
|
||||
public static IProductPricing getProductPricing() {
|
||||
|
||||
List<IProductPricingFactory> factoryList =
|
||||
Service.locator().list(IProductPricingFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IProductPricingFactory factory : factoryList) {
|
||||
IProductPricing myProductPricing = factory.newProductPricingInstance();
|
||||
public static synchronized IProductPricing getProductPricing() {
|
||||
if (s_productPricingFactoryCache != null) {
|
||||
IProductPricingFactory service = s_productPricingFactoryCache.getService();
|
||||
if (service != null) {
|
||||
IProductPricing myProductPricing = service.newProductPricingInstance();
|
||||
if (myProductPricing != null)
|
||||
return myProductPricing;
|
||||
}
|
||||
s_productPricingFactoryCache = null;
|
||||
}
|
||||
IServiceReferenceHolder<IProductPricingFactory> factoryReference = Service.locator().locate(IProductPricingFactory.class).getServiceReference();
|
||||
if (factoryReference != null) {
|
||||
IProductPricingFactory service = factoryReference.getService();
|
||||
if (service != null) {
|
||||
IProductPricing myProductPricing = service.newProductPricingInstance();
|
||||
if (myProductPricing != null) {
|
||||
s_productPricingFactoryCache = factoryReference;
|
||||
return myProductPricing;
|
||||
}
|
||||
}
|
||||
|
@ -520,20 +804,35 @@ public class Core {
|
|||
return null;
|
||||
}
|
||||
|
||||
private final static CCache<String, IServiceReferenceHolder<IDepreciationMethodFactory>> s_depreciationMethodFactoryCache = new CCache<>(null, "IDepreciationMethodFactory", 100, false);
|
||||
|
||||
/**
|
||||
* lookup implement {@link IDepreciationMethod}
|
||||
* @param factoryLookupDTO
|
||||
* @return
|
||||
* @return {@link IDepreciationMethod}
|
||||
*/
|
||||
public static IDepreciationMethod getDepreciationMethod(DepreciationFactoryLookupDTO factoryLookupDTO) {
|
||||
|
||||
List<IDepreciationMethodFactory> factoryList =
|
||||
Service.locator().list(IDepreciationMethodFactory.class).getServices();
|
||||
if (factoryList != null) {
|
||||
for(IDepreciationMethodFactory factory : factoryList) {
|
||||
IDepreciationMethod depreciationMethod = factory.getDepreciationMethod(factoryLookupDTO);
|
||||
if (depreciationMethod != null) {
|
||||
String cacheKey = factoryLookupDTO.depreciationType;
|
||||
IServiceReferenceHolder<IDepreciationMethodFactory> cache = s_depreciationMethodFactoryCache.get(cacheKey);
|
||||
if (cache != null) {
|
||||
IDepreciationMethodFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
IDepreciationMethod depreciationMethod = service.getDepreciationMethod(factoryLookupDTO);
|
||||
if (depreciationMethod != null)
|
||||
return depreciationMethod;
|
||||
}
|
||||
s_depreciationMethodFactoryCache.remove(cacheKey);
|
||||
}
|
||||
List<IServiceReferenceHolder<IDepreciationMethodFactory>> factoryList = Service.locator().list(IDepreciationMethodFactory.class).getServiceReferences();
|
||||
if (factoryList != null) {
|
||||
for(IServiceReferenceHolder<IDepreciationMethodFactory> factory : factoryList) {
|
||||
IDepreciationMethodFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
IDepreciationMethod depreciationMethod = service.getDepreciationMethod(factoryLookupDTO);
|
||||
if (depreciationMethod != null) {
|
||||
s_depreciationMethodFactoryCache.put(cacheKey, factory);
|
||||
return depreciationMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -541,4 +840,88 @@ public class Core {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<IMessageService> s_messageServiceReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link IMessageService}
|
||||
*/
|
||||
public static synchronized IMessageService getMessageService() {
|
||||
IMessageService messageService = null;
|
||||
if (s_messageServiceReference != null) {
|
||||
messageService = s_messageServiceReference.getService();
|
||||
if (messageService != null)
|
||||
return messageService;
|
||||
}
|
||||
IServiceReferenceHolder<IMessageService> serviceReference = Service.locator().locate(IMessageService.class).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
messageService = serviceReference.getService();
|
||||
s_messageServiceReference = serviceReference;
|
||||
}
|
||||
return messageService;
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<IClusterService> s_clusterServiceReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link IClusterService}
|
||||
*/
|
||||
public static synchronized IClusterService getClusterService() {
|
||||
IClusterService clusterService = null;
|
||||
if (s_clusterServiceReference != null) {
|
||||
clusterService = s_clusterServiceReference.getService();
|
||||
if (clusterService != null)
|
||||
return clusterService;
|
||||
}
|
||||
IServiceReferenceHolder<IClusterService> serviceReference = Service.locator().locate(IClusterService.class).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
clusterService = serviceReference.getService();
|
||||
s_clusterServiceReference = serviceReference;
|
||||
}
|
||||
return clusterService;
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<ICacheService> s_cacheServiceReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link ICacheService}
|
||||
*/
|
||||
public static synchronized ICacheService getCacheService() {
|
||||
ICacheService cacheService = null;
|
||||
if (s_cacheServiceReference != null) {
|
||||
cacheService = s_cacheServiceReference.getService();
|
||||
if (cacheService != null)
|
||||
return cacheService;
|
||||
}
|
||||
IServiceReferenceHolder<ICacheService> serviceReference = Service.locator().locate(ICacheService.class).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
cacheService = serviceReference.getService();
|
||||
s_cacheServiceReference = serviceReference;
|
||||
}
|
||||
return cacheService;
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<IDictionaryService> s_dictionaryServiceReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link IDictionaryService}
|
||||
*/
|
||||
public static synchronized IDictionaryService getDictionaryService() {
|
||||
IDictionaryService ids = null;
|
||||
if (s_dictionaryServiceReference != null) {
|
||||
ids = s_dictionaryServiceReference.getService();
|
||||
if (ids != null)
|
||||
return ids;
|
||||
}
|
||||
IServiceReferenceHolder<IDictionaryService> serviceReference = Service.locator().locate(IDictionaryService.class).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
ids = serviceReference.getService();
|
||||
s_dictionaryServiceReference = serviceReference;
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.compiere.util.Util;
|
|||
*/
|
||||
public class DefaultModelFactory implements IModelFactory {
|
||||
|
||||
private static CCache<String,Class<?>> s_classCache = new CCache<String,Class<?>>(null, "PO_Class", 20, false);
|
||||
private static CCache<String,Class<?>> s_classCache = new CCache<String,Class<?>>(null, "PO_Class", 100, 120, false, 2000);
|
||||
private final static CLogger s_log = CLogger.getCLogger(DefaultModelFactory.class);
|
||||
|
||||
/** Packages for Model Classes */
|
||||
|
|
|
@ -22,9 +22,14 @@ package org.adempiere.base;
|
|||
public interface IServiceHolder<T> {
|
||||
|
||||
/**
|
||||
*
|
||||
* Get service with highest service.ranking value
|
||||
* @return service instance. null if not available or no matching service found
|
||||
*/
|
||||
public T getService();
|
||||
|
||||
/**
|
||||
* Get service reference for service with highest service.ranking value
|
||||
* @return {@link IServiceReferenceHolder}
|
||||
*/
|
||||
public IServiceReferenceHolder<T> getServiceReference();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.adempiere.base;
|
||||
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
/**
|
||||
* Dynamic service reference holder for a service object.
|
||||
* For cache usage, you should cache this instead of service object
|
||||
* @author hengsin
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface IServiceReferenceHolder<T> {
|
||||
|
||||
/**
|
||||
* Get service object from cache service reference
|
||||
* @return Service Object or null if the osgi service is no longer available
|
||||
*/
|
||||
public T getService();
|
||||
|
||||
/**
|
||||
* Get the cache service reference
|
||||
* @return ServiceReference
|
||||
*/
|
||||
public ServiceReference<T> getServiceReference();
|
||||
}
|
|
@ -24,9 +24,15 @@ import java.util.List;
|
|||
public interface IServicesHolder<T> {
|
||||
|
||||
/**
|
||||
*
|
||||
* Get list of service, sorted by service.ranking (from highest to lowest ranking)
|
||||
* @return list of service instance. null if not available or no matching service found
|
||||
*/
|
||||
public List<T> getServices();
|
||||
|
||||
/**
|
||||
* Get list of service reference, sorted by service.ranking (from highest to lowest ranking).
|
||||
* If you want to cache service, cache IServiceReferenceHolder instead of the actual service object
|
||||
* @return list of {@link IServiceReferenceHolder}
|
||||
*/
|
||||
public List<IServiceReferenceHolder<T>> getServiceReferences();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.adempiere.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.compiere.model.GridFieldVO;
|
||||
import org.compiere.model.Lookup;
|
||||
import org.compiere.util.CCache;
|
||||
import org.osgi.framework.Constants;
|
||||
|
||||
/**
|
||||
* Static helper methods for working with {@link ILookupFactory}
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public final class LookupFactoryHelper {
|
||||
|
||||
private LookupFactoryHelper() {
|
||||
}
|
||||
|
||||
private static final CCache<Long, IServiceReferenceHolder<ILookupFactory>> s_lookupFactoryCache = new CCache<Long, IServiceReferenceHolder<ILookupFactory>>(
|
||||
null, "ILookupFactory", 10, false);
|
||||
|
||||
/**
|
||||
* Get lookup from osgi factory
|
||||
*
|
||||
* @param gridFieldVO
|
||||
* @return {@link Lookup}
|
||||
*/
|
||||
public static Lookup getLookup(GridFieldVO gridFieldVO) {
|
||||
List<Long> visitedIds = new ArrayList<Long>();
|
||||
if (!s_lookupFactoryCache.isEmpty()) {
|
||||
Long[] keys = s_lookupFactoryCache.keySet().toArray(new Long[0]);
|
||||
for (Long key : keys) {
|
||||
IServiceReferenceHolder<ILookupFactory> serviceReference = s_lookupFactoryCache.get(key);
|
||||
if (serviceReference != null) {
|
||||
ILookupFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
visitedIds.add(key);
|
||||
Lookup lookup = service.getLookup(gridFieldVO);
|
||||
if (lookup != null)
|
||||
return lookup;
|
||||
} else {
|
||||
s_lookupFactoryCache.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IServiceReferenceHolder<ILookupFactory>> serviceReferences = Service.locator().list(ILookupFactory.class)
|
||||
.getServiceReferences();
|
||||
for (IServiceReferenceHolder<ILookupFactory> serviceReference : serviceReferences) {
|
||||
Long serviceId = (Long) serviceReference.getServiceReference().getProperty(Constants.SERVICE_ID);
|
||||
if (visitedIds.contains(serviceId))
|
||||
continue;
|
||||
ILookupFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
s_lookupFactoryCache.put(serviceId, serviceReference);
|
||||
Lookup lookup = service.getLookup(gridFieldVO);
|
||||
if (lookup != null)
|
||||
return lookup;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check lookup from osgi factory
|
||||
*
|
||||
* @param gridFieldVO
|
||||
* @return true if gridFieldVO is a lookup field
|
||||
*/
|
||||
public static boolean isLookup(GridFieldVO gridFieldVO) {
|
||||
List<Long> visitedIds = new ArrayList<Long>();
|
||||
if (!s_lookupFactoryCache.isEmpty()) {
|
||||
Long[] keys = s_lookupFactoryCache.keySet().toArray(new Long[0]);
|
||||
for (Long key : keys) {
|
||||
IServiceReferenceHolder<ILookupFactory> serviceReference = s_lookupFactoryCache.get(key);
|
||||
if (serviceReference != null) {
|
||||
ILookupFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
visitedIds.add(key);
|
||||
if (service.isLookup(gridFieldVO))
|
||||
return true;
|
||||
} else {
|
||||
s_lookupFactoryCache.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IServiceReferenceHolder<ILookupFactory>> serviceReferences = Service.locator().list(ILookupFactory.class)
|
||||
.getServiceReferences();
|
||||
for (IServiceReferenceHolder<ILookupFactory> serviceReference : serviceReferences) {
|
||||
Long serviceId = (Long) serviceReference.getServiceReference().getProperty(Constants.SERVICE_ID);
|
||||
if (visitedIds.contains(serviceId))
|
||||
continue;
|
||||
ILookupFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
s_lookupFactoryCache.put(serviceId, serviceReference);
|
||||
if (service.isLookup(gridFieldVO))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.IServicesHolder;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
|
@ -54,10 +55,36 @@ public class DynamicServiceHolder<T> implements IServiceHolder<T>, IServicesHold
|
|||
if (objects != null && objects.length > 0) {
|
||||
references = Arrays.asList(objects);
|
||||
}
|
||||
Collections.sort(references, Collections.reverseOrder());
|
||||
if (references.size() > 1)
|
||||
Collections.sort(references, ServiceRankingComparator.INSTANCE);
|
||||
for(ServiceReference<T> reference : references) {
|
||||
services.add(serviceTracker.getService(reference));
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IServiceReferenceHolder<T> getServiceReference() {
|
||||
ServiceReference<T> v = serviceTracker.getServiceReference();
|
||||
if (v != null)
|
||||
return new DynamicServiceReference<T>(serviceTracker, v);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IServiceReferenceHolder<T>> getServiceReferences() {
|
||||
List<IServiceReferenceHolder<T>> services = new ArrayList<>();
|
||||
ServiceReference<T>[] objects = serviceTracker.getServiceReferences();
|
||||
List<ServiceReference<T>> references = new ArrayList<ServiceReference<T>>();
|
||||
if (objects != null && objects.length > 0) {
|
||||
references = Arrays.asList(objects);
|
||||
}
|
||||
if (references.size() > 1)
|
||||
Collections.sort(references, ServiceRankingComparator.INSTANCE);
|
||||
for(ServiceReference<T> reference : references) {
|
||||
services.add(new DynamicServiceReference<T>(serviceTracker, reference));
|
||||
}
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.adempiere.base.ds;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
|
||||
/**
|
||||
* IServiceReferenceHolder implementation using ServiceTracker
|
||||
* @author hengsin
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class DynamicServiceReference<T> implements IServiceReferenceHolder<T> {
|
||||
|
||||
private ServiceTracker<T, T> serviceTracker;
|
||||
private ServiceReference<T> serviceReference;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tracker
|
||||
* @param serviceReference
|
||||
*/
|
||||
public DynamicServiceReference(ServiceTracker<T, T> tracker, ServiceReference<T> serviceReference) {
|
||||
this.serviceTracker = tracker;
|
||||
this.serviceReference = serviceReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getService() {
|
||||
return serviceTracker.getService(serviceReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceReference<T> getServiceReference() {
|
||||
return serviceReference;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.adempiere.base.ds;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.osgi.framework.Constants;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
/**
|
||||
* Service Reference Comparator.
|
||||
* This comparator follows OSGi Ranking policy.
|
||||
* @author hengsin
|
||||
*/
|
||||
public final class ServiceRankingComparator implements Comparator<ServiceReference<?>>, Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3444598255961708618L;
|
||||
|
||||
/**
|
||||
* share service ranking comparator instance
|
||||
*/
|
||||
public static final ServiceRankingComparator INSTANCE = new ServiceRankingComparator();
|
||||
|
||||
private ServiceRankingComparator() {}
|
||||
|
||||
/**
|
||||
* Compares two service reference.
|
||||
* @param serviceReference1 service reference 1
|
||||
* @param serviceReference2 service reference 2
|
||||
* @return <code>-1</code> if service reference 1 service.ranking value
|
||||
* is higher than service reference 2, <code>1</code> otherwise.
|
||||
* (i.e for sorting in descending order of service.ranking value)
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public int compare(ServiceReference<?> serviceReference1, ServiceReference<?> serviceReference2) {
|
||||
if (serviceReference1.equals(serviceReference2)) { return 0; }
|
||||
|
||||
if (serviceReference2 != null) {
|
||||
Object serviceRankingP1 = serviceReference1.getProperty(Constants.SERVICE_RANKING);
|
||||
Object serviceRankingP2 = serviceReference2.getProperty(Constants.SERVICE_RANKING);
|
||||
|
||||
int serviceRanking1 = 0;
|
||||
int serviceRanking2 = 0;
|
||||
if (serviceRankingP1 instanceof Integer) {
|
||||
serviceRanking1 = (Integer) serviceRankingP1;
|
||||
}
|
||||
if (serviceRankingP2 instanceof Integer) {
|
||||
serviceRanking2 = (Integer) serviceRankingP2;
|
||||
}
|
||||
|
||||
if (serviceRanking1 == serviceRanking2) {
|
||||
// Check service.id
|
||||
Object serviceIdP1 = serviceReference1.getProperty(Constants.SERVICE_ID);
|
||||
Object serviceIdP2 = serviceReference2.getProperty(Constants.SERVICE_ID);
|
||||
|
||||
long serviceId1 = (Long) serviceIdP1;
|
||||
long serviceId2 = (Long) serviceIdP2;
|
||||
|
||||
if (serviceId1 == serviceId2) {
|
||||
return 0;
|
||||
} else if (serviceId1 > serviceId2) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else if (serviceRanking1 > serviceRanking2) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.adempiere.process;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.compiere.model.MAttachment;
|
||||
import org.compiere.model.MPackage;
|
||||
|
@ -27,7 +28,7 @@ public class PrintShippingLabel extends SvrProcess
|
|||
if (labelId <= 0)
|
||||
return "Label format not defined.";
|
||||
|
||||
IPrintShippingLabel service = Service.locator().locate(IPrintShippingLabel.class).getService();
|
||||
IPrintShippingLabel service = getService();
|
||||
if (service != null)
|
||||
{
|
||||
MShipperLabels label = new MShipperLabels(getCtx(), labelId, get_TrxName());
|
||||
|
@ -39,4 +40,24 @@ public class PrintShippingLabel extends SvrProcess
|
|||
else
|
||||
return "Not found in service/extension registry and classpath";
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<IPrintShippingLabel> s_serviceReference = null;
|
||||
|
||||
private synchronized static IPrintShippingLabel getService() {
|
||||
if (s_serviceReference != null) {
|
||||
IPrintShippingLabel service = s_serviceReference.getService();
|
||||
if (service != null)
|
||||
return service;
|
||||
}
|
||||
IServiceReferenceHolder<IPrintShippingLabel> serviceReference = Service.locator().locate(IPrintShippingLabel.class).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
IPrintShippingLabel service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
s_serviceReference = serviceReference;
|
||||
return service;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IDocFactory;
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.ServiceQuery;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
|
@ -31,6 +32,7 @@ import org.adempiere.exceptions.DBException;
|
|||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -108,6 +110,8 @@ public class DocManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IDocFactory>> s_DocFactoryCache = new CCache<>(null, "IDocFactory", 100, false);
|
||||
|
||||
/**
|
||||
* Create Posting document
|
||||
* @param as accounting schema
|
||||
|
@ -133,29 +137,57 @@ public class DocManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("gaap", as.getGAAP());
|
||||
List<IDocFactory> factoryList = Service.locator().list(IDocFactory.class, query).getServices();
|
||||
if (factoryList != null)
|
||||
String cacheKey = as.getC_AcctSchema_ID() + "|" + AD_Table_ID;
|
||||
IServiceReferenceHolder<IDocFactory> cache = s_DocFactoryCache.get(cacheKey);
|
||||
if (cache != null)
|
||||
{
|
||||
for(IDocFactory factory : factoryList)
|
||||
IDocFactory service = cache.getService();
|
||||
if (service != null)
|
||||
{
|
||||
Doc doc = factory.getDocument(as, AD_Table_ID, Record_ID, trxName);
|
||||
Doc doc = service.getDocument(as, AD_Table_ID, Record_ID, trxName);
|
||||
if (doc != null)
|
||||
return doc;
|
||||
}
|
||||
s_DocFactoryCache.remove(cacheKey);
|
||||
}
|
||||
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("gaap", as.getGAAP());
|
||||
List<IServiceReferenceHolder<IDocFactory>> factoryList = Service.locator().list(IDocFactory.class, query).getServiceReferences();
|
||||
if (factoryList != null)
|
||||
{
|
||||
for(IServiceReferenceHolder<IDocFactory> factory : factoryList)
|
||||
{
|
||||
IDocFactory service = factory.getService();
|
||||
if (service != null)
|
||||
{
|
||||
Doc doc = service.getDocument(as, AD_Table_ID, Record_ID, trxName);
|
||||
if (doc != null)
|
||||
{
|
||||
s_DocFactoryCache.put(cacheKey, factory);
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query.clear();
|
||||
query.put("gaap", "*");
|
||||
factoryList = Service.locator().list(IDocFactory.class, query).getServices();
|
||||
factoryList = Service.locator().list(IDocFactory.class, query).getServiceReferences();
|
||||
if (factoryList != null)
|
||||
{
|
||||
for(IDocFactory factory : factoryList)
|
||||
for(IServiceReferenceHolder<IDocFactory> factory : factoryList)
|
||||
{
|
||||
Doc doc = factory.getDocument(as, AD_Table_ID, Record_ID, trxName);
|
||||
if (doc != null)
|
||||
return doc;
|
||||
IDocFactory service = factory.getService();
|
||||
if (service != null)
|
||||
{
|
||||
Doc doc = service.getDocument(as, AD_Table_ID, Record_ID, trxName);
|
||||
if (doc != null)
|
||||
{
|
||||
s_DocFactoryCache.put(cacheKey, factory);
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,29 +205,57 @@ public class DocManager {
|
|||
*/
|
||||
public static Doc getDocument(MAcctSchema as, int AD_Table_ID, ResultSet rs, String trxName)
|
||||
{
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("gaap", as.getGAAP());
|
||||
List<IDocFactory> factoryList = Service.locator().list(IDocFactory.class,query).getServices();
|
||||
if (factoryList != null)
|
||||
String cacheKey = as.getC_AcctSchema_ID() + "|" + AD_Table_ID;
|
||||
IServiceReferenceHolder<IDocFactory> cache = s_DocFactoryCache.get(cacheKey);
|
||||
if (cache != null)
|
||||
{
|
||||
for(IDocFactory factory : factoryList)
|
||||
IDocFactory service = cache.getService();
|
||||
if (service != null)
|
||||
{
|
||||
Doc doc = factory.getDocument(as, AD_Table_ID, rs, trxName);
|
||||
Doc doc = service.getDocument(as, AD_Table_ID, rs, trxName);
|
||||
if (doc != null)
|
||||
return doc;
|
||||
}
|
||||
s_DocFactoryCache.remove(cacheKey);
|
||||
}
|
||||
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("gaap", as.getGAAP());
|
||||
List<IServiceReferenceHolder<IDocFactory>> factoryList = Service.locator().list(IDocFactory.class,query).getServiceReferences();
|
||||
if (factoryList != null)
|
||||
{
|
||||
for(IServiceReferenceHolder<IDocFactory> factory : factoryList)
|
||||
{
|
||||
IDocFactory service = factory.getService();
|
||||
if (service != null)
|
||||
{
|
||||
Doc doc = service.getDocument(as, AD_Table_ID, rs, trxName);
|
||||
if (doc != null)
|
||||
{
|
||||
s_DocFactoryCache.put(cacheKey, factory);
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query.clear();
|
||||
query.put("gaap", "*");
|
||||
factoryList = Service.locator().list(IDocFactory.class,query).getServices();
|
||||
factoryList = Service.locator().list(IDocFactory.class,query).getServiceReferences();
|
||||
if (factoryList != null)
|
||||
{
|
||||
for(IDocFactory factory : factoryList)
|
||||
for(IServiceReferenceHolder<IDocFactory> factory : factoryList)
|
||||
{
|
||||
Doc doc = factory.getDocument(as, AD_Table_ID, rs, trxName);
|
||||
if (doc != null)
|
||||
return doc;
|
||||
IDocFactory service = factory.getService();
|
||||
if (service != null)
|
||||
{
|
||||
Doc doc = service.getDocument(as, AD_Table_ID, rs, trxName);
|
||||
if (doc != null)
|
||||
{
|
||||
s_DocFactoryCache.put(cacheKey, factory);
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ package org.compiere.db;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.ServiceQuery;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
|
@ -51,15 +53,29 @@ public class Database
|
|||
/** Default Port */
|
||||
public static final int DB_POSTGRESQL_DEFAULT_PORT = 5432;
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<AdempiereDatabase>> s_databaseReferenceCache = new CCache<>(null, "IDatabase", 2, false);
|
||||
|
||||
/**
|
||||
* Get Database by database Id.
|
||||
* @return database
|
||||
*/
|
||||
public static AdempiereDatabase getDatabase (String type)
|
||||
{
|
||||
AdempiereDatabase db = null;
|
||||
IServiceReferenceHolder<AdempiereDatabase> cache = s_databaseReferenceCache.get(type);
|
||||
if (cache != null) {
|
||||
db = cache.getService();
|
||||
if (db != null)
|
||||
return db;
|
||||
s_databaseReferenceCache.remove(type);
|
||||
}
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("id", type);
|
||||
AdempiereDatabase db = Service.locator().locate(AdempiereDatabase.class, query).getService();
|
||||
IServiceReferenceHolder<AdempiereDatabase> serviceReference = Service.locator().locate(AdempiereDatabase.class, query).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
db = serviceReference.getService();
|
||||
s_databaseReferenceCache.put(type, serviceReference);
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ import java.util.Properties;
|
|||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.ILookupFactory;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.LookupFactoryHelper;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -195,15 +194,8 @@ public class GridField
|
|||
} // m_lookup
|
||||
|
||||
private void loadLookupFromFactory() {
|
||||
//http://jira.idempiere.com/browse/IDEMPIERE-694
|
||||
//see DefaultLookupFactory.java for the other default Lookups
|
||||
List<ILookupFactory> factoryList = Service.locator().list(ILookupFactory.class).getServices();
|
||||
for(ILookupFactory factory : factoryList)
|
||||
{
|
||||
m_lookup = factory.getLookup(m_vo);
|
||||
if (m_lookup != null)
|
||||
break;
|
||||
}
|
||||
//http://jira.idempiere.com/browse/IDEMPIERE-694
|
||||
m_lookup = LookupFactoryHelper.getLookup(m_vo);
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -263,14 +255,8 @@ public class GridField
|
|||
// retValue = false;
|
||||
else {
|
||||
//http://jira.idempiere.com/browse/IDEMPIERE-694
|
||||
//see DefaultLookupFactory.java for the other default Lookups
|
||||
List<ILookupFactory> factoryList = Service.locator().list(ILookupFactory.class).getServices();
|
||||
for(ILookupFactory factory : factoryList)
|
||||
{
|
||||
retValue = factory.isLookup(m_vo);
|
||||
if (retValue == true)
|
||||
break;
|
||||
}
|
||||
if (LookupFactoryHelper.isLookup(m_vo))
|
||||
retValue = true;
|
||||
}
|
||||
return retValue;
|
||||
} // isLookup
|
||||
|
|
|
@ -41,6 +41,17 @@ public class GridWindowVO implements Serializable
|
|||
*/
|
||||
private static final long serialVersionUID = 6884332743173214735L;
|
||||
|
||||
/**
|
||||
* Create Window Value Object
|
||||
* @param WindowNo window no for ctx
|
||||
* @param AD_Window_ID window id
|
||||
* @return MWindowVO
|
||||
*/
|
||||
public static GridWindowVO create (int WindowNo, int AD_Window_ID)
|
||||
{
|
||||
return create(Env.getCtx(), WindowNo, AD_Window_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Window Value Object
|
||||
* @param ctx context
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
@ -402,7 +402,7 @@ public class MPInstance extends X_AD_PInstance
|
|||
}
|
||||
|
||||
public static void publishChangedEvent(int AD_User_ID) {
|
||||
IMessageService service = Service.locator().locate(IMessageService.class).getService();
|
||||
IMessageService service = Core.getMessageService();
|
||||
if (service != null) {
|
||||
ITopic<Integer> topic = service.getTopic(ON_RUNNING_JOB_CHANGED_TOPIC);
|
||||
topic.publish(AD_User_ID);
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -244,7 +244,7 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
|
|||
}
|
||||
|
||||
public static void publishChangedEvent(int AD_User_ID) {
|
||||
IMessageService service = Service.locator().locate(IMessageService.class).getService();
|
||||
IMessageService service = Core.getMessageService();
|
||||
if (service != null) {
|
||||
ITopic<Integer> topic = service.getTopic(ON_RECENT_ITEM_CHANGED_TOPIC);
|
||||
topic.publish(AD_User_ID);
|
||||
|
|
|
@ -19,9 +19,11 @@ package org.compiere.model;
|
|||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.ServiceQuery;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.util.CCache;
|
||||
|
||||
public class MStorageProvider extends X_AD_StorageProvider {
|
||||
/**
|
||||
|
@ -37,42 +39,132 @@ public class MStorageProvider extends X_AD_StorageProvider {
|
|||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link IAttachmentStore}
|
||||
*/
|
||||
public IAttachmentStore getAttachmentStore() {
|
||||
ServiceQuery query=new ServiceQuery();
|
||||
String method = this.getMethod();
|
||||
if (method == null)
|
||||
method = "DB";
|
||||
query.put("method", method);
|
||||
IAttachmentStore store = Service.locator().locate(IAttachmentStore.class, query).getService();
|
||||
IAttachmentStore store = getAttachmentStoreService(query);
|
||||
if (store == null) {
|
||||
throw new AdempiereException("No attachment storage provider found");
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
private static CCache<ServiceQuery, IServiceReferenceHolder<IAttachmentStore>> s_attachmentStoreReference = new CCache<>(null, "IAttachmentStore", 3, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param query
|
||||
* @return {@link IAttachmentStore}
|
||||
*/
|
||||
public static IAttachmentStore getAttachmentStoreService(ServiceQuery query) {
|
||||
IAttachmentStore store = null;
|
||||
IServiceReferenceHolder<IAttachmentStore> cache = s_attachmentStoreReference.get(query);
|
||||
if (cache != null) {
|
||||
store = cache.getService();
|
||||
if (store != null)
|
||||
return store;
|
||||
else
|
||||
s_attachmentStoreReference.remove(query);
|
||||
}
|
||||
IServiceReferenceHolder<IAttachmentStore> serviceReference = Service.locator().locate(IAttachmentStore.class, query).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
store = serviceReference.getService();
|
||||
if (store != null)
|
||||
s_attachmentStoreReference.put(query, serviceReference);
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link IArchiveStore}
|
||||
*/
|
||||
public IArchiveStore getArchiveStore() {
|
||||
ServiceQuery query=new ServiceQuery();
|
||||
String method = this.getMethod();
|
||||
if (method == null)
|
||||
method = "DB";
|
||||
query.put("method", method);
|
||||
IArchiveStore store = Service.locator().locate(IArchiveStore.class, query).getService();
|
||||
IArchiveStore store = getArchiveStoreService(query);
|
||||
if (store == null) {
|
||||
throw new AdempiereException("No archive storage provider found");
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
private static CCache<ServiceQuery, IServiceReferenceHolder<IArchiveStore>> s_archiveStoreReference = new CCache<>(null, "IArchiveStore", 3, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param query
|
||||
* @return {@link IArchiveStore}
|
||||
*/
|
||||
public static IArchiveStore getArchiveStoreService(ServiceQuery query) {
|
||||
IArchiveStore store = null;
|
||||
IServiceReferenceHolder<IArchiveStore> cache = s_archiveStoreReference.get(query);
|
||||
if (cache != null) {
|
||||
store = cache.getService();
|
||||
if (store != null)
|
||||
return store;
|
||||
else
|
||||
s_archiveStoreReference.remove(query);
|
||||
}
|
||||
|
||||
IServiceReferenceHolder<IArchiveStore> serviceReference = Service.locator().locate(IArchiveStore.class, query).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
store = serviceReference.getService();
|
||||
if (store != null)
|
||||
s_archiveStoreReference.put(query, serviceReference);
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link IImageStore}
|
||||
*/
|
||||
public IImageStore getImageStore() {
|
||||
ServiceQuery query=new ServiceQuery();
|
||||
String method = this.getMethod();
|
||||
if (method == null)
|
||||
method = "DB";
|
||||
query.put("method", method);
|
||||
IImageStore store = Service.locator().locate(IImageStore.class, query).getService();
|
||||
IImageStore store = getImageStoreService(query);
|
||||
if (store == null) {
|
||||
throw new AdempiereException("No image storage provider found");
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
private static CCache<ServiceQuery, IServiceReferenceHolder<IImageStore>> s_imageStoreReference = new CCache<>(null, "IImageStore", 3, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param query
|
||||
* @return {@link IImageStore}
|
||||
*/
|
||||
public static IImageStore getImageStoreService(ServiceQuery query) {
|
||||
IImageStore store = null;
|
||||
IServiceReferenceHolder<IImageStore> cache = s_imageStoreReference.get(query);
|
||||
if (cache != null) {
|
||||
store = cache.getService();
|
||||
if (store != null)
|
||||
return store;
|
||||
else
|
||||
s_imageStoreReference.remove(query);
|
||||
}
|
||||
IServiceReferenceHolder<IImageStore> serviceReference = Service.locator().locate(IImageStore.class, query).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
store = serviceReference.getService();
|
||||
s_imageStoreReference.put(query, serviceReference);
|
||||
}
|
||||
return store;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,12 @@ import java.util.Properties;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.IModelFactory;
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.model.GenericPO;
|
||||
import org.compiere.db.AdempiereDatabase;
|
||||
import org.compiere.db.Database;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -207,7 +209,7 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport
|
|||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MTable.class);
|
||||
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IModelFactory>> s_modelFactoryCache = new CCache<>(null, "IModelFactory", 100, 120, false, 2000);
|
||||
|
||||
/**
|
||||
* Get Persistence Class for Table
|
||||
|
@ -216,13 +218,32 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport
|
|||
*/
|
||||
public static Class<?> getClass (String tableName)
|
||||
{
|
||||
List<IModelFactory> factoryList = Service.locator().list(IModelFactory.class).getServices();
|
||||
IServiceReferenceHolder<IModelFactory> cache = s_modelFactoryCache.get(tableName);
|
||||
if (cache != null)
|
||||
{
|
||||
IModelFactory service = cache.getService();
|
||||
if (service != null)
|
||||
{
|
||||
Class<?> clazz = service.getClass(tableName);
|
||||
if (clazz != null)
|
||||
return clazz;
|
||||
}
|
||||
s_modelFactoryCache.remove(tableName);
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IModelFactory>> factoryList = Service.locator().list(IModelFactory.class).getServiceReferences();
|
||||
if (factoryList == null)
|
||||
return null;
|
||||
for(IModelFactory factory : factoryList) {
|
||||
Class<?> clazz = factory.getClass(tableName);
|
||||
if (clazz != null)
|
||||
return clazz;
|
||||
for(IServiceReferenceHolder<IModelFactory> factory : factoryList) {
|
||||
IModelFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
Class<?> clazz = service.getClass(tableName);
|
||||
if (clazz != null)
|
||||
{
|
||||
s_modelFactoryCache.put(tableName, factory);
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} // getClass
|
||||
|
@ -481,18 +502,43 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport
|
|||
}
|
||||
|
||||
PO po = null;
|
||||
List<IModelFactory> factoryList = Service.locator().list(IModelFactory.class).getServices();
|
||||
if (factoryList != null)
|
||||
IServiceReferenceHolder<IModelFactory> cache = s_modelFactoryCache.get(tableName);
|
||||
if (cache != null)
|
||||
{
|
||||
for(IModelFactory factory : factoryList)
|
||||
IModelFactory service = cache.getService();
|
||||
if (service != null)
|
||||
{
|
||||
po = factory.getPO(tableName, Record_ID, trxName);
|
||||
po = service.getPO(tableName, Record_ID, trxName);
|
||||
if (po != null)
|
||||
{
|
||||
if (po.get_ID() != Record_ID && Record_ID > 0)
|
||||
po = null;
|
||||
else
|
||||
break;
|
||||
return po;
|
||||
}
|
||||
}
|
||||
s_modelFactoryCache.remove(tableName);
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IModelFactory>> factoryList = Service.locator().list(IModelFactory.class).getServiceReferences();
|
||||
if (factoryList != null)
|
||||
{
|
||||
for(IServiceReferenceHolder<IModelFactory> factory : factoryList)
|
||||
{
|
||||
IModelFactory service = factory.getService();
|
||||
if (service != null)
|
||||
{
|
||||
po = service.getPO(tableName, Record_ID, trxName);
|
||||
if (po != null)
|
||||
{
|
||||
if (po.get_ID() != Record_ID && Record_ID > 0)
|
||||
po = null;
|
||||
else
|
||||
{
|
||||
s_modelFactoryCache.put(tableName, factory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -518,13 +564,32 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport
|
|||
String tableName = getTableName();
|
||||
|
||||
PO po = null;
|
||||
List<IModelFactory> factoryList = Service.locator().list(IModelFactory.class).getServices();
|
||||
IServiceReferenceHolder<IModelFactory> cache = s_modelFactoryCache.get(tableName);
|
||||
if (cache != null)
|
||||
{
|
||||
IModelFactory service = cache.getService();
|
||||
if (service != null)
|
||||
{
|
||||
po = service.getPO(tableName, rs, trxName);
|
||||
if (po != null)
|
||||
return po;
|
||||
}
|
||||
s_modelFactoryCache.remove(tableName);
|
||||
}
|
||||
List<IServiceReferenceHolder<IModelFactory>> factoryList = Service.locator().list(IModelFactory.class).getServiceReferences();
|
||||
if (factoryList != null)
|
||||
{
|
||||
for(IModelFactory factory : factoryList) {
|
||||
po = factory.getPO(tableName, rs, trxName);
|
||||
if (po != null)
|
||||
break;
|
||||
for(IServiceReferenceHolder<IModelFactory> factory : factoryList) {
|
||||
IModelFactory service = factory.getService();
|
||||
if (service != null)
|
||||
{
|
||||
po = service.getPO(tableName, rs, trxName);
|
||||
if (po != null)
|
||||
{
|
||||
s_modelFactoryCache.put(tableName, factory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.idempiere.distributed.ICacheService;
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ public class CCache<K,V> implements CacheInterface, Map<K, V>, Serializable
|
|||
cache = CacheMgt.get().register(this, distributed);
|
||||
m_distributed = distributed;
|
||||
if (distributed) {
|
||||
ICacheService provider = Service.locator().locate(ICacheService.class).getService();
|
||||
ICacheService provider = Core.getCacheService();
|
||||
if (provider != null) {
|
||||
nullList = provider.getSet(name);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.db.AdempiereDatabase;
|
||||
import org.compiere.db.CConnection;
|
||||
|
@ -561,7 +561,7 @@ public class CLogMgt
|
|||
//
|
||||
//cluster info
|
||||
if (Env.getAD_Client_ID(Env.getCtx()) == 0) {
|
||||
IClusterService service = Service.locator().locate(IClusterService.class).getService();
|
||||
IClusterService service = Core.getClusterService();
|
||||
if (service != null) {
|
||||
IClusterMember local = service.getLocalMember();
|
||||
Collection<IClusterMember> members = service.getMembers();
|
||||
|
|
|
@ -37,8 +37,7 @@ import java.util.Map.Entry;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.idempiere.distributed.IClusterMember;
|
||||
import org.idempiere.distributed.IClusterService;
|
||||
|
||||
|
@ -157,8 +156,7 @@ public class CacheInfo implements Serializable {
|
|||
* @return cache infos
|
||||
*/
|
||||
public static List<CacheInfo> getCacheInfos(boolean sortByName) {
|
||||
IServiceHolder<IClusterService> holder = Service.locator().locate(IClusterService.class);
|
||||
IClusterService service = holder != null ? holder.getService() : null;
|
||||
IClusterService service = Core.getClusterService();
|
||||
if (service != null && service.getMembers().size() > 1) {
|
||||
List<CacheInfo> instances = new ArrayList<>();
|
||||
GetCacheInfoCallable callable = new GetCacheInfoCallable();
|
||||
|
|
|
@ -26,8 +26,7 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.idempiere.distributed.ICacheService;
|
||||
import org.idempiere.distributed.IClusterMember;
|
||||
import org.idempiere.distributed.IClusterService;
|
||||
|
@ -107,10 +106,10 @@ public class CacheMgt
|
|||
Map<K, V> map = null;
|
||||
if (distributed)
|
||||
{
|
||||
ICacheService provider = Service.locator().locate(ICacheService.class).getService();
|
||||
ICacheService provider = Core.getCacheService();
|
||||
if (provider != null)
|
||||
{
|
||||
IClusterService clusterService = Service.locator().locate(IClusterService.class).getService();
|
||||
IClusterService clusterService = Core.getClusterService();
|
||||
if (clusterService != null && !clusterService.isStandAlone())
|
||||
map = provider.getMap(name);
|
||||
}
|
||||
|
@ -162,8 +161,7 @@ public class CacheMgt
|
|||
* @return number of deleted cache entries
|
||||
*/
|
||||
private int clusterReset(String tableName, int recordId) {
|
||||
IServiceHolder<IClusterService> holder = Service.locator().locate(IClusterService.class);
|
||||
IClusterService service = holder.getService();
|
||||
IClusterService service = Core.getClusterService();
|
||||
if (service != null) {
|
||||
ResetCacheCallable callable = new ResetCacheCallable(tableName, recordId);
|
||||
Map<IClusterMember, Future<Integer>> futureMap = service.execute(callable, service.getMembers());
|
||||
|
@ -203,8 +201,7 @@ public class CacheMgt
|
|||
* @return number of deleted cache entries
|
||||
*/
|
||||
private void clusterNewRecord(String tableName, int recordId) {
|
||||
IServiceHolder<IClusterService> holder = Service.locator().locate(IClusterService.class);
|
||||
IClusterService service = holder.getService();
|
||||
IClusterService service = Core.getClusterService();
|
||||
if (service != null) {
|
||||
CacheNewRecordCallable callable = new CacheNewRecordCallable(tableName, recordId);
|
||||
if (service.execute(callable, service.getMembers()) == null) {
|
||||
|
|
|
@ -64,9 +64,11 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.IDisplayTypeFactory;
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.compiere.db.AdempiereDatabase;
|
||||
import org.compiere.db.Database;
|
||||
|
@ -214,10 +216,18 @@ public final class DisplayType
|
|||
|| displayType == Image || displayType == Chart)
|
||||
return true;
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
if(factory.isID(displayType))
|
||||
return true;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null)
|
||||
return service.isID(displayType);
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().isID(displayType))
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -235,10 +245,18 @@ public final class DisplayType
|
|||
|| displayType == Integer || displayType == Quantity)
|
||||
return true;
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
if(factory.isNumeric(displayType))
|
||||
return true;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null)
|
||||
return service.isNumeric(displayType);
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().isNumeric(displayType))
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -260,13 +278,22 @@ public final class DisplayType
|
|||
|| displayType == Quantity)
|
||||
return 4;
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
if(factory.getDefaultPrecision(displayType) != null)
|
||||
return factory.getDefaultPrecision(displayType).intValue();
|
||||
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
Integer v = service.getDefaultPrecision(displayType);
|
||||
return v != null ? v.intValue() : 0;
|
||||
}
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().getDefaultPrecision(displayType) != null)
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
Integer v = found.get().getService().getDefaultPrecision(displayType);
|
||||
return v != null ? v.intValue() : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // getDefaultPrecision
|
||||
|
||||
|
@ -289,10 +316,18 @@ public final class DisplayType
|
|||
|| displayType == ChosenMultipleSelectionSearch)
|
||||
return true;
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
if(factory.isText(displayType))
|
||||
return true;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null)
|
||||
return service.isText(displayType);
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().isText(displayType))
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // isText
|
||||
|
@ -308,10 +343,18 @@ public final class DisplayType
|
|||
if (displayType == Date || displayType == DateTime || displayType == Time)
|
||||
return true;
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
if(factory.isDate(displayType))
|
||||
return true;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null)
|
||||
return service.isDate(displayType);
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().isDate(displayType))
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -332,10 +375,18 @@ public final class DisplayType
|
|||
|| displayType == ChosenMultipleSelectionList)
|
||||
return true;
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
if(factory.isLookup(displayType))
|
||||
return true;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null)
|
||||
return service.isLookup(displayType);
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().isLookup(displayType))
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -352,10 +403,18 @@ public final class DisplayType
|
|||
|| displayType == TextLong)
|
||||
return true;
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
if(factory.isLOB(displayType))
|
||||
return true;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null)
|
||||
return service.isLOB(displayType);
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().isLOB(displayType))
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -415,13 +474,22 @@ public final class DisplayType
|
|||
}
|
||||
else
|
||||
{
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
DecimalFormat osgiFormat = factory.getNumberFormat(displayType, myLanguage, pattern);
|
||||
if(osgiFormat!=null){
|
||||
return osgiFormat;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
DecimalFormat f = service.getNumberFormat(displayType, language, pattern);
|
||||
if (f != null)
|
||||
return f;
|
||||
}
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().getNumberFormat(displayType, language, pattern) != null)
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return found.get().getService().getNumberFormat(displayType, language, pattern);
|
||||
}
|
||||
|
||||
format.setMaximumIntegerDigits(MAX_DIGITS);
|
||||
format.setMaximumFractionDigits(MAX_FRACTION);
|
||||
|
@ -530,11 +598,21 @@ public final class DisplayType
|
|||
}
|
||||
|
||||
else {
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
SimpleDateFormat osgiFormat = factory.getDateFormat(displayType, myLanguage, pattern);
|
||||
if(osgiFormat!=null)
|
||||
return osgiFormat;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
SimpleDateFormat v = service.getDateFormat(displayType, language, pattern);
|
||||
if (v != null)
|
||||
return v;
|
||||
}
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().getDateFormat(displayType, language, pattern) != null)
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return found.get().getService().getDateFormat(displayType, language, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,11 +671,21 @@ public final class DisplayType
|
|||
return byte[].class;
|
||||
else
|
||||
{
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
Class<?> osgiClass = factory.getClass(displayType, yesNoAsBoolean);
|
||||
if(osgiClass!=null)
|
||||
return osgiClass;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
Class<?> v = service.getClass(displayType, yesNoAsBoolean);
|
||||
if (v != null)
|
||||
return v;
|
||||
}
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().getClass(displayType, yesNoAsBoolean) != null)
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return found.get().getService().getClass(displayType, yesNoAsBoolean);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -672,11 +760,21 @@ public final class DisplayType
|
|||
return getDatabase().getCharacterDataType()+"(" + fieldLength + ")";
|
||||
}
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
String osgiSQLDataType = factory.getSQLDataType(displayType, columnName, fieldLength);
|
||||
if(osgiSQLDataType!=null)
|
||||
return osgiSQLDataType;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
String v = service.getSQLDataType(displayType, columnName, fieldLength);
|
||||
if (v != null)
|
||||
return v;
|
||||
}
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().getSQLDataType(displayType, columnName, fieldLength) != null)
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return found.get().getService().getSQLDataType(displayType, columnName, fieldLength);
|
||||
}
|
||||
|
||||
if (!DisplayType.isText(displayType))
|
||||
|
@ -764,11 +862,21 @@ public final class DisplayType
|
|||
if (displayType == Chart)
|
||||
return "Chart";
|
||||
|
||||
List<IDisplayTypeFactory> factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices();
|
||||
for(IDisplayTypeFactory factory : factoryList){
|
||||
String osgiDescription = factory.getDescription(displayType);
|
||||
if(osgiDescription!=null)
|
||||
return osgiDescription;
|
||||
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
|
||||
if (cache != null) {
|
||||
IDisplayTypeFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
String v = service.getDescription(displayType);
|
||||
if (v != null)
|
||||
return v;
|
||||
}
|
||||
}
|
||||
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
|
||||
.filter(e -> e.getService() != null && e.getService().getDescription(displayType) != null)
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
s_displayTypeFactoryCache.put(displayType, found.get());
|
||||
return found.get().getService().getDescription(displayType);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -791,4 +899,9 @@ public final class DisplayType
|
|||
} // getCurrencyFormat
|
||||
|
||||
|
||||
private final static CCache<Integer, IServiceReferenceHolder<IDisplayTypeFactory>> s_displayTypeFactoryCache = new CCache<>(null, "IDisplayTypeFactory", 100, false);
|
||||
|
||||
private static List<IServiceReferenceHolder<IDisplayTypeFactory>> getDisplayTypeFactories() {
|
||||
return Service.locator().list(IDisplayTypeFactory.class).getServiceReferences();
|
||||
}
|
||||
} // DisplayType
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.pipo.srv.PipoDictionaryService">
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.adempiere.pipo.srv.PipoDictionaryService">
|
||||
<implementation class="org.adempiere.pipo.srv.PipoDictionaryService"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IDictionaryService"/>
|
||||
|
|
|
@ -18,8 +18,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.IDictionaryService;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MSysConfig;
|
||||
|
@ -93,9 +93,8 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
|||
boolean success = false;
|
||||
|
||||
if (!installedPackage(version)) {
|
||||
List<IDictionaryService> list = Service.locator().list(IDictionaryService.class).getServices();
|
||||
if (list != null) {
|
||||
IDictionaryService ids = list.get(0);
|
||||
IDictionaryService ids = Core.getDictionaryService();
|
||||
if (ids != null) {
|
||||
ids.merge(null, zipfile);
|
||||
success = true;
|
||||
if (ids.getAD_Package_Imp_Proc() != null) {
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
* - carlos *
|
||||
* - deepak *
|
||||
* - thomas *
|
||||
**********************************************************************/
|
||||
package org.adempiere.report.jasper;
|
||||
|
||||
import org.compiere.model.PrintInfo;
|
||||
|
@ -5,11 +32,29 @@ import org.compiere.model.PrintInfo;
|
|||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JasperPrint;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface JRViewerProvider {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param jasperPrint
|
||||
* @param title
|
||||
* @param printInfo
|
||||
* @throws JRException
|
||||
*/
|
||||
public void openViewer(JasperPrint jasperPrint, String title, PrintInfo printInfo) throws JRException;
|
||||
|
||||
default void openViewer(JasperPrint jasperPrint, String title) throws JRException {
|
||||
/**
|
||||
*
|
||||
* @param jasperPrint
|
||||
* @param title
|
||||
* @throws JRException
|
||||
*/
|
||||
public default void openViewer(JasperPrint jasperPrint, String title) throws JRException {
|
||||
openViewer(jasperPrint, title, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - carlos *
|
||||
* - deepak *
|
||||
**********************************************************************/
|
||||
package org.adempiere.report.jasper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -7,11 +32,23 @@ import org.compiere.model.PrintInfo;
|
|||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JasperPrint;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author carlos
|
||||
*
|
||||
*/
|
||||
public interface JRViewerProviderList {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param jasperPrintList
|
||||
* @param title
|
||||
* @param printInfo
|
||||
* @throws JRException
|
||||
*/
|
||||
public void openViewer(List<JasperPrint> jasperPrintList, String title, PrintInfo printInfo) throws JRException;
|
||||
|
||||
default void openViewer(List<JasperPrint> jasperPrintList, String title) throws JRException {
|
||||
public default void openViewer(List<JasperPrint> jasperPrintList, String title) throws JRException {
|
||||
openViewer(jasperPrintList, title, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import javax.print.attribute.PrintRequestAttributeSet;
|
|||
import javax.print.attribute.standard.Copies;
|
||||
import javax.print.attribute.standard.JobName;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.exceptions.DBException;
|
||||
|
@ -755,7 +756,7 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
|||
printInfo = new PrintInfo(pi);
|
||||
if (reportPathList.length == 1) {
|
||||
if (log.isLoggable(Level.INFO)) log.info( "ReportStarter.startProcess run report -"+jasperPrint.getName());
|
||||
JRViewerProvider viewerLauncher = Service.locator().locate(JRViewerProvider.class).getService();
|
||||
JRViewerProvider viewerLauncher = getViewerProvider();
|
||||
if (!Util.isEmpty(processInfo.getReportType())) {
|
||||
jasperPrint.setProperty("IDEMPIERE_REPORT_TYPE", processInfo.getReportType());
|
||||
}
|
||||
|
@ -763,7 +764,7 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
|||
} else {
|
||||
jasperPrintList.add(jasperPrint);
|
||||
if (idx+1 == reportPathList.length) {
|
||||
JRViewerProviderList viewerLauncher = Service.locator().locate(JRViewerProviderList.class).getService();
|
||||
JRViewerProviderList viewerLauncher = getViewerProviderList();
|
||||
if (viewerLauncher == null) {
|
||||
throw new AdempiereException("Can not find a viewer provider for multiple jaspers");
|
||||
}
|
||||
|
@ -886,7 +887,49 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
|||
reportResult( AD_PInstance_ID, null, trxName);
|
||||
pi.setSummary(Msg.getMsg(Env.getCtx(), "Success"), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<JRViewerProviderList> s_viewerProviderListReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link JRViewerProviderList}
|
||||
*/
|
||||
public static synchronized JRViewerProviderList getViewerProviderList() {
|
||||
JRViewerProviderList viewerLauncher = null;
|
||||
if (s_viewerProviderListReference != null) {
|
||||
viewerLauncher = s_viewerProviderListReference.getService();
|
||||
if (viewerLauncher != null)
|
||||
return viewerLauncher;
|
||||
}
|
||||
IServiceReferenceHolder<JRViewerProviderList> viewerReference = Service.locator().locate(JRViewerProviderList.class).getServiceReference();
|
||||
if (viewerReference != null) {
|
||||
viewerLauncher = viewerReference.getService();
|
||||
s_viewerProviderListReference = viewerReference;
|
||||
}
|
||||
return viewerLauncher;
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<JRViewerProvider> s_viewerProviderReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link JRViewerProvider}
|
||||
*/
|
||||
public static synchronized JRViewerProvider getViewerProvider() {
|
||||
JRViewerProvider viewerLauncher = null;
|
||||
if (s_viewerProviderReference != null) {
|
||||
viewerLauncher = s_viewerProviderReference.getService();
|
||||
if (viewerLauncher != null)
|
||||
return viewerLauncher;
|
||||
}
|
||||
IServiceReferenceHolder<JRViewerProvider> viewerReference = Service.locator().locate(JRViewerProvider.class).getServiceReference();
|
||||
if (viewerReference != null) {
|
||||
viewerLauncher = viewerReference.getService();
|
||||
s_viewerProviderReference = viewerReference;
|
||||
}
|
||||
return viewerLauncher;
|
||||
}
|
||||
|
||||
private String makePrefix(String name) {
|
||||
StringBuilder prefix = new StringBuilder();
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.server.AdempiereServerActivator;
|
||||
import org.adempiere.server.IServerFactory;
|
||||
|
@ -142,7 +142,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
|
|||
if (clusterId != null) {
|
||||
Map<String, String> map = getServerOwnerMap();
|
||||
if (map != null) {
|
||||
ICacheService cacheService = getCacheService();
|
||||
ICacheService cacheService = Core.getCacheService();
|
||||
try {
|
||||
String reloadLockKey = "cluster.server.owner.map.reload";
|
||||
if (cacheService.tryLock(map, reloadLockKey, 30, TimeUnit.SECONDS)) {
|
||||
|
@ -200,7 +200,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
|
|||
if (clusterId != null) {
|
||||
Map<String, String> map = getServerOwnerMap();
|
||||
if (map != null) {
|
||||
ICacheService cacheService = getCacheService();
|
||||
ICacheService cacheService = Core.getCacheService();
|
||||
try {
|
||||
if (cacheService.tryLock(map, server.getServerID(), 30, TimeUnit.SECONDS)) {
|
||||
try {
|
||||
|
@ -257,7 +257,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
|
|||
if (clusterId != null) {
|
||||
Map<String, String> map = getServerOwnerMap();
|
||||
if (map != null) {
|
||||
ICacheService cacheService = getCacheService();
|
||||
ICacheService cacheService = Core.getCacheService();
|
||||
try {
|
||||
if (cacheService.tryLock(map, server.getServerID(), 30, TimeUnit.SECONDS)) {
|
||||
try {
|
||||
|
@ -853,14 +853,8 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
|
|||
return null;
|
||||
}
|
||||
|
||||
private ICacheService getCacheService( ) {
|
||||
IServiceHolder<ICacheService> holder = Service.locator().locate(ICacheService.class);
|
||||
ICacheService service = holder != null ? holder.getService() : null;
|
||||
return service;
|
||||
}
|
||||
|
||||
private Map<String, String> getServerOwnerMap() {
|
||||
ICacheService service = getCacheService();
|
||||
ICacheService service = Core.getCacheService();
|
||||
if (service != null) {
|
||||
return service.getMap("cluster.server.owner.map");
|
||||
}
|
||||
|
|
|
@ -36,8 +36,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.MScheduler;
|
||||
import org.compiere.server.IServerManager;
|
||||
|
@ -84,9 +83,7 @@ public class ClusterServerMgr implements IServerManager {
|
|||
* @return cluster service
|
||||
*/
|
||||
public static IClusterService getClusterService() {
|
||||
IServiceHolder<IClusterService> holder = Service.locator().locate(IClusterService.class);
|
||||
IClusterService service = holder != null ? holder.getService() : null;
|
||||
return service;
|
||||
return Core.getClusterService();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,13 +20,25 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.ServiceQuery;
|
||||
import org.adempiere.webui.apps.IProcessParameterListener;
|
||||
import org.adempiere.webui.apps.graph.IChartRendererService;
|
||||
import org.adempiere.webui.factory.IDashboardGadgetFactory;
|
||||
import org.adempiere.webui.factory.IFormFactory;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.compiere.grid.ICreateFrom;
|
||||
import org.compiere.grid.ICreateFromFactory;
|
||||
import org.compiere.grid.IPaymentForm;
|
||||
import org.compiere.grid.IPaymentFormFactory;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.util.CCache;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -36,23 +48,42 @@ import org.adempiere.webui.panel.ADForm;
|
|||
*/
|
||||
public class Extensions {
|
||||
|
||||
private final static CCache<String, IServiceReferenceHolder<IFormFactory>> s_formFactoryCache = new CCache<>(null, "IFormFactory", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param formId Java class name or equinox extension Id
|
||||
* @return IFormController instance or null if formId not found
|
||||
*/
|
||||
public static ADForm getForm(String formId) {
|
||||
List<IFormFactory> factories = Service.locator().list(IFormFactory.class).getServices();
|
||||
if (factories != null) {
|
||||
for(IFormFactory factory : factories) {
|
||||
ADForm form = factory.newFormInstance(formId);
|
||||
IServiceReferenceHolder<IFormFactory> cache = s_formFactoryCache.get(formId);
|
||||
if (cache != null) {
|
||||
IFormFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
ADForm form = service.newFormInstance(formId);
|
||||
if (form != null)
|
||||
return form;
|
||||
}
|
||||
s_formFactoryCache.remove(formId);
|
||||
}
|
||||
List<IServiceReferenceHolder<IFormFactory>> factories = Service.locator().list(IFormFactory.class).getServiceReferences();
|
||||
if (factories != null) {
|
||||
for(IServiceReferenceHolder<IFormFactory> factory : factories) {
|
||||
IFormFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
ADForm form = service.newFormInstance(formId);
|
||||
if (form != null) {
|
||||
s_formFactoryCache.put(formId, factory);
|
||||
return form;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final static CCache<String, List<IServiceReferenceHolder<IProcessParameterListener>>> s_processParameterListenerCache = new CCache<>(null, "List<IProcessParameterListener>", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param processClass
|
||||
|
@ -60,10 +91,133 @@ public class Extensions {
|
|||
* @return list of parameter listener
|
||||
*/
|
||||
public static List<IProcessParameterListener> getProcessParameterListeners(String processClass, String columnName) {
|
||||
String cacheKey = processClass + "|" + columnName;
|
||||
List<IServiceReferenceHolder<IProcessParameterListener>> listeners = s_processParameterListenerCache.get(cacheKey);
|
||||
if (listeners != null)
|
||||
return listeners.stream().filter(e -> e.getService() != null).map(e -> e.getService()).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("ProcessClass", processClass);
|
||||
if (columnName != null)
|
||||
query.put("|(ColumnName", columnName+")(ColumnName="+columnName+",*)(ColumnName="+"*,"+columnName+",*)(ColumnName=*,"+columnName+")");
|
||||
return Service.locator().list(IProcessParameterListener.class, null, query).getServices();
|
||||
listeners = Service.locator().list(IProcessParameterListener.class, null, query).getServiceReferences();
|
||||
if (listeners == null)
|
||||
listeners = new ArrayList<>();
|
||||
s_processParameterListenerCache.put(cacheKey, listeners);
|
||||
return listeners.stream().filter(e -> e.getService() != null).map(e -> e.getService()).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
private final static CCache<String, IServiceReferenceHolder<ICreateFromFactory>> s_createFromFactoryCache = new CCache<>(null, "ICreateFromFactory", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mTab
|
||||
* @return ICreateFrom instance
|
||||
*/
|
||||
public static ICreateFrom getCreateFrom(GridTab mTab) {
|
||||
ICreateFrom createFrom = null;
|
||||
String cacheKey = Integer.toString(mTab.getAD_Tab_ID());
|
||||
IServiceReferenceHolder<ICreateFromFactory> cache = s_createFromFactoryCache.get(cacheKey);
|
||||
if (cache != null) {
|
||||
ICreateFromFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
createFrom = service.create(mTab);
|
||||
if (createFrom != null) {
|
||||
return createFrom;
|
||||
}
|
||||
}
|
||||
s_createFromFactoryCache.remove(cacheKey);
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<ICreateFromFactory>> factories = Service.locator().list(ICreateFromFactory.class).getServiceReferences();
|
||||
for (IServiceReferenceHolder<ICreateFromFactory> factory : factories)
|
||||
{
|
||||
ICreateFromFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
createFrom = service.create(mTab);
|
||||
if (createFrom != null) {
|
||||
s_createFromFactoryCache.put(cacheKey, factory);
|
||||
return createFrom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IPaymentFormFactory>> s_paymentFormFactoryCache = new CCache<>(null, "IPaymentFormFactory", 100, false);
|
||||
/**
|
||||
*
|
||||
* @param windowNo
|
||||
* @param mTab
|
||||
* @param paymentRule
|
||||
* @return IPaymentForm instance
|
||||
*/
|
||||
public static IPaymentForm getPaymentForm(int windowNo, GridTab mTab, String paymentRule) {
|
||||
String cacheKey = mTab.getAD_Tab_ID() + "|" + paymentRule;
|
||||
IServiceReferenceHolder<IPaymentFormFactory> cache = s_paymentFormFactoryCache.get(cacheKey);
|
||||
if (cache != null) {
|
||||
IPaymentFormFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
IPaymentForm paymentForm = service.create(windowNo, mTab, paymentRule);
|
||||
if (paymentForm != null)
|
||||
return paymentForm;
|
||||
}
|
||||
s_paymentFormFactoryCache.remove(cacheKey);
|
||||
}
|
||||
IPaymentForm paymentForm = null;
|
||||
List<IServiceReferenceHolder<IPaymentFormFactory>> factories = Service.locator().list(IPaymentFormFactory.class).getServiceReferences();
|
||||
for (IServiceReferenceHolder<IPaymentFormFactory> factory : factories) {
|
||||
IPaymentFormFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
paymentForm = service.create(windowNo, mTab, paymentRule);
|
||||
if (paymentForm != null) {
|
||||
s_paymentFormFactoryCache.put(cacheKey, factory);
|
||||
return paymentForm;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final CCache<String, IServiceReferenceHolder<IDashboardGadgetFactory>> s_dashboardGadgetFactoryCache = new CCache<>(null, "IDashboardGadgetFactory", 100, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @param parent
|
||||
* @return Gadget component
|
||||
*/
|
||||
public static final Component getDashboardGadget(String url, Component parent) {
|
||||
IServiceReferenceHolder<IDashboardGadgetFactory> cache = s_dashboardGadgetFactoryCache.get(url);
|
||||
if (cache != null) {
|
||||
IDashboardGadgetFactory service = cache.getService();
|
||||
if (service != null) {
|
||||
Component component = service.getGadget(url,parent);
|
||||
if(component != null)
|
||||
return component;
|
||||
}
|
||||
s_dashboardGadgetFactoryCache.remove(url);
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IDashboardGadgetFactory>> f = Service.locator().list(IDashboardGadgetFactory.class).getServiceReferences();
|
||||
for (IServiceReferenceHolder<IDashboardGadgetFactory> factory : f) {
|
||||
IDashboardGadgetFactory service = factory.getService();
|
||||
if (service != null) {
|
||||
Component component = service.getGadget(url,parent);
|
||||
if(component != null)
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return list of {@link IChartRendererService}
|
||||
*/
|
||||
public static final List<IChartRendererService> getChartRendererServices() {
|
||||
return Service.locator().list(IChartRendererService.class).getServices();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class Actions {
|
|||
synchronized (trackerCache) {
|
||||
action = trackerCache.get(actionId);
|
||||
}
|
||||
if (action != null)
|
||||
if (action != null && action.getService() != null)
|
||||
return action;
|
||||
|
||||
action = Service.locator().locate(IAction.class, actionId, null);
|
||||
|
@ -57,7 +57,7 @@ public class Actions {
|
|||
if (aImage != null)
|
||||
return aImage;
|
||||
|
||||
IServiceHolder<IAction> action = Service.locator().locate(IAction.class, actionId, null);
|
||||
IServiceHolder<IAction> action = getAction(actionId);
|
||||
if (action.getService() != null) {
|
||||
String path = ACTION_IMAGES_PATH + actionId + "24.png";
|
||||
InputStream inputStream = action.getService().getClass().getClassLoader().getResourceAsStream(path);
|
||||
|
|
|
@ -16,7 +16,8 @@ package org.adempiere.webui.apps;
|
|||
import org.adempiere.webui.editor.WEditor;
|
||||
|
||||
/**
|
||||
* Listener interface for process parameter panel
|
||||
* Listener interface for process parameter panel.
|
||||
* Implementation must be thread safe
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -13,25 +13,24 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.Extensions;
|
||||
import org.compiere.grid.ICreateFrom;
|
||||
import org.compiere.grid.ICreateFromFactory;
|
||||
import org.compiere.model.GridTab;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class WCreateFromFactory
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param mTab
|
||||
* @return ICreateFrom instance
|
||||
*/
|
||||
public static ICreateFrom create (GridTab mTab)
|
||||
{
|
||||
ICreateFrom createFrom = null;
|
||||
List<ICreateFromFactory> factories = Service.locator().list(ICreateFromFactory.class).getServices();
|
||||
for (ICreateFromFactory factory : factories)
|
||||
{
|
||||
createFrom = factory.create(mTab);
|
||||
if (createFrom != null)
|
||||
break;
|
||||
}
|
||||
return createFrom;
|
||||
return Extensions.getCreateFrom(mTab);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,8 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.Extensions;
|
||||
import org.compiere.grid.IPaymentForm;
|
||||
import org.compiere.grid.IPaymentFormFactory;
|
||||
import org.compiere.model.GridTab;
|
||||
|
||||
/**
|
||||
|
@ -27,15 +24,15 @@ import org.compiere.model.GridTab;
|
|||
*/
|
||||
public class WPaymentFormFactory {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowNo
|
||||
* @param mTab
|
||||
* @param paymentRule
|
||||
* @return IPaymentForm instance
|
||||
*/
|
||||
public static IPaymentForm create(int windowNo, GridTab mTab, String paymentRule)
|
||||
{
|
||||
IPaymentForm paymentForm = null;
|
||||
List<IPaymentFormFactory> factories = Service.locator().list(IPaymentFormFactory.class).getServices();
|
||||
for (IPaymentFormFactory factory : factories) {
|
||||
paymentForm = factory.create(windowNo, mTab, paymentRule);
|
||||
if (paymentForm != null)
|
||||
break;
|
||||
}
|
||||
return paymentForm;
|
||||
return Extensions.getPaymentForm(windowNo, mTab, paymentRule);
|
||||
}
|
||||
}
|
|
@ -22,8 +22,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.adempiere.apps.graph.GraphColumn;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.Extensions;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.graph.model.GoalModel;
|
||||
import org.adempiere.webui.editor.WTableDirEditor;
|
||||
|
@ -277,7 +277,7 @@ public class WGraph extends Div implements IdSpace {
|
|||
goalModel.xAxisLabel = m_xAxisLabel;
|
||||
goalModel.yAxisLabel = m_yAxisLabel;
|
||||
goalModel.zoomFactor = zoomFactor;
|
||||
List<IChartRendererService> list = Service.locator().list(IChartRendererService.class).getServices();
|
||||
List<IChartRendererService> list = Extensions.getChartRendererServices();
|
||||
for (IChartRendererService renderer : list) {
|
||||
if (renderer.renderPerformanceGraph(panel.getPanelchildren(), width, height, goalModel))
|
||||
break;
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.text.DecimalFormat;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.Extensions;
|
||||
import org.adempiere.webui.apps.graph.model.IndicatorModel;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
|
@ -199,7 +199,7 @@ public class WPerformanceIndicator extends Panel implements EventListener<Event>
|
|||
model.dialBackground = dialBackground;
|
||||
model.needleColor = needleColor;
|
||||
model.tickColor = tickColor;
|
||||
List<IChartRendererService> list = Service.locator().list(IChartRendererService.class).getServices();
|
||||
List<IChartRendererService> list = Extensions.getChartRendererServices();
|
||||
for (IChartRendererService renderer : list) {
|
||||
if (renderer.renderPerformanceIndicator(this, chartWidth, chartHeight, model))
|
||||
break;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.event.AbstractEventHandler;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
|
@ -167,7 +167,7 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
|
||||
if (subscriber == null) {
|
||||
subscriber = new TopicSubscriber();
|
||||
IMessageService service = Service.locator().locate(IMessageService.class).getService();
|
||||
IMessageService service = Core.getMessageService();
|
||||
if (service != null) {
|
||||
ITopic<Map<String,String>> topic = service.getTopic("onRequestChanged");
|
||||
topic.subscribe(subscriber);
|
||||
|
@ -562,7 +562,7 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
IMessageService service = Service.locator().locate(IMessageService.class).getService();
|
||||
IMessageService service = Core.getMessageService();
|
||||
if (service != null) {
|
||||
ITopic<Map<String,String>> topic = service.getTopic(ON_REQUEST_CHANGED_TOPIC);
|
||||
topic.publish(message);
|
||||
|
|
|
@ -16,7 +16,7 @@ package org.adempiere.webui.dashboard;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
|
@ -154,7 +154,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
private static synchronized void createTopicSubscriber() {
|
||||
if (topicSubscriber == null) {
|
||||
topicSubscriber = new TopicSubscriber();
|
||||
IMessageService service = Service.locator().locate(IMessageService.class).getService();
|
||||
IMessageService service = Core.getMessageService();
|
||||
if (service != null) {
|
||||
ITopic<Integer> topic = service.getTopic(MRecentItem.ON_RECENT_ITEM_CHANGED_TOPIC);
|
||||
topic.subscribe(topicSubscriber);
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.adempiere.webui.dashboard;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
|
@ -126,7 +126,7 @@ public class DPRunningJobs extends DashboardPanel implements EventListener<Event
|
|||
{
|
||||
if (topicSubscriber == null) {
|
||||
topicSubscriber = new TopicSubscriber();
|
||||
IMessageService service = Service.locator().locate(IMessageService.class).getService();
|
||||
IMessageService service = Core.getMessageService();
|
||||
if (service != null) {
|
||||
ITopic<Integer> topic = service.getTopic(MPInstance.ON_RUNNING_JOB_CHANGED_TOPIC);
|
||||
topic.subscribe(topicSubscriber);
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.Extensions;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.graph.IChartRendererService;
|
||||
import org.adempiere.webui.apps.graph.WGraph;
|
||||
|
@ -37,7 +37,6 @@ import org.adempiere.webui.apps.graph.model.ChartModel;
|
|||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.dashboard.DashboardPanel;
|
||||
import org.adempiere.webui.dashboard.DashboardRunnable;
|
||||
import org.adempiere.webui.factory.IDashboardGadgetFactory;
|
||||
import org.adempiere.webui.report.HTMLExtension;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
|
@ -472,14 +471,7 @@ public class DashboardController implements EventListener<Event> {
|
|||
{
|
||||
try {
|
||||
|
||||
Component component = null;
|
||||
List<IDashboardGadgetFactory> f = Service.locator().list(IDashboardGadgetFactory.class).getServices();
|
||||
for (IDashboardGadgetFactory factory : f) {
|
||||
component = factory.getGadget(url.toString(),content);
|
||||
if(component != null)
|
||||
break;
|
||||
}
|
||||
|
||||
Component component = Extensions.getDashboardGadget(url, content);
|
||||
if(component != null)
|
||||
{
|
||||
if (component instanceof Include)
|
||||
|
@ -528,11 +520,7 @@ public class DashboardController implements EventListener<Event> {
|
|||
chartPanel.getChildren().clear();
|
||||
ChartModel model = new ChartModel();
|
||||
model.chart = chartModel;
|
||||
List<IChartRendererService> list = Service.locator().list(IChartRendererService.class).getServices();
|
||||
for (IChartRendererService renderer : list) {
|
||||
if (renderer.renderChart(chartPanel, width, height, model))
|
||||
break;
|
||||
}
|
||||
renderChart(chartPanel, width, height, model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -967,4 +955,12 @@ public class DashboardController implements EventListener<Event> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderChart(final Div chartPanel, int width, int height, ChartModel model) {
|
||||
List<IChartRendererService> list = Extensions.getChartRendererServices();
|
||||
for (IChartRendererService renderer : list) {
|
||||
if (renderer.renderChart(chartPanel, width, height, model))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ package org.adempiere.webui.editor;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.Extensions;
|
||||
import org.adempiere.webui.apps.graph.IChartRendererService;
|
||||
import org.adempiere.webui.apps.graph.model.ChartModel;
|
||||
import org.compiere.model.GridField;
|
||||
|
@ -66,7 +66,7 @@ public class WChartEditor extends WEditor
|
|||
chartDiv.getChildren().clear();
|
||||
ChartModel model = new ChartModel();
|
||||
model.chart = chartModel;
|
||||
List<IChartRendererService> list = Service.locator().list(IChartRendererService.class).getServices();
|
||||
List<IChartRendererService> list = Extensions.getChartRendererServices();
|
||||
for (IChartRendererService renderer : list) {
|
||||
if (renderer.renderChart(chartDiv, chartWidth, chartHeight, model))
|
||||
break;
|
||||
|
@ -156,7 +156,7 @@ public class WChartEditor extends WEditor
|
|||
chartDiv.getChildren().clear();
|
||||
ChartModel model = new ChartModel();
|
||||
model.chart = chartModel;
|
||||
List<IChartRendererService> list = Service.locator().list(IChartRendererService.class).getServices();
|
||||
List<IChartRendererService> list = Extensions.getChartRendererServices();
|
||||
for (IChartRendererService renderer : list) {
|
||||
if (renderer.renderChart(chartDiv, chartWidth, chartHeight, model))
|
||||
break;
|
||||
|
|
|
@ -17,13 +17,16 @@
|
|||
|
||||
package org.adempiere.webui.editor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.factory.IEditorFactory;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.CCache;
|
||||
import org.osgi.framework.Constants;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -36,29 +39,61 @@ import org.compiere.util.CLogger;
|
|||
*/
|
||||
public class WebEditorFactory
|
||||
{
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final static CLogger logger;
|
||||
|
||||
static
|
||||
{
|
||||
logger = CLogger.getCLogger(WebEditorFactory.class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gridField
|
||||
* @param tableEditor
|
||||
* @return WEditor for GridField
|
||||
*/
|
||||
public static WEditor getEditor(GridField gridField, boolean tableEditor)
|
||||
{
|
||||
return getEditor(gridField.getGridTab(), gridField, tableEditor);
|
||||
}
|
||||
|
||||
private static final CCache<Long, IServiceReferenceHolder<IEditorFactory>> s_editorFactoryCache = new CCache<>(null, "IEditorFactory", 10, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gridTab
|
||||
* @param gridField
|
||||
* @param tableEditor
|
||||
* @return WEditor for GridField
|
||||
*/
|
||||
public static WEditor getEditor(GridTab gridTab, GridField gridField, boolean tableEditor)
|
||||
{
|
||||
List<Long> visitedIds = new ArrayList<Long>();
|
||||
if (!s_editorFactoryCache.isEmpty()) {
|
||||
Long[] keys = s_editorFactoryCache.keySet().toArray(new Long[0]);
|
||||
for (Long key : keys) {
|
||||
IServiceReferenceHolder<IEditorFactory> serviceReference = s_editorFactoryCache.get(key);
|
||||
if (serviceReference != null) {
|
||||
IEditorFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
visitedIds.add(key);
|
||||
WEditor editor = service.getEditor(gridTab, gridField, tableEditor);
|
||||
if (editor != null)
|
||||
return editor;
|
||||
} else {
|
||||
s_editorFactoryCache.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WEditor editor = null;
|
||||
List<IEditorFactory> factoryList = Service.locator().list(IEditorFactory.class).getServices();
|
||||
for(IEditorFactory factory : factoryList)
|
||||
List<IServiceReferenceHolder<IEditorFactory>> serviceReferences = Service.locator().list(IEditorFactory.class).getServiceReferences();
|
||||
for(IServiceReferenceHolder<IEditorFactory> serviceReference : serviceReferences)
|
||||
{
|
||||
editor = factory.getEditor(gridTab, gridField, tableEditor);
|
||||
if (editor != null)
|
||||
break;
|
||||
Long serviceId = (Long) serviceReference.getServiceReference().getProperty(Constants.SERVICE_ID);
|
||||
if (visitedIds.contains(serviceId))
|
||||
continue;
|
||||
IEditorFactory service = serviceReference.getService();
|
||||
if (service != null)
|
||||
{
|
||||
s_editorFactoryCache.put(serviceId, serviceReference);
|
||||
editor = service.getEditor(gridTab, gridField, tableEditor);
|
||||
if (editor != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
|
|
@ -13,14 +13,18 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.factory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.info.InfoWindow;
|
||||
import org.adempiere.webui.panel.InfoPanel;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.Lookup;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.util.CCache;
|
||||
import org.osgi.framework.Constants;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -29,23 +33,74 @@ import org.compiere.model.MLookup;
|
|||
*/
|
||||
public class InfoManager
|
||||
{
|
||||
private final static CCache<Long, IServiceReferenceHolder<IInfoFactory>> s_infoFactoryCache = new CCache<Long, IServiceReferenceHolder<IInfoFactory>>(null, "IInfoFactory", 10, false);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param WindowNo
|
||||
* @param tableName
|
||||
* @param keyColumn
|
||||
* @param value
|
||||
* @param multiSelection
|
||||
* @param whereClause
|
||||
* @param lookup
|
||||
* @return {@link InfoPanel}
|
||||
*/
|
||||
public static InfoPanel create (int WindowNo,
|
||||
String tableName, String keyColumn, String value,
|
||||
boolean multiSelection, String whereClause, boolean lookup)
|
||||
{
|
||||
InfoPanel info = null;
|
||||
|
||||
List<IInfoFactory> factoryList = Service.locator().list(IInfoFactory.class).getServices();
|
||||
for(IInfoFactory factory : factoryList)
|
||||
InfoPanel info = null;
|
||||
|
||||
List<Long> visitedIds = new ArrayList<Long>();
|
||||
if (!s_infoFactoryCache.isEmpty()) {
|
||||
Long[] keys = s_infoFactoryCache.keySet().toArray(new Long[0]);
|
||||
for (Long key : keys) {
|
||||
IServiceReferenceHolder<IInfoFactory> serviceReference = s_infoFactoryCache.get(key);
|
||||
if (serviceReference != null) {
|
||||
IInfoFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
visitedIds.add(key);
|
||||
info = service.create(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, 0, lookup);
|
||||
if (info != null)
|
||||
return info;
|
||||
} else {
|
||||
s_infoFactoryCache.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IInfoFactory>> serviceReferences = Service.locator().list(IInfoFactory.class).getServiceReferences();
|
||||
for(IServiceReferenceHolder<IInfoFactory> serviceReference : serviceReferences)
|
||||
{
|
||||
info = factory.create(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, 0, lookup);
|
||||
if (info != null)
|
||||
break;
|
||||
Long serviceId = (Long) serviceReference.getServiceReference().getProperty(Constants.SERVICE_ID);
|
||||
if (visitedIds.contains(serviceId))
|
||||
continue;
|
||||
IInfoFactory service = serviceReference.getService();
|
||||
if (service != null)
|
||||
{
|
||||
s_infoFactoryCache.put(serviceId, serviceReference);
|
||||
info = service.create(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, 0, lookup);
|
||||
if (info != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lookup
|
||||
* @param field
|
||||
* @param tableName
|
||||
* @param keyColumn
|
||||
* @param queryValue
|
||||
* @param multiSelection
|
||||
* @param whereClause
|
||||
* @return {@link InfoPanel}
|
||||
*/
|
||||
public static InfoPanel create(Lookup lookup, GridField field, String tableName,
|
||||
String keyColumn, String queryValue, boolean multiSelection,
|
||||
String whereClause)
|
||||
|
@ -56,26 +111,86 @@ public class InfoManager
|
|||
{
|
||||
AD_InfoWindow_ID = ((MLookup)lookup).getAD_InfoWindow_ID();
|
||||
}
|
||||
List<IInfoFactory> factoryList = Service.locator().list(IInfoFactory.class).getServices();
|
||||
for(IInfoFactory factory : factoryList)
|
||||
|
||||
List<Long> visitedIds = new ArrayList<Long>();
|
||||
if (!s_infoFactoryCache.isEmpty()) {
|
||||
Long[] keys = s_infoFactoryCache.keySet().toArray(new Long[0]);
|
||||
for (Long key : keys) {
|
||||
IServiceReferenceHolder<IInfoFactory> serviceReference = s_infoFactoryCache.get(key);
|
||||
if (serviceReference != null) {
|
||||
IInfoFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
visitedIds.add(key);
|
||||
ip = service.create(lookup, field, tableName, keyColumn, queryValue, false, whereClause, AD_InfoWindow_ID);
|
||||
if (ip != null)
|
||||
return ip;
|
||||
} else {
|
||||
s_infoFactoryCache.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IInfoFactory>> serviceReferences = Service.locator().list(IInfoFactory.class).getServiceReferences();
|
||||
for(IServiceReferenceHolder<IInfoFactory> serviceReference : serviceReferences)
|
||||
{
|
||||
ip = factory.create(lookup, field, tableName, keyColumn, queryValue, false, whereClause, AD_InfoWindow_ID);
|
||||
if (ip != null)
|
||||
break;
|
||||
Long serviceId = (Long) serviceReference.getServiceReference().getProperty(Constants.SERVICE_ID);
|
||||
if (visitedIds.contains(serviceId))
|
||||
continue;
|
||||
IInfoFactory service = serviceReference.getService();
|
||||
if (service != null)
|
||||
{
|
||||
s_infoFactoryCache.put(serviceId, serviceReference);
|
||||
ip = service.create(lookup, field, tableName, keyColumn, queryValue, false, whereClause, AD_InfoWindow_ID);
|
||||
if (ip != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param AD_InfoWindow_ID
|
||||
* @return {@link InfoWindow}
|
||||
*/
|
||||
public static InfoWindow create (int AD_InfoWindow_ID)
|
||||
{
|
||||
InfoWindow info = null;
|
||||
|
||||
List<IInfoFactory> factoryList = Service.locator().list(IInfoFactory.class).getServices();
|
||||
for(IInfoFactory factory : factoryList)
|
||||
List<Long> visitedIds = new ArrayList<Long>();
|
||||
if (!s_infoFactoryCache.isEmpty()) {
|
||||
Long[] keys = s_infoFactoryCache.keySet().toArray(new Long[0]);
|
||||
for (Long key : keys) {
|
||||
IServiceReferenceHolder<IInfoFactory> serviceReference = s_infoFactoryCache.get(key);
|
||||
if (serviceReference != null) {
|
||||
IInfoFactory service = serviceReference.getService();
|
||||
if (service != null) {
|
||||
visitedIds.add(key);
|
||||
info = service.create(AD_InfoWindow_ID);
|
||||
if (info != null)
|
||||
return info;
|
||||
} else {
|
||||
s_infoFactoryCache.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IServiceReferenceHolder<IInfoFactory>> serviceReferences = Service.locator().list(IInfoFactory.class).getServiceReferences();
|
||||
for(IServiceReferenceHolder<IInfoFactory> serviceReference : serviceReferences)
|
||||
{
|
||||
info = factory.create(AD_InfoWindow_ID);
|
||||
if (info != null)
|
||||
break;
|
||||
Long serviceId = (Long) serviceReference.getServiceReference().getProperty(Constants.SERVICE_ID);
|
||||
if (visitedIds.contains(serviceId))
|
||||
continue;
|
||||
IInfoFactory service = serviceReference.getService();
|
||||
if (service != null)
|
||||
{
|
||||
s_infoFactoryCache.put(serviceId, serviceReference);
|
||||
info = service.create(AD_InfoWindow_ID);
|
||||
if (info != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
return info;
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
**********************************************************************/
|
||||
package org.adempiere.webui.scheduler;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.action.IAction;
|
||||
|
@ -156,8 +155,7 @@ public class ChangeStateAction implements IAction, EventListener<Event> {
|
|||
|
||||
private IServerManager getServerMgr() {
|
||||
IServerManager serverMgr = null;
|
||||
IServiceHolder<IClusterService> holder = Service.locator().locate(IClusterService.class);
|
||||
IClusterService service = holder != null ? holder.getService() : null;
|
||||
IClusterService service = Core.getClusterService();
|
||||
if (service != null)
|
||||
serverMgr = ClusterServerMgr.getInstance();
|
||||
else
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
**********************************************************************/
|
||||
package org.adempiere.webui.scheduler;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.adwindow.ADWindow;
|
||||
import org.adempiere.webui.component.Button;
|
||||
|
@ -329,8 +328,7 @@ public class SchedulerStateEditor extends WEditor {
|
|||
|
||||
private IServerManager getServerMgr() {
|
||||
IServerManager serverMgr = null;
|
||||
IServiceHolder<IClusterService> holder = Service.locator().locate(IClusterService.class);
|
||||
IClusterService service = holder != null ? holder.getService() : null;
|
||||
IClusterService service = Core.getClusterService();
|
||||
if (service != null)
|
||||
serverMgr = ClusterServerMgr.getInstance();
|
||||
else
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.adempiere.webui.util;
|
|||
|
||||
import javax.activation.DataSource;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.factory.IFeedbackService;
|
||||
|
@ -52,9 +53,30 @@ public class FeedbackManager {
|
|||
*/
|
||||
public static void emailSupport(boolean errorOnly)
|
||||
{
|
||||
IFeedbackService service = Service.locator().locate(IFeedbackService.class).getService();
|
||||
IFeedbackService service = getFeedbackService();
|
||||
if (service != null)
|
||||
service.emailSupport(errorOnly);
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<IFeedbackService> s_feedbackServiceReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link IFeedbackService}
|
||||
*/
|
||||
public static synchronized IFeedbackService getFeedbackService() {
|
||||
IFeedbackService service = null;
|
||||
if (s_feedbackServiceReference != null) {
|
||||
service = s_feedbackServiceReference.getService();
|
||||
if (service != null)
|
||||
return service;
|
||||
}
|
||||
IServiceReferenceHolder<IFeedbackService> serviceReference = Service.locator().locate(IFeedbackService.class).getServiceReference();
|
||||
if (serviceReference != null) {
|
||||
service = serviceReference.getService();
|
||||
s_feedbackServiceReference = serviceReference;
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,7 +84,7 @@ public class FeedbackManager {
|
|||
*/
|
||||
public static void createNewRequest()
|
||||
{
|
||||
IFeedbackService service = Service.locator().locate(IFeedbackService.class).getService();
|
||||
IFeedbackService service = getFeedbackService();
|
||||
if (service != null)
|
||||
service.createNewRequest();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.zkoss.zk.ui.Executions;
|
|||
*/
|
||||
public class ZkReportViewerProvider implements ReportViewerProvider {
|
||||
|
||||
@Override
|
||||
public void openViewer(final ReportEngine report) {
|
||||
// IDEMPIERE-2499
|
||||
// detect ui thread by value of Executions.getCurrent(), not office method but work
|
||||
|
|
|
@ -25,11 +25,9 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.IPaymentExporterFactory;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.Core;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MLookupInfo;
|
||||
import org.compiere.model.MPaySelectionCheck;
|
||||
|
@ -252,15 +250,7 @@ public class PayPrint {
|
|||
}
|
||||
try
|
||||
{
|
||||
List<IPaymentExporterFactory> factories = Service.locator().list(IPaymentExporterFactory.class).getServices();
|
||||
if (factories != null && !factories.isEmpty()) {
|
||||
for(IPaymentExporterFactory factory : factories) {
|
||||
m_PaymentExport = factory.newPaymentExporterInstance(m_PaymentExportClass);
|
||||
if (m_PaymentExport != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_PaymentExport = Core.getPaymentExporter(m_PaymentExportClass);
|
||||
if (m_PaymentExport == null)
|
||||
{
|
||||
Class<?> clazz = Class.forName (m_PaymentExportClass);
|
||||
|
|
|
@ -31,6 +31,7 @@ import static org.compiere.model.SystemIDs.PROCESS_RPT_M_MOVEMENT;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.IServiceReferenceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
|
@ -463,8 +464,29 @@ public class ReportCtl
|
|||
*/
|
||||
public static void preview(ReportEngine re)
|
||||
{
|
||||
ReportViewerProvider viewer = Service.locator().locate(ReportViewerProvider.class).getService();
|
||||
ReportViewerProvider viewer = getReportViewerProvider();
|
||||
viewer.openViewer(re);
|
||||
}
|
||||
|
||||
private static IServiceReferenceHolder<ReportViewerProvider> s_reportViewerProviderReference = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link ReportViewerProvider}
|
||||
*/
|
||||
public static synchronized ReportViewerProvider getReportViewerProvider() {
|
||||
ReportViewerProvider viewer = null;
|
||||
if (s_reportViewerProviderReference != null) {
|
||||
viewer = s_reportViewerProviderReference.getService();
|
||||
if (viewer != null)
|
||||
return viewer;
|
||||
}
|
||||
IServiceReferenceHolder<ReportViewerProvider> viewerReference = Service.locator().locate(ReportViewerProvider.class).getServiceReference();
|
||||
if (viewerReference != null) {
|
||||
s_reportViewerProviderReference = viewerReference;
|
||||
viewer = viewerReference.getService();
|
||||
}
|
||||
return viewer;
|
||||
}
|
||||
|
||||
} // ReportCtl
|
||||
|
|
|
@ -23,5 +23,9 @@ package org.compiere.print;
|
|||
*
|
||||
*/
|
||||
public interface ReportViewerProvider {
|
||||
/**
|
||||
* Open report viewer
|
||||
* @param re
|
||||
*/
|
||||
public void openViewer(ReportEngine re);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.sql.DriverManager;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
|
|
|
@ -16,5 +16,11 @@ Import-Package: org.junit.jupiter.api;version="5.6.0",
|
|||
org.junit.jupiter.params.aggregator;version="5.6.0",
|
||||
org.junit.jupiter.params.converter;version="5.6.0",
|
||||
org.junit.jupiter.params.provider;version="5.6.0",
|
||||
org.junit.jupiter.params.support;version="5.6.0"
|
||||
Require-Bundle: org.adempiere.base;bundle-version="7.1.0"
|
||||
org.junit.jupiter.params.support;version="5.6.0",
|
||||
org.osgi.framework;version="1.9.0"
|
||||
Require-Bundle: org.adempiere.base;bundle-version="7.1.0",
|
||||
org.adempiere.base.callout;bundle-version="7.1.0",
|
||||
org.adempiere.base.process;bundle-version="7.1.0",
|
||||
org.adempiere.payment.processor;bundle-version="7.1.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Activator: org.idempiere.test.TestActivator
|
||||
|
|
|
@ -480,9 +480,6 @@
|
|||
<setEntry value="org.hamcrest.core@default:default"/>
|
||||
<setEntry value="org.hamcrest.library@default:default"/>
|
||||
<setEntry value="org.hsqldb@default:default"/>
|
||||
<setEntry value="org.jacoco.agent@default:default"/>
|
||||
<setEntry value="org.jacoco.core@default:default"/>
|
||||
<setEntry value="org.jacoco.report@default:default"/>
|
||||
<setEntry value="org.jaxen@default:default"/>
|
||||
<setEntry value="org.jcodings@default:default"/>
|
||||
<setEntry value="org.jdom2@default:default"/>
|
||||
|
@ -509,16 +506,11 @@
|
|||
<setEntry value="org.mortbay.jasper.apache-el@default:default"/>
|
||||
<setEntry value="org.mortbay.jasper.apache-jsp@default:default"/>
|
||||
<setEntry value="org.mozilla.javascript@default:default"/>
|
||||
<setEntry value="org.objectweb.asm*7.0.0@default:default"/>
|
||||
<setEntry value="org.objectweb.asm*7.2.0.v20191010-1910@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.analysis@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.commons*7.0.0@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.commons*7.2.0.v20191010-1910@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.tree*7.0.0@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.tree*7.2.0.v20191010-1910@default:default"/>
|
||||
<setEntry value="org.objectweb.asm*7.3.1@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.commons*7.3.1@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.tree*7.3.1@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.tree.analysis@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.util*7.0.0@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.util*7.2.0.v20191010-1910@default:default"/>
|
||||
<setEntry value="org.objectweb.asm.util*7.3.1@default:default"/>
|
||||
<setEntry value="org.objenesis@default:default"/>
|
||||
<setEntry value="org.opentest4j@default:default"/>
|
||||
<setEntry value="org.passay@default:default"/>
|
||||
|
@ -547,7 +539,7 @@
|
|||
<setEntry value="org.adempiere.install@default:default"/>
|
||||
<setEntry value="org.adempiere.payment.processor@default:default"/>
|
||||
<setEntry value="org.adempiere.pipo.handlers@default:default"/>
|
||||
<setEntry value="org.adempiere.pipo@default:default"/>
|
||||
<setEntry value="org.adempiere.pipo@default:true"/>
|
||||
<setEntry value="org.adempiere.plugin.utils@default:default"/>
|
||||
<setEntry value="org.adempiere.report.jasper.library@default:false"/>
|
||||
<setEntry value="org.adempiere.report.jasper@default:default"/>
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test;
|
||||
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class TestActivator implements BundleActivator {
|
||||
|
||||
public static BundleContext context = null;
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
TestActivator.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
TestActivator.context = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,22 +25,99 @@
|
|||
package org.idempiere.test.performance;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.DefaultPaymentExporterFactory;
|
||||
import org.adempiere.base.IAddressValidationFactory;
|
||||
import org.adempiere.base.IBankStatementLoaderFactory;
|
||||
import org.adempiere.base.IBankStatementMatcherFactory;
|
||||
import org.adempiere.base.IColumnCallout;
|
||||
import org.adempiere.base.IDisplayTypeFactory;
|
||||
import org.adempiere.base.IPaymentExporterFactory;
|
||||
import org.adempiere.base.IReplenishFactory;
|
||||
import org.adempiere.base.IResourceFinder;
|
||||
import org.adempiere.base.LookupFactoryHelper;
|
||||
import org.adempiere.base.ServiceQuery;
|
||||
import org.adempiere.model.IAddressValidation;
|
||||
import org.adempiere.model.IShipmentProcessor;
|
||||
import org.adempiere.model.ITaxProvider;
|
||||
import org.adempiere.model.MShipperFacade;
|
||||
import org.adempiere.model.ProductPriceValidator;
|
||||
import org.compiere.acct.Doc;
|
||||
import org.compiere.acct.DocManager;
|
||||
import org.compiere.db.AdempiereDatabase;
|
||||
import org.compiere.db.Database;
|
||||
import org.compiere.impexp.BankStatementLoaderInterface;
|
||||
import org.compiere.impexp.BankStatementMatcherInterface;
|
||||
import org.compiere.impexp.OFXFileBankStatementLoader;
|
||||
import org.compiere.model.Callout;
|
||||
import org.compiere.model.GridFieldVO;
|
||||
import org.compiere.model.GridTabVO;
|
||||
import org.compiere.model.GridWindowVO;
|
||||
import org.compiere.model.IArchiveStore;
|
||||
import org.compiere.model.IAttachmentStore;
|
||||
import org.compiere.model.IImageStore;
|
||||
import org.compiere.model.I_AD_Table;
|
||||
import org.compiere.model.I_M_InventoryLine;
|
||||
import org.compiere.model.Lookup;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MAddressValidation;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MBankAccountProcessor;
|
||||
import org.compiere.model.MClientInfo;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MDocType;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MInvoiceLine;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MProduct;
|
||||
import org.compiere.model.MRefTable;
|
||||
import org.compiere.model.MShipper;
|
||||
import org.compiere.model.MStorageProvider;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.MTaxProvider;
|
||||
import org.compiere.model.MWarehouse;
|
||||
import org.compiere.model.MZoomCondition;
|
||||
import org.compiere.model.ModelValidator;
|
||||
import org.compiere.model.PaymentProcessor;
|
||||
import org.compiere.model.StandardTaxProvider;
|
||||
import org.compiere.model.X_C_AddressValidationCfg;
|
||||
import org.compiere.model.X_C_TaxProviderCfg;
|
||||
import org.compiere.process.BPartnerValidate;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
import org.compiere.process.ProcessCall;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CacheInterface;
|
||||
import org.compiere.util.CacheMgt;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.GenericPaymentExport;
|
||||
import org.compiere.util.PaymentExport;
|
||||
import org.compiere.util.ReplenishInterface;
|
||||
import org.compiere.util.TimeUtil;
|
||||
import org.compiere.wf.MWorkflow;
|
||||
import org.eevolution.model.CalloutBOM;
|
||||
import org.idempiere.fa.service.api.DepreciationFactoryLookupDTO;
|
||||
import org.idempiere.fa.service.api.IDepreciationMethod;
|
||||
import org.idempiere.fa.service.api.IDepreciationMethodFactory;
|
||||
import org.idempiere.test.AbstractTestCase;
|
||||
import org.idempiere.test.TestActivator;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
|
@ -77,22 +154,7 @@ public class CacheTest extends AbstractTestCase {
|
|||
MTable table = MTable.get(Env.getCtx(), MOrder.Table_ID);
|
||||
|
||||
//find table cache instance
|
||||
@SuppressWarnings("rawtypes")
|
||||
CCache tblCache = null;
|
||||
CacheInterface[] cis = CacheMgt.get().getInstancesAsArray();
|
||||
for(CacheInterface ci : cis) {
|
||||
if (ci instanceof CCache<?, ?>) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
CCache ccache = (CCache) ci;
|
||||
if (ccache.getName().equals(ccache.getTableName()) && ccache.getTableName().equals(MTable.Table_Name)) {
|
||||
if (ccache.containsKey(MOrder.Table_ID)) {
|
||||
tblCache = ccache;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CCache<?, ?> tblCache = findByTableNameAndKey(MTable.Table_Name, MOrder.Table_ID);
|
||||
if (tblCache == null)
|
||||
fail("Table cache instance missing");
|
||||
|
||||
|
@ -107,20 +169,7 @@ public class CacheTest extends AbstractTestCase {
|
|||
table = MTable.get(Env.getCtx(), MWarehouse.Table_ID);
|
||||
MRefTable refTable = MRefTable.get(Env.getCtx(), 197);
|
||||
|
||||
tblCache = null;
|
||||
for(CacheInterface ci : cis) {
|
||||
if (ci instanceof CCache<?, ?>) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
CCache ccache = (CCache) ci;
|
||||
if (ccache.getName().equals(ccache.getTableName()) && ccache.getTableName().equals(MTable.Table_Name)) {
|
||||
if (ccache.containsKey(MWarehouse.Table_ID)) {
|
||||
tblCache = ccache;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tblCache = findByTableNameAndKey(MTable.Table_Name, MWarehouse.Table_ID);
|
||||
if (tblCache == null)
|
||||
fail("Table cache instance missing");
|
||||
|
||||
|
@ -129,28 +178,14 @@ public class CacheTest extends AbstractTestCase {
|
|||
assertEquals(hit+1, tblCache.getHit());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@Test
|
||||
public void testPOCacheAfterUpdate() {
|
||||
int mulch = 137;
|
||||
int oak = 123;
|
||||
//init cache
|
||||
MProduct p1 = MProduct.get(Env.getCtx(), mulch);
|
||||
CCache<Integer, MProduct> pc = null;
|
||||
CacheInterface[] cis = CacheMgt.get().getInstancesAsArray();
|
||||
//find product cache instance
|
||||
for(CacheInterface ci : cis) {
|
||||
if (ci instanceof CCache<?, ?>) {
|
||||
CCache ccache = (CCache) ci;
|
||||
if (ccache.getName().equals(ccache.getTableName()) && ccache.getTableName().equals(MProduct.Table_Name)) {
|
||||
if (ccache.containsKey(mulch)) {
|
||||
pc = ccache;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CCache<Integer, MProduct> pc = (CCache<Integer, MProduct>) findByTableNameAndKey(MProduct.Table_Name, mulch);
|
||||
if (pc == null)
|
||||
fail("Product cache instance missing");
|
||||
|
||||
|
@ -214,4 +249,455 @@ public class CacheTest extends AbstractTestCase {
|
|||
|
||||
rollback();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServices() {
|
||||
//IResourceFinder
|
||||
TestActivator.context.registerService(IResourceFinder.class, new FakeResourceFinder(), null);
|
||||
IResourceFinder resourceFinder = Core.getResourceFinder();
|
||||
assertNotNull(resourceFinder, "Can't find resource finder service");
|
||||
String cacheKey = FakeResourceFinder.class.getName();
|
||||
URL url = Core.getResourceFinder().getResource(cacheKey);
|
||||
assertNotNull(url);
|
||||
String cacheName = "IResourceFinder";
|
||||
CCache<?, ?> cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
long hit = cache.getHit();
|
||||
url = Core.getResourceFinder().getResource(cacheKey);
|
||||
assertNotNull(url);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IColumnCalloutFactory
|
||||
List<IColumnCallout> callouts = Core.findCallout(I_M_InventoryLine.Table_Name, I_M_InventoryLine.COLUMNNAME_M_Product_ID);
|
||||
assertTrue(callouts.size() > 0, "Can't find callouts for " + I_M_InventoryLine.Table_Name + ", " + I_M_InventoryLine.COLUMNNAME_M_Product_ID);
|
||||
cacheKey = I_M_InventoryLine.Table_Name + "." + I_M_InventoryLine.COLUMNNAME_M_Product_ID;
|
||||
cacheName = "List<IColumnCalloutFactory>";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
callouts = Core.findCallout(I_M_InventoryLine.Table_Name, I_M_InventoryLine.COLUMNNAME_M_Product_ID);
|
||||
assertTrue(callouts.size() > 0, "Can't find callouts for " + I_M_InventoryLine.Table_Name + ", " + I_M_InventoryLine.COLUMNNAME_M_Product_ID);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//ICalloutFactory
|
||||
cacheKey = CalloutBOM.class.getName() + "::" + "parent";
|
||||
Callout callout = Core.getCallout(CalloutBOM.class.getName(), "parent");
|
||||
assertNotNull(callout, "Can't find callout for " + cacheKey);
|
||||
cacheName = "ICalloutFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
callout = Core.getCallout(CalloutBOM.class.getName(), "parent");
|
||||
assertNotNull(callout, "Can't find callout for " + cacheKey);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IProcessFactory
|
||||
cacheKey = BPartnerValidate.class.getName();
|
||||
ProcessCall process = Core.getProcess(cacheKey);
|
||||
assertNotNull(process, "Can't find process for " + cacheKey);
|
||||
cacheName = "IProcessFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
process = Core.getProcess(cacheKey);
|
||||
assertNotNull(process, "Can't find process for " + cacheKey);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IModelValidatorFactory
|
||||
cacheKey = ProductPriceValidator.class.getName();
|
||||
ModelValidator modelValidator = Core.getModelValidator(cacheKey);
|
||||
assertNotNull(modelValidator, "Can't find model validator for " + cacheKey);
|
||||
cacheName = "IModelValidatorFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
modelValidator = Core.getModelValidator(cacheKey);
|
||||
assertNotNull(modelValidator, "Can't find model validator for " + cacheKey);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IKeyStore
|
||||
assertNotNull(Core.getKeyStore(), "Can't find key store service");
|
||||
//second call to check service reference cache is working
|
||||
assertNotNull(Core.getKeyStore(), "Can't find key store service");
|
||||
|
||||
//IPaymentProcessorFactory
|
||||
int pp_payflowpro_id = 100;
|
||||
MBankAccountProcessor bankAccountProcessor = MBankAccountProcessor.get(Env.getCtx(), pp_payflowpro_id, pp_payflowpro_id, getTrxName());
|
||||
assertNotNull(bankAccountProcessor, "Can't load bank account processor for PP_PayFlowPro");
|
||||
PaymentProcessor paymentProcessor = Core.getPaymentProcessor(bankAccountProcessor, null);
|
||||
assertNotNull(paymentProcessor, "Can't load payment processor for PP_PayFlowPro");
|
||||
cacheKey = "org.compiere.model.PP_PayFlowPro";
|
||||
cacheName = "IPaymentProcessorFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
paymentProcessor = Core.getPaymentProcessor(bankAccountProcessor, null);
|
||||
assertNotNull(paymentProcessor, "Can't load payment processor for PP_PayFlowPro");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IBankStatementLoaderFactory
|
||||
TestActivator.context.registerService(IBankStatementLoaderFactory.class, new FakeBankStatementLoaderFactory(), null);
|
||||
cacheKey = OFXFileBankStatementLoader.class.getName();
|
||||
BankStatementLoaderInterface bankStatementLoader = Core.getBankStatementLoader(cacheKey);
|
||||
assertNotNull(bankStatementLoader, "Can't find BankStatementLoader for " + cacheKey);
|
||||
cacheName = "IBankStatementLoaderFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
bankStatementLoader = Core.getBankStatementLoader(cacheKey);
|
||||
assertNotNull(bankStatementLoader, "Can't find BankStatementLoader for " + cacheKey);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IBankStatementMatcherFactory
|
||||
TestActivator.context.registerService(IBankStatementMatcherFactory.class, new FakeBankStatementMatcherFactory(), null);
|
||||
cacheKey = FakeBankStatementMatcherFactory.class.getName();
|
||||
BankStatementMatcherInterface bankStatementMatcher = Core.getBankStatementMatcher(cacheKey);
|
||||
assertNotNull(bankStatementMatcher, "Can't find bank statement matcher service");
|
||||
cacheName = "IBankStatementMatcherFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
bankStatementMatcher = Core.getBankStatementMatcher(cacheKey);
|
||||
assertNotNull(bankStatementMatcher, "Can't find bank statement matcher service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IShipmentProcessorFactory
|
||||
int m_shipper_id=100;
|
||||
MShipperFacade shipperFacade = new MShipperFacade(new MShipper(Env.getCtx(), m_shipper_id, getTrxName()));
|
||||
cacheKey = shipperFacade.getShippingProcessorClass();
|
||||
cacheName = "IShipmentProcessorFactory";
|
||||
IShipmentProcessor shipmentProcessor = Core.getShipmentProcessor(shipperFacade);
|
||||
assertNotNull(shipmentProcessor, "Can't find shipment processor");
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
shipmentProcessor = Core.getShipmentProcessor(shipperFacade);
|
||||
assertNotNull(shipmentProcessor, "Can't find shipment processor");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IAddressValidationFactory
|
||||
X_C_AddressValidationCfg cfg = new X_C_AddressValidationCfg(Env.getCtx(), 0, getTrxName());
|
||||
cfg.setHostAddress("10.8.0.1");
|
||||
cfg.setHostPort(433);
|
||||
cfg.setName("Test Cfg");
|
||||
cacheKey = FakeAddressValidationFactory.class.getName();
|
||||
cfg.setAddressValidationClass(cacheKey);
|
||||
cfg.saveEx();
|
||||
MAddressValidation addressValidation = new MAddressValidation(Env.getCtx(), 0, getTrxName());
|
||||
addressValidation.setC_AddressValidationCfg_ID(cfg.get_ID());
|
||||
addressValidation.setConnectionPassword("password");
|
||||
addressValidation.setName("Test Address Validation");
|
||||
addressValidation.setUserID("userid");
|
||||
addressValidation.setSeqNo(10);
|
||||
addressValidation.saveEx();
|
||||
TestActivator.context.registerService(IAddressValidationFactory.class, new FakeAddressValidationFactory(), null);
|
||||
IAddressValidation addressValidationService = Core.getAddressValidation(addressValidation);
|
||||
assertNotNull(addressValidationService, "Can't find address validation service");
|
||||
cacheName = "IAddressValidationFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
addressValidationService = Core.getAddressValidation(addressValidation);
|
||||
assertNotNull(addressValidationService, "Can't find address validation service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//ITaxProviderFactory
|
||||
X_C_TaxProviderCfg taxProviderCfg = new X_C_TaxProviderCfg(Env.getCtx(), 0, getTrxName());
|
||||
taxProviderCfg.setName("Standard Provider Configuration");
|
||||
taxProviderCfg.setTaxProviderClass(StandardTaxProvider.class.getName());
|
||||
taxProviderCfg.saveEx();
|
||||
MTaxProvider taxProvider = new MTaxProvider(Env.getCtx(), 0, getTrxName());
|
||||
taxProvider.setC_TaxProviderCfg_ID(taxProviderCfg.get_ID());
|
||||
taxProvider.setName("Standard Provider");
|
||||
taxProvider.saveEx();
|
||||
ITaxProvider taxProviderService = Core.getTaxProvider(taxProvider);
|
||||
assertNotNull(taxProviderService, "Can't find tax provider service");
|
||||
cacheKey = StandardTaxProvider.class.getName();
|
||||
cacheName = "ITaxProviderFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
taxProviderService = Core.getTaxProvider(taxProvider);
|
||||
assertNotNull(taxProviderService, "Can't find tax provider service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IReplenishFactory
|
||||
TestActivator.context.registerService(IReplenishFactory.class, new FakeReplenishFactory(), null);
|
||||
cacheKey = FakeReplenishFactory.class.getName();
|
||||
ReplenishInterface replenishService = Core.getReplenish(cacheKey);
|
||||
assertNotNull(replenishService, "Can't find replenish service");
|
||||
cacheName = "IReplenishFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
replenishService = Core.getReplenish(cacheKey);
|
||||
assertNotNull(replenishService, "Can't find replenish service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//ScriptEngineFactory
|
||||
TestActivator.context.registerService(ScriptEngineFactory.class, new FakeScriptEngineFactory(), null);
|
||||
cacheKey = FakeScriptEngineFactory.class.getName();
|
||||
ScriptEngine scriptEngine = Core.getScriptEngine(cacheKey);
|
||||
assertNotNull(scriptEngine, "Can't find script engine service");
|
||||
cacheName = "ScriptEngineFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
scriptEngine = Core.getScriptEngine(cacheKey);
|
||||
assertNotNull(scriptEngine, "Can't find script engine service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IPaymentExporterFactory
|
||||
TestActivator.context.registerService(IPaymentExporterFactory.class, new DefaultPaymentExporterFactory(), null);
|
||||
cacheKey = GenericPaymentExport.class.getName();
|
||||
PaymentExport paymentExportService = Core.getPaymentExporter(cacheKey);
|
||||
assertNotNull(paymentExportService, "Can't find payment exporter service");
|
||||
cacheName = "IPaymentExporterFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
paymentExportService = Core.getPaymentExporter(cacheKey);
|
||||
assertNotNull(paymentExportService, "Can't find payment exporter service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IProductPricing
|
||||
assertNotNull(Core.getProductPricing(), "Can't find product pricing service");
|
||||
//second call to check service reference cache is working
|
||||
assertNotNull(Core.getProductPricing(), "Can't find product pricing service");
|
||||
|
||||
//IDepreciationMethodFactory
|
||||
TestActivator.context.registerService(IDepreciationMethodFactory.class, new FakeDepreciationMethodFactory(), null);
|
||||
cacheKey = FakeDepreciationMethodFactory.class.getName();
|
||||
DepreciationFactoryLookupDTO dto = new DepreciationFactoryLookupDTO();
|
||||
dto.depreciationType = cacheKey;
|
||||
IDepreciationMethod depreciationMethod = Core.getDepreciationMethod(dto);
|
||||
assertNotNull(depreciationMethod, "Can't find depreciation method service");
|
||||
cacheName = "IDepreciationMethodFactory";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
depreciationMethod = Core.getDepreciationMethod(dto);
|
||||
assertNotNull(depreciationMethod, "Can't find depreciation method service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IMessageService
|
||||
assertNotNull(Core.getMessageService(), "Can't find message service");
|
||||
//second call to check service reference cache is working
|
||||
assertNotNull(Core.getMessageService(), "Can't find message service");
|
||||
|
||||
//IClusterService
|
||||
assertNotNull(Core.getClusterService(), "Can't find cluster service");
|
||||
//second call to check service reference cache is working
|
||||
assertNotNull(Core.getClusterService(), "Can't find cluster service");
|
||||
|
||||
//ICacheService
|
||||
assertNotNull(Core.getCacheService(), "Can't find cache service");
|
||||
//second call to check service reference cache is working
|
||||
assertNotNull(Core.getCacheService(), "Can't find cache service");
|
||||
|
||||
//IDictionaryService
|
||||
assertNotNull(Core.getDictionaryService(), "Can't find dictionary service");
|
||||
//second call to check service reference cache is working
|
||||
assertNotNull(Core.getDictionaryService(), "Can't find dictionary service");
|
||||
|
||||
//ILookupFactory
|
||||
int ad_window_id=143; //sales order window
|
||||
int ad_tab_id=187; //sales order line
|
||||
int ad_field_id=1127; //product
|
||||
GridFieldVO gridField = null;
|
||||
Lookup lookup = null;
|
||||
GridWindowVO gridWindow = GridWindowVO.create(1, ad_window_id);
|
||||
Optional<GridTabVO> optional = gridWindow.Tabs.stream().filter(e -> e.AD_Tab_ID == ad_tab_id).findFirst();
|
||||
if (optional.isPresent()) {
|
||||
GridTabVO gridTabVO = optional.get();
|
||||
Optional<GridFieldVO> optional1 = gridTabVO.getFields().stream().filter(e -> e.AD_Field_ID == ad_field_id).findFirst();
|
||||
if (optional1.isPresent()) {
|
||||
gridField = optional1.get();
|
||||
}
|
||||
}
|
||||
assertNotNull(gridField, "Can't find grid field");
|
||||
lookup = LookupFactoryHelper.getLookup(gridField);
|
||||
assertNotNull(lookup, "Can't find lookup service");
|
||||
cacheName = "ILookupFactory";
|
||||
cacheKey = null;
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
lookup = LookupFactoryHelper.getLookup(gridField);
|
||||
assertNotNull(lookup, "Can't find lookup service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
hit = cache.getHit();
|
||||
assertTrue(LookupFactoryHelper.isLookup(gridField), "Lookup should be true for " + gridField.toString());
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IDocFactory
|
||||
int C_AcctSchema_ID = MClientInfo.get().getC_AcctSchema1_ID();
|
||||
cacheKey = C_AcctSchema_ID + "|" + MInvoice.Table_ID;
|
||||
cacheName = "IDocFactory";
|
||||
MInvoice invoice = new MInvoice(Env.getCtx(), 0, getTrxName());
|
||||
invoice.setBPartner(MBPartner.get(Env.getCtx(), 117)); // C&W
|
||||
invoice.setC_DocTypeTarget_ID(MDocType.DOCBASETYPE_ARInvoice);
|
||||
invoice.setC_DocType_ID(invoice.getC_DocTypeTarget_ID()); // required to avoid runDocumentActionWorkflow exception
|
||||
invoice.setPaymentRule(MInvoice.PAYMENTRULE_Check);
|
||||
invoice.setC_PaymentTerm_ID(105); // Immediate
|
||||
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||
invoice.setDateInvoiced(today);
|
||||
invoice.setDateAcct(today);
|
||||
invoice.setDocStatus(DocAction.STATUS_Drafted);
|
||||
invoice.setDocAction(DocAction.ACTION_Complete);
|
||||
invoice.saveEx();
|
||||
MInvoiceLine line1 = new MInvoiceLine(invoice);
|
||||
line1.setLine(10);
|
||||
line1.setC_Charge_ID(100); // Bank Charge
|
||||
line1.setQty(new BigDecimal("1"));
|
||||
line1.setPrice(Env.ONEHUNDRED);
|
||||
line1.saveEx();
|
||||
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(invoice, DocAction.ACTION_Complete);
|
||||
invoice.load(getTrxName());
|
||||
assertFalse(info.isError());
|
||||
assertEquals(DocAction.STATUS_Completed, invoice.getDocStatus());
|
||||
if (!invoice.isPosted()) {
|
||||
String error = DocumentEngine.postImmediate(Env.getCtx(), invoice.getAD_Client_ID(), MInvoice.Table_ID, invoice.get_ID(), true, getTrxName());
|
||||
assertNull(error, "Error posting invoice: " + error);
|
||||
}
|
||||
MAcctSchema as = MAcctSchema.get(C_AcctSchema_ID);
|
||||
Doc doc = DocManager.getDocument(as, MInvoice.Table_ID, invoice.get_ID(), getTrxName());
|
||||
assertNotNull(doc, "Failed load acct doc for invoice");
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
doc = DocManager.getDocument(as, MInvoice.Table_ID, invoice.get_ID(), getTrxName());
|
||||
assertNotNull(doc, "Failed load acct doc for invoice");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IDatabase
|
||||
AdempiereDatabase db = Database.getDatabase(Database.DB_POSTGRESQL);
|
||||
assertNotNull(db, "Failed to load db service for " + Database.DB_POSTGRESQL);
|
||||
cacheKey = Database.DB_POSTGRESQL;
|
||||
cacheName = "IDatabase";
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
db = Database.getDatabase(Database.DB_POSTGRESQL);
|
||||
assertNotNull(db, "Failed to load db service for " + Database.DB_POSTGRESQL);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IArchiveStore
|
||||
ServiceQuery dbServiceQuery = new ServiceQuery();
|
||||
dbServiceQuery.put("method", "DB");
|
||||
IArchiveStore archiveStoreService = MStorageProvider.getArchiveStoreService(dbServiceQuery);
|
||||
assertNotNull(archiveStoreService, "Can't find archive store service");
|
||||
cacheName = "IArchiveStore";
|
||||
cache = findByNameAndKey(cacheName, dbServiceQuery);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
archiveStoreService = MStorageProvider.getArchiveStoreService(dbServiceQuery);
|
||||
assertNotNull(archiveStoreService, "Can't find archive store service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
ServiceQuery fileSystemServiceQuery = new ServiceQuery();
|
||||
fileSystemServiceQuery.put("method", "FileSystem");
|
||||
archiveStoreService = MStorageProvider.getArchiveStoreService(fileSystemServiceQuery);
|
||||
assertNotNull(archiveStoreService, "Can't find archive store service");
|
||||
hit = cache.getHit();
|
||||
archiveStoreService = MStorageProvider.getArchiveStoreService(fileSystemServiceQuery);
|
||||
assertNotNull(archiveStoreService, "Can't find archive store service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
assertTrue(cache.size() == 2, "Size for " + cacheName + " != 2");
|
||||
|
||||
//IAttachmentStore
|
||||
IAttachmentStore attachmentStoreService = MStorageProvider.getAttachmentStoreService(dbServiceQuery);
|
||||
assertNotNull(attachmentStoreService, "Can't find attachment store service");
|
||||
cacheName = "IAttachmentStore";
|
||||
cache = findByNameAndKey(cacheName, dbServiceQuery);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
attachmentStoreService = MStorageProvider.getAttachmentStoreService(dbServiceQuery);
|
||||
assertNotNull(attachmentStoreService, "Can't find attachment store service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
attachmentStoreService = MStorageProvider.getAttachmentStoreService(fileSystemServiceQuery);
|
||||
assertNotNull(attachmentStoreService, "Can't find attachment store service");
|
||||
hit = cache.getHit();
|
||||
attachmentStoreService = MStorageProvider.getAttachmentStoreService(fileSystemServiceQuery);
|
||||
assertNotNull(attachmentStoreService, "Can't find attachment store service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
assertTrue(cache.size() == 2, "Size for " + cacheName + " != 2");
|
||||
|
||||
//IImageStore
|
||||
IImageStore imagetStoreService = MStorageProvider.getImageStoreService(dbServiceQuery);
|
||||
assertNotNull(imagetStoreService, "Can't find image store service");
|
||||
cacheName = "IImageStore";
|
||||
cache = findByNameAndKey(cacheName, dbServiceQuery);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
imagetStoreService = MStorageProvider.getImageStoreService(dbServiceQuery);
|
||||
assertNotNull(imagetStoreService, "Can't find image store service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
imagetStoreService = MStorageProvider.getImageStoreService(fileSystemServiceQuery);
|
||||
assertNotNull(imagetStoreService, "Can't find image store service");
|
||||
hit = cache.getHit();
|
||||
imagetStoreService = MStorageProvider.getImageStoreService(fileSystemServiceQuery);
|
||||
assertNotNull(imagetStoreService, "Can't find image store service");
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
assertTrue(cache.size() == 2, "Size for " + cacheName + " != 2");
|
||||
|
||||
//IModelFactory
|
||||
cacheName = "IModelFactory";
|
||||
cacheKey = MInvoice.Table_Name;
|
||||
Class<?> modelClass = MTable.getClass(cacheKey);
|
||||
assertNotNull(modelClass, "Can't find model class for " + cacheKey);
|
||||
cache = findByNameAndKey(cacheName, cacheKey);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
modelClass = MTable.getClass(cacheKey);
|
||||
assertNotNull(modelClass, "Can't find model class for " + cacheKey);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
|
||||
//IDisplayTypeFactory
|
||||
TestActivator.context.registerService(IDisplayTypeFactory.class, new FakeDisplayTypeFactory(), null);
|
||||
cacheName = "IDisplayTypeFactory";
|
||||
boolean isText = DisplayType.isText(FakeDisplayTypeFactory.DISPLAY_TYPE);
|
||||
assertTrue(isText);
|
||||
cache = findByNameAndKey(cacheName, FakeDisplayTypeFactory.DISPLAY_TYPE);
|
||||
assertNotNull(cache, "Can't find cache for " + cacheName);
|
||||
hit = cache.getHit();
|
||||
isText = DisplayType.isText(FakeDisplayTypeFactory.DISPLAY_TYPE);
|
||||
assertTrue(isText);
|
||||
assertTrue(cache.getHit() > hit, "Hit for " + cacheName + " doesn't increase as expected");
|
||||
}
|
||||
|
||||
private CCache<?, ?> findByTableNameAndKey(String tableName, Object key) {
|
||||
CacheInterface[] cis = CacheMgt.get().getInstancesAsArray();
|
||||
for(CacheInterface ci : cis) {
|
||||
if (ci instanceof CCache<?, ?>) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
CCache ccache = (CCache) ci;
|
||||
if (ccache.getName().equals(ccache.getTableName()) && ccache.getTableName().equals(tableName)) {
|
||||
if (ccache.containsKey(key)) {
|
||||
return ccache;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private CCache<?, ?> findByNameAndKey(String name, Object key) {
|
||||
CacheInterface[] cis = CacheMgt.get().getInstancesAsArray();
|
||||
for(CacheInterface ci : cis) {
|
||||
if (ci instanceof CCache<?, ?>) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
CCache ccache = (CCache) ci;
|
||||
if (ccache.getTableName() == null && ccache.getName().equals(name)) {
|
||||
if (key != null) {
|
||||
if (ccache.containsKey(key)) {
|
||||
return ccache;
|
||||
}
|
||||
} else {
|
||||
return ccache;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test.performance;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.base.IAddressValidationFactory;
|
||||
import org.adempiere.model.IAddressValidation;
|
||||
import org.compiere.model.MAddressTransaction;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class FakeAddressValidationFactory implements IAddressValidationFactory {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FakeAddressValidationFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAddressValidation newAddressValidationInstance(String className) {
|
||||
if (FakeAddressValidationFactory.class.getName().equals(className)) {
|
||||
return new IAddressValidation() {
|
||||
@Override
|
||||
public boolean onlineValidate(Properties ctx, MAddressTransaction addressTransaction, String trxName) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test.performance;
|
||||
|
||||
import org.adempiere.base.IBankStatementLoaderFactory;
|
||||
import org.compiere.impexp.BankStatementLoaderInterface;
|
||||
import org.compiere.impexp.OFXFileBankStatementLoader;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class FakeBankStatementLoaderFactory implements IBankStatementLoaderFactory {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FakeBankStatementLoaderFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankStatementLoaderInterface newBankStatementLoaderInstance(String className) {
|
||||
if (OFXFileBankStatementLoader.class.getName().equals(className))
|
||||
return new OFXFileBankStatementLoader();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test.performance;
|
||||
|
||||
import org.adempiere.base.IBankStatementMatcherFactory;
|
||||
import org.compiere.impexp.BankStatementMatchInfo;
|
||||
import org.compiere.impexp.BankStatementMatcherInterface;
|
||||
import org.compiere.model.MBankStatementLine;
|
||||
import org.compiere.model.X_I_BankStatement;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class FakeBankStatementMatcherFactory implements IBankStatementMatcherFactory {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FakeBankStatementMatcherFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankStatementMatcherInterface newBankStatementMatcherInstance(String className) {
|
||||
if (FakeBankStatementMatcherFactory.class.getName().equals(className)) {
|
||||
return new BankStatementMatcherInterface() {
|
||||
|
||||
@Override
|
||||
public BankStatementMatchInfo findMatch(X_I_BankStatement ibs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankStatementMatchInfo findMatch(MBankStatementLine bsl) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test.performance;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.idempiere.fa.service.api.DepreciationDTO;
|
||||
import org.idempiere.fa.service.api.DepreciationFactoryLookupDTO;
|
||||
import org.idempiere.fa.service.api.IDepreciationMethod;
|
||||
import org.idempiere.fa.service.api.IDepreciationMethodFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class FakeDepreciationMethodFactory implements IDepreciationMethodFactory {
|
||||
|
||||
public FakeDepreciationMethodFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDepreciationMethod getDepreciationMethod(DepreciationFactoryLookupDTO factoryLookupDTO) {
|
||||
if (FakeDepreciationMethodFactory.class.getName().equals(factoryLookupDTO.depreciationType)) {
|
||||
return new IDepreciationMethod() {
|
||||
|
||||
@Override
|
||||
public BigDecimal caclulateDepreciation(DepreciationDTO depreciationDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCountPeriod(DepreciationDTO depreciationDTO) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPeriodAdjustment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package org.idempiere.test.performance;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.adempiere.base.IDisplayTypeFactory;
|
||||
import org.compiere.util.Language;
|
||||
|
||||
public class FakeDisplayTypeFactory implements IDisplayTypeFactory {
|
||||
|
||||
public final static int DISPLAY_TYPE = 9876543;
|
||||
|
||||
public FakeDisplayTypeFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isID(int displayType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNumeric(int displayType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDefaultPrecision(int displayType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isText(int displayType) {
|
||||
if (displayType == DISPLAY_TYPE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDate(int displayType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLookup(int displayType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLOB(int displayType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecimalFormat getNumberFormat(int displayType, Language language, String pattern) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleDateFormat getDateFormat(int displayType, Language language, String pattern) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getClass(int displayType, boolean yesNoAsBoolean) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLDataType(int displayType, String columnName, int fieldLength) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(int displayType) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test.performance;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.adempiere.base.IReplenishFactory;
|
||||
import org.compiere.model.MWarehouse;
|
||||
import org.compiere.model.X_T_Replenish;
|
||||
import org.compiere.util.ReplenishInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class FakeReplenishFactory implements IReplenishFactory {
|
||||
|
||||
public FakeReplenishFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplenishInterface newReplenishInstance(String className) {
|
||||
if (FakeReplenishFactory.class.getName().equals(className)) {
|
||||
return new ReplenishInterface() {
|
||||
|
||||
@Override
|
||||
public BigDecimal getQtyToOrder(MWarehouse wh, X_T_Replenish replenish) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test.performance;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.adempiere.base.IResourceFinder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class FakeResourceFinder implements IResourceFinder {
|
||||
|
||||
public FakeResourceFinder() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
if (getClass().getName().equals(name)) {
|
||||
try {
|
||||
return new URL("file:///TestResourceFinder.txt");
|
||||
} catch (MalformedURLException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - hengsin *
|
||||
**********************************************************************/
|
||||
package org.idempiere.test.performance;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class FakeScriptEngineFactory implements ScriptEngineFactory {
|
||||
|
||||
public FakeScriptEngineFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEngineName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEngineVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getExtensions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMimeTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNames() {
|
||||
return Arrays.asList(FakeScriptEngineFactory.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParameter(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodCallSyntax(String obj, String m, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputStatement(String toDisplay) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProgram(String... statements) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptEngine getScriptEngine() {
|
||||
return new ScriptEngine() {
|
||||
|
||||
@Override
|
||||
public void setContext(ScriptContext context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBindings(Bindings bindings, int scope) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, Object value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptEngineFactory getFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptContext getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bindings getBindings(int scope) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object eval(Reader reader, Bindings n) throws ScriptException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object eval(String script, Bindings n) throws ScriptException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object eval(Reader reader, ScriptContext context) throws ScriptException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object eval(String script, ScriptContext context) throws ScriptException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object eval(Reader reader) throws ScriptException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object eval(String script) throws ScriptException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bindings createBindings() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue