IDEMPIERE-2485 Missing OSGi Factory for Replenish Interface
This commit is contained in:
parent
825c5e4941
commit
423d803b3f
|
@ -24,6 +24,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.base.Core;
|
||||||
import org.compiere.model.MBPartner;
|
import org.compiere.model.MBPartner;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MDocType;
|
import org.compiere.model.MDocType;
|
||||||
|
@ -351,9 +352,13 @@ public class ReplenishReport extends SvrProcess
|
||||||
ReplenishInterface custom = null;
|
ReplenishInterface custom = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
custom = Core.getReplenish(className);
|
||||||
|
if(custom==null){
|
||||||
|
// if no OSGi plugin is found try the legacy way (in my own classpath)
|
||||||
Class<?> clazz = Class.forName(className);
|
Class<?> clazz = Class.forName(className);
|
||||||
custom = (ReplenishInterface) clazz.newInstance();
|
custom = (ReplenishInterface) clazz.newInstance();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new AdempiereUserError("No custom Replenishment class "
|
throw new AdempiereUserError("No custom Replenishment class "
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.base.Core;
|
||||||
import org.compiere.model.MBPartner;
|
import org.compiere.model.MBPartner;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MDocType;
|
import org.compiere.model.MDocType;
|
||||||
|
@ -385,9 +386,13 @@ public class ReplenishReportProduction extends SvrProcess
|
||||||
ReplenishInterface custom = null;
|
ReplenishInterface custom = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
custom = Core.getReplenish(className);
|
||||||
|
if(custom==null){
|
||||||
|
// if no OSGi plugin is found try the legacy way (in my own classpath)
|
||||||
Class<?> clazz = Class.forName(className);
|
Class<?> clazz = Class.forName(className);
|
||||||
custom = (ReplenishInterface) clazz.newInstance();
|
custom = (ReplenishInterface) clazz.newInstance();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new AdempiereUserError("No custom Replenishment class "
|
throw new AdempiereUserError("No custom Replenishment class "
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.compiere.model.PaymentProcessor;
|
||||||
import org.compiere.model.StandardTaxProvider;
|
import org.compiere.model.StandardTaxProvider;
|
||||||
import org.compiere.process.ProcessCall;
|
import org.compiere.process.ProcessCall;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.ReplenishInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a facade class for the Service Locator.
|
* This is a facade class for the Service Locator.
|
||||||
|
@ -304,4 +305,38 @@ public class Core {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Custom Replenish instance
|
||||||
|
*
|
||||||
|
* @param className
|
||||||
|
* @return instance of the ReplenishInterface or null
|
||||||
|
*/
|
||||||
|
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) {
|
||||||
|
myReplenishInstance = loader;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myReplenishInstance == null) {
|
||||||
|
s_log.log(Level.SEVERE, "Not found in service/extension registry and classpath");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return myReplenishInstance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.adempiere.base;
|
||||||
|
|
||||||
|
import org.compiere.util.ReplenishInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory Interface for plugins to connect to the iDempiere core and provide a
|
||||||
|
* way to load Replication Custom Interface.
|
||||||
|
*
|
||||||
|
* @author tsvikruha
|
||||||
|
*/
|
||||||
|
public interface IReplenishFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param className
|
||||||
|
* @return Replenish instance
|
||||||
|
*/
|
||||||
|
public ReplenishInterface newReplenishInstance(String className);
|
||||||
|
}
|
Loading…
Reference in New Issue