IDEMPIERE-1655 no OSGi interface for a BankStatementMatcher
This commit is contained in:
parent
7950090c64
commit
eb3491f826
|
@ -30,6 +30,7 @@ import org.adempiere.model.IShipmentProcessor;
|
||||||
import org.adempiere.model.ITaxProvider;
|
import org.adempiere.model.ITaxProvider;
|
||||||
import org.adempiere.model.MShipperFacade;
|
import org.adempiere.model.MShipperFacade;
|
||||||
import org.compiere.impexp.BankStatementLoaderInterface;
|
import org.compiere.impexp.BankStatementLoaderInterface;
|
||||||
|
import org.compiere.impexp.BankStatementMatcherInterface;
|
||||||
import org.compiere.model.MAddressValidation;
|
import org.compiere.model.MAddressValidation;
|
||||||
import org.compiere.model.MBankAccountProcessor;
|
import org.compiere.model.MBankAccountProcessor;
|
||||||
import org.compiere.model.MPaymentProcessor;
|
import org.compiere.model.MPaymentProcessor;
|
||||||
|
@ -210,6 +211,40 @@ public class Core {
|
||||||
return myBankStatementLoader;
|
return myBankStatementLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get BankStatementMatcher instance
|
||||||
|
*
|
||||||
|
* @param className
|
||||||
|
* @return instance of the BankStatementMatcherInterface or null
|
||||||
|
*/
|
||||||
|
public static BankStatementMatcherInterface getBankStatementMatcher(String className){
|
||||||
|
if (className == null || className.length() == 0) {
|
||||||
|
s_log.log(Level.SEVERE, "No BankStatementMatcherInterface class name");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
myBankStatementMatcher = matcher;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myBankStatementMatcher == null) {
|
||||||
|
s_log.log(Level.SEVERE, "Not found in service/extension registry and classpath");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return myBankStatementMatcher;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param sf
|
* @param sf
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.base;
|
||||||
|
|
||||||
|
import org.compiere.impexp.BankStatementMatcherInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory Interface for plugins to connect to the iDempiere core and provide a
|
||||||
|
* way to match Bank statements
|
||||||
|
*
|
||||||
|
* @author tsvikruha, inspired by tbayen IBankStatementLoaderFactory
|
||||||
|
*/
|
||||||
|
public interface IBankStatementMatcherFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class will be implemented in OSGi plugins. Every plugin that
|
||||||
|
* provides this service may or may not provide an BankStatementMatcher
|
||||||
|
* depending on the given classname. By convention this classname is
|
||||||
|
* the fully qualified classname of the Loader class you want to use.
|
||||||
|
*
|
||||||
|
* @param className
|
||||||
|
* @return BankStatementMatcher instance
|
||||||
|
*/
|
||||||
|
public BankStatementMatcherInterface newBankStatementMatcherInstance(String className);
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.base.Core;
|
||||||
import org.compiere.impexp.BankStatementMatcherInterface;
|
import org.compiere.impexp.BankStatementMatcherInterface;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
@ -134,8 +135,14 @@ public class MBankStatementMatcher extends X_C_BankStatementMatcher
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class<?> matcherClass = Class.forName(className);
|
if (log.isLoggable(Level.INFO)) log.info( "MBankStatementMatch Class Name=" + className);
|
||||||
m_matcher = (BankStatementMatcherInterface)matcherClass.newInstance();
|
// load the BankStatementMatcher class via OSGi Service definition from a plugin
|
||||||
|
m_matcher = Core.getBankStatementMatcher(className);
|
||||||
|
if(m_matcher==null){
|
||||||
|
// if no OSGi plugin is found try the legacy way (in my own classpath)
|
||||||
|
Class<?> bsrClass = Class.forName(className);
|
||||||
|
m_matcher = (BankStatementMatcherInterface) bsrClass.newInstance();
|
||||||
|
}
|
||||||
m_matcherValid = Boolean.TRUE;
|
m_matcherValid = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
Loading…
Reference in New Issue