IDEMPIERE-359 Add OSGi Service support for existing extension point. Added process factory interface.
This commit is contained in:
parent
f0cac5bd82
commit
fb883fd47c
|
@ -24,6 +24,7 @@ import java.net.URL;
|
|||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MBankAccountProcessor;
|
||||
import org.compiere.model.MPaymentProcessor;
|
||||
import org.compiere.model.ModelValidator;
|
||||
import org.compiere.model.PaymentInterface;
|
||||
|
@ -80,7 +81,16 @@ public class Core {
|
|||
* @return ProcessCall instance or null if serviceId not found
|
||||
*/
|
||||
public static ProcessCall getProcess(String serviceId) {
|
||||
return Service.locator().locate(ProcessCall.class, "org.adempiere.base.Process", serviceId, null).getService();
|
||||
ProcessCall process = null;
|
||||
List<IProcessFactory> factories = Service.locator().list(IProcessFactory.class).getServices();
|
||||
if (factories != null && !factories.isEmpty()) {
|
||||
for(IProcessFactory factory : factories) {
|
||||
process = factory.newProcessInstance(serviceId);
|
||||
if (process != null)
|
||||
return process;
|
||||
}
|
||||
}
|
||||
return Service.locator().locate(ProcessCall.class, "org.adempiere.base.Process", serviceId, null).getService();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,17 +104,18 @@ public class Core {
|
|||
|
||||
/**
|
||||
* Get payment processor instance
|
||||
* @param mpp payment processor model
|
||||
* @param mbap payment processor model
|
||||
* @param mp payment model
|
||||
* @return initialized PaymentProcessor or null
|
||||
*/
|
||||
public static PaymentProcessor getPaymentProcessor(MPaymentProcessor mpp, PaymentInterface mp) {
|
||||
public static PaymentProcessor getPaymentProcessor(MBankAccountProcessor mbap, PaymentInterface mp) {
|
||||
if (s_log.isLoggable(Level.FINE))
|
||||
s_log.fine("create for " + mpp);
|
||||
s_log.fine("create for " + mbap);
|
||||
|
||||
MPaymentProcessor mpp = new MPaymentProcessor(mbap.getCtx(), mbap.getC_PaymentProcessor_ID(), mbap.get_TrxName());
|
||||
String className = mpp.getPayProcessorClass();
|
||||
if (className == null || className.length() == 0) {
|
||||
s_log.log(Level.SEVERE, "No PaymentProcessor class name in " + mpp);
|
||||
s_log.log(Level.SEVERE, "No PaymentProcessor class name in " + mbap);
|
||||
return null;
|
||||
}
|
||||
//
|
||||
|
@ -130,7 +141,7 @@ public class Core {
|
|||
}
|
||||
|
||||
// Initialize
|
||||
myProcessor.initialize(mpp, mp);
|
||||
myProcessor.initialize(mbap, mp);
|
||||
//
|
||||
return myProcessor;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Heng Sin Low *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.base;
|
||||
|
||||
import org.compiere.process.ProcessCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IProcessFactory {
|
||||
|
||||
/**
|
||||
* Create new process instance
|
||||
* @param className
|
||||
* @return new process instance
|
||||
*/
|
||||
public ProcessCall newProcessInstance(String className);
|
||||
|
||||
}
|
|
@ -57,4 +57,4 @@ Bundle-Activator: org.adempiere.webui.WebUIActivator
|
|||
Eclipse-ExtensibleAPI: true
|
||||
Eclipse-RegisterBuddy: org.zkoss.zk.library
|
||||
Web-ContextPath: webui
|
||||
Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml, OSGI-INF/defaultpaymentformfactory.xml
|
||||
Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml, OSGI-INF/defaultpaymentformfactory.xml, OSGI-INF/processfactory.xml
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.process.factory">
|
||||
<implementation class="org.adempiere.webui.util.ProcessFactoryImpl"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IProcessFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,45 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Heng Sin Low *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.util;
|
||||
|
||||
import org.adempiere.base.IProcessFactory;
|
||||
import org.compiere.process.ProcessCall;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class ProcessFactoryImpl implements IProcessFactory {
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
public ProcessFactoryImpl() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.base.IProcessFactory#newProcessInstance(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ProcessCall newProcessInstance(String className) {
|
||||
ProcessCall process = null;
|
||||
try {
|
||||
Class<?> clazz = getClass().getClassLoader().loadClass(className);
|
||||
process = (ProcessCall) clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +1,53 @@
|
|||
output.. = WEB-INF/classes/
|
||||
bin.includes = META-INF/,\
|
||||
WEB-INF/,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
timeout.zul,\
|
||||
plugin.xml,\
|
||||
WEB-INF/classes/,\
|
||||
WEB-INF/lib/atmosphere-runtime-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\
|
||||
metainfo/,\
|
||||
WEB-INF/lib/calendar.jar,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul,\
|
||||
OSGI-INF/,\
|
||||
OSGI-INF/reportviewerprovider.xml,\
|
||||
OSGI-INF/defaultinfofactory.xml,\
|
||||
OSGI-INF/defaulteditorfactory.xml,\
|
||||
OSGI-INF/jrviewerprovider.xml,\
|
||||
OSGI-INF/resourcefinder.xml,\
|
||||
OSGI-INF/defaultpaymentformfactory.xml
|
||||
src.includes = WEB-INF/classes/,\
|
||||
WEB-INF/tld/,\
|
||||
WEB-INF/web.xml,\
|
||||
WEB-INF/xsd/,\
|
||||
WEB-INF/zk.xml,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
metainfo/,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul
|
||||
source.. = WEB-INF/src/
|
||||
bin.excludes = WEB-INF/src/,\
|
||||
WEB-INF/web-2.5.xml
|
||||
output.. = WEB-INF/classes/
|
||||
bin.includes = META-INF/,\
|
||||
WEB-INF/,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
timeout.zul,\
|
||||
plugin.xml,\
|
||||
WEB-INF/classes/,\
|
||||
WEB-INF/lib/atmosphere-runtime-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\
|
||||
metainfo/,\
|
||||
WEB-INF/lib/calendar.jar,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul,\
|
||||
OSGI-INF/,\
|
||||
OSGI-INF/reportviewerprovider.xml,\
|
||||
OSGI-INF/defaultinfofactory.xml,\
|
||||
OSGI-INF/defaulteditorfactory.xml,\
|
||||
OSGI-INF/jrviewerprovider.xml,\
|
||||
OSGI-INF/resourcefinder.xml,\
|
||||
OSGI-INF/defaultpaymentformfactory.xml,\
|
||||
OSGI-INF/processfactory.xml
|
||||
src.includes = WEB-INF/classes/,\
|
||||
WEB-INF/tld/,\
|
||||
WEB-INF/web.xml,\
|
||||
WEB-INF/xsd/,\
|
||||
WEB-INF/zk.xml,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
metainfo/,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul
|
||||
source.. = WEB-INF/src/
|
||||
bin.excludes = WEB-INF/src/,\
|
||||
WEB-INF/web-2.5.xml
|
||||
|
|
Loading…
Reference in New Issue