From 2dfa60b73ea50fbeee2c3d065237f769d8ba08c2 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 6 Nov 2012 11:39:23 +0800 Subject: [PATCH] IDEMPIERE-359 Add OSGi Service support for existing extension point --- org.adempiere.base/META-INF/MANIFEST.MF | 4 +- org.adempiere.base/OSGI-INF/dslocator.xml | 8 + .../OSGI-INF/extensionlocator.xml | 8 + org.adempiere.base/OSGI-INF/serverbean.xml | 7 + org.adempiere.base/OSGI-INF/statusbean.xml | 7 + org.adempiere.base/build.properties | 8 +- .../src/org/adempiere/base/BaseActivator.java | 49 +++++ .../src/org/adempiere/base/Core.java | 37 ++-- .../base/DelegatingServiceHolder.java | 64 +++++++ .../base/DelegatingServiceLocator.java | 181 ++++++++++++++++++ .../org/adempiere/base/IServiceHolder.java | 30 +++ .../org/adempiere/base/IServiceLocator.java | 96 ++++++++-- .../org/adempiere/base/IServicesHolder.java | 32 ++++ .../src/org/adempiere/base/Service.java | 65 +------ .../src/org/adempiere/base/ServiceQuery.java | 11 +- .../base/ds/DynamicServiceHolder.java | 63 ++++++ .../base/ds/DynamicServiceLocator.java | 166 ++++++++++++++++ .../base/equinox/EquinoxServiceHolder.java | 46 +++++ .../base/equinox/EquinoxServiceLocator.java | 56 ++++-- .../adempiere/base/equinox/ExtensionList.java | 48 +++-- .../src/org/compiere/acct/DocManager.java | 8 +- .../src/org/compiere/db/CConnection.java | 6 +- .../src/org/compiere/db/Database.java | 2 +- .../src/org/compiere/model/GridTab.java | 2 +- .../src/org/compiere/model/MTable.java | 6 +- .../compiere/install/ConfigurationData.java | 2 +- .../adempiere/pipo2/OSGiHandlerRegistry.java | 6 +- .../plugin/utils/AdempiereActivator.java | 2 +- .../org/compiere/report/ReportStarter.java | 2 +- .../compiere/server/AdempiereServerMgr.java | 2 +- .../src/org/adempiere/client/Client.java | 4 +- .../src/org/adempiere/client/InfoManager.java | 4 +- .../src/org/compiere/apps/AExport.java | 2 +- .../org/compiere/grid/ed/VEditorFactory.java | 2 +- .../ui/zk/example/action/ExportAction.java | 2 +- org.adempiere.ui.zk/META-INF/MANIFEST.MF | 3 +- .../OSGI-INF/defaulteditorfactory.xml | 7 + .../OSGI-INF/defaultinfofactory.xml | 7 + .../OSGI-INF/jrviewerprovider.xml | 7 + .../OSGI-INF/reportviewerprovider.xml | 7 + .../OSGI-INF/resourcefinder.xml | 7 + .../src/org/adempiere/webui/Extensions.java | 4 +- .../org/adempiere/webui/action/Actions.java | 44 ++--- .../webui/adwindow/ADWindowToolbar.java | 6 +- .../webui/adwindow/ToolbarCustomButton.java | 8 +- .../webui/editor/WebEditorFactory.java | 5 +- .../adempiere/webui/factory/InfoManager.java | 4 +- .../webui/panel/action/ExportAction.java | 2 +- .../webui/panel/action/FileImportAction.java | 2 +- org.adempiere.ui.zk/build.properties | 9 +- org.adempiere.ui.zk/plugin.xml | 49 ----- .../src/org/compiere/print/ReportCtl.java | 2 +- 52 files changed, 945 insertions(+), 266 deletions(-) create mode 100644 org.adempiere.base/OSGI-INF/dslocator.xml create mode 100644 org.adempiere.base/OSGI-INF/extensionlocator.xml create mode 100644 org.adempiere.base/OSGI-INF/serverbean.xml create mode 100644 org.adempiere.base/OSGI-INF/statusbean.xml create mode 100644 org.adempiere.base/src/org/adempiere/base/DelegatingServiceHolder.java create mode 100644 org.adempiere.base/src/org/adempiere/base/DelegatingServiceLocator.java create mode 100644 org.adempiere.base/src/org/adempiere/base/IServiceHolder.java create mode 100644 org.adempiere.base/src/org/adempiere/base/IServicesHolder.java create mode 100644 org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceHolder.java create mode 100644 org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceLocator.java create mode 100644 org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceHolder.java create mode 100644 org.adempiere.ui.zk/OSGI-INF/defaulteditorfactory.xml create mode 100644 org.adempiere.ui.zk/OSGI-INF/defaultinfofactory.xml create mode 100644 org.adempiere.ui.zk/OSGI-INF/jrviewerprovider.xml create mode 100644 org.adempiere.ui.zk/OSGI-INF/reportviewerprovider.xml create mode 100644 org.adempiere.ui.zk/OSGI-INF/resourcefinder.xml diff --git a/org.adempiere.base/META-INF/MANIFEST.MF b/org.adempiere.base/META-INF/MANIFEST.MF index 63c5db283d..04737eb512 100644 --- a/org.adempiere.base/META-INF/MANIFEST.MF +++ b/org.adempiere.base/META-INF/MANIFEST.MF @@ -279,7 +279,9 @@ Import-Package: com.sun.mail.auth;version="1.4.5", org.eclipse.osgi.framework.console;version="1.1.0", org.eclipse.osgi.service.datalocation, org.osgi.framework, + org.osgi.service.component;version="1.1.0", org.osgi.service.event;version="1.2.0", + org.osgi.util.tracker;version="1.5.0", org.restlet, org.restlet.data, org.restlet.representation, @@ -287,6 +289,6 @@ Import-Package: com.sun.mail.auth;version="1.4.5", Eclipse-BuddyPolicy: registered Eclipse-ExtensibleAPI: true Bundle-Activator: org.adempiere.base.BaseActivator -Service-Component: OSGI-INF/eventmanager.xml +Service-Component: OSGI-INF/eventmanager.xml, OSGI-INF/dslocator.xml, OSGI-INF/extensionlocator.xml, OSGI-INF/serverbean.xml, OSGI-INF/statusbean.xml Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.equinox.app;bundle-version="1.3.1" diff --git a/org.adempiere.base/OSGI-INF/dslocator.xml b/org.adempiere.base/OSGI-INF/dslocator.xml new file mode 100644 index 0000000000..c318b703fb --- /dev/null +++ b/org.adempiere.base/OSGI-INF/dslocator.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.base/OSGI-INF/extensionlocator.xml b/org.adempiere.base/OSGI-INF/extensionlocator.xml new file mode 100644 index 0000000000..4134d186fd --- /dev/null +++ b/org.adempiere.base/OSGI-INF/extensionlocator.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.base/OSGI-INF/serverbean.xml b/org.adempiere.base/OSGI-INF/serverbean.xml new file mode 100644 index 0000000000..201af98d9b --- /dev/null +++ b/org.adempiere.base/OSGI-INF/serverbean.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.base/OSGI-INF/statusbean.xml b/org.adempiere.base/OSGI-INF/statusbean.xml new file mode 100644 index 0000000000..5528079e58 --- /dev/null +++ b/org.adempiere.base/OSGI-INF/statusbean.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.base/build.properties b/org.adempiere.base/build.properties index b6a4bb78c8..35345f99c3 100644 --- a/org.adempiere.base/build.properties +++ b/org.adempiere.base/build.properties @@ -16,7 +16,11 @@ bin.includes = META-INF/,\ groovy-all-1.7.5.jar,\ vt-dictionary-3.0.jar,\ vt-password-3.1.1.jar,\ - super-csv-2.0.0-beta-1.jar + super-csv-2.0.0-beta-1.jar,\ + OSGI-INF/dslocator.xml,\ + OSGI-INF/extensionlocator.xml,\ + OSGI-INF/serverbean.xml,\ + OSGI-INF/statusbean.xml output.base.jar = build/ -source.base.jar = src/ src.includes = schema/ +source.base.jar = src/ diff --git a/org.adempiere.base/src/org/adempiere/base/BaseActivator.java b/org.adempiere.base/src/org/adempiere/base/BaseActivator.java index 12f9897050..0096e386f9 100644 --- a/org.adempiere.base/src/org/adempiere/base/BaseActivator.java +++ b/org.adempiere.base/src/org/adempiere/base/BaseActivator.java @@ -23,6 +23,8 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; import org.adempiere.base.equinox.StackTraceCommand; @@ -30,6 +32,8 @@ import org.compiere.Adempiere; import org.eclipse.osgi.framework.console.CommandProvider; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; +import org.osgi.util.tracker.ServiceTracker; /** * @author hengsin @@ -102,10 +106,55 @@ public class BaseActivator implements BundleActivator { @Override public void stop(BundleContext context) throws Exception { bundleContext = null; + for(Map> cacheMap : trackerCache.values()) { + for(ServiceTracker cacheTracker : cacheMap.values()) { + if (cacheTracker.getTrackingCount() != -1) { + cacheTracker.close(); + } + } + } + trackerCache.clear(); Adempiere.stop(); } + /** + * @return bundle context + */ public static BundleContext getBundleContext() { return bundleContext; } + + private static Map>> trackerCache = new HashMap>>(); + + @SuppressWarnings("unchecked") + /** + * @param type + * @param filter + * @return service tracker + */ + public static ServiceTracker getServiceTracker(Class type, Filter filter) { + ServiceTracker tracker = null; + String className = type.getName(); + Map> cacheMap = null; + synchronized (trackerCache) { + cacheMap = trackerCache.get(className); + if (cacheMap == null) { + cacheMap = new HashMap>(); + trackerCache.put(className, cacheMap); + } + } + + String filterKey = filter.toString(); + synchronized (cacheMap) { + ServiceTracker cacheTracker = cacheMap.get(filterKey); + if (cacheTracker == null) { + tracker = new ServiceTracker(bundleContext, filter, null); + cacheMap.put(filterKey, tracker); + } else { + tracker = (ServiceTracker) cacheTracker; + } + } + + return tracker; + } } diff --git a/org.adempiere.base/src/org/adempiere/base/Core.java b/org.adempiere.base/src/org/adempiere/base/Core.java index cba5b182c9..b40e2c3a3f 100644 --- a/org.adempiere.base/src/org/adempiere/base/Core.java +++ b/org.adempiere.base/src/org/adempiere/base/Core.java @@ -49,7 +49,7 @@ public class Core { return new IResourceFinder() { public URL getResource(String name) { - List f = Service.list(IResourceFinder.class); + List f = Service.locator().list(IResourceFinder.class).getServices(); for (IResourceFinder finder : f) { URL url = finder.getResource(name); if (url!=null) @@ -71,39 +71,37 @@ public class Core { query.put("tableName", tableName); query.put("columnName", columnName); - return Service.list(IColumnCallout.class, query); + return Service.locator().list(IColumnCallout.class, query).getServices(); } /** * - * @param extensionId - * @return ProcessCall instance or null if extensionId not found + * @param serviceId + * @return ProcessCall instance or null if serviceId not found */ - public static ProcessCall getProcess(String extensionId) { - ServiceQuery query = new ServiceQuery(); - query.put(ServiceQuery.EXTENSION_ID, extensionId); - return Service.locate(ProcessCall.class, "org.adempiere.base.Process", query); + public static ProcessCall getProcess(String serviceId) { + return Service.locator().locate(ProcessCall.class, "org.adempiere.base.Process", serviceId, null).getService(); } /** * - * @param extensionId - * @return ModelValidator instance of null if extensionId not found + * @param serviceId + * @return ModelValidator instance of null if serviceId not found */ - public static ModelValidator getModelValidator(String extensionId) { - ServiceQuery query = new ServiceQuery(); - query.put(ServiceQuery.EXTENSION_ID, extensionId); - return Service.locate(ModelValidator.class, "org.adempiere.base.ModelValidator", query); + public static ModelValidator getModelValidator(String serviceId) { + return Service.locator().locate(ModelValidator.class, "org.adempiere.base.ModelValidator", serviceId, null).getService(); } /** - * Factory + * Get payment processor instance * @param mpp payment processor model * @param mp payment model * @return initialized PaymentProcessor or null */ public static PaymentProcessor getPaymentProcessor(MPaymentProcessor mpp, PaymentInterface mp) { - s_log.info("create for " + mpp); + if (s_log.isLoggable(Level.FINE)) + s_log.fine("create for " + mpp); + String className = mpp.getPayProcessorClass(); if (className == null || className.length() == 0) { s_log.log(Level.SEVERE, "No PaymentProcessor class name in " + mpp); @@ -111,10 +109,9 @@ public class Core { } // PaymentProcessor myProcessor = null; - ServiceQuery query = new ServiceQuery(); - query.put(ServiceQuery.EXTENSION_ID, className); - myProcessor = Service.locate(PaymentProcessor.class, query); + myProcessor = Service.locator().locate(PaymentProcessor.class, className, null).getService(); if (myProcessor == null) { + //fall back to dynamic java class loadup try { Class ppClass = Class.forName(className); if (ppClass != null) @@ -128,7 +125,7 @@ public class Core { } } if (myProcessor == null) { - s_log.log(Level.SEVERE, "Not found in extension registry and classpath"); + s_log.log(Level.SEVERE, "Not found in service/extension registry and classpath"); return null; } diff --git a/org.adempiere.base/src/org/adempiere/base/DelegatingServiceHolder.java b/org.adempiere.base/src/org/adempiere/base/DelegatingServiceHolder.java new file mode 100644 index 0000000000..7f085ea393 --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/DelegatingServiceHolder.java @@ -0,0 +1,64 @@ +/****************************************************************************** + * 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 java.util.ArrayList; +import java.util.List; + +/** + * @author hengsin + * + */ +public class DelegatingServiceHolder implements IServiceHolder, + IServicesHolder { + + private List> serviceHolder = new ArrayList>(); + private List> servicesHolder = new ArrayList>(); + + /** + * + */ + public DelegatingServiceHolder() { + } + + public void addServiceHolder(IServiceHolder holder) { + serviceHolder.add(holder); + } + + public void addServicesHolder(IServicesHolder holder) { + servicesHolder.add(holder); + } + + @Override + public List getServices() { + List list = new ArrayList(); + for(IServicesHolder holder : servicesHolder) { + List t = holder.getServices(); + if (t != null && !t.isEmpty()) + list.addAll(t); + } + return list; + } + + @Override + public T getService() { + T t = null; + for(IServiceHolder holder : serviceHolder) { + t = holder.getService(); + if (t != null) break; + } + return t; + } + +} diff --git a/org.adempiere.base/src/org/adempiere/base/DelegatingServiceLocator.java b/org.adempiere.base/src/org/adempiere/base/DelegatingServiceLocator.java new file mode 100644 index 0000000000..8375376036 --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/DelegatingServiceLocator.java @@ -0,0 +1,181 @@ +/****************************************************************************** + * 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 java.util.List; + +import org.adempiere.base.ds.DynamicServiceLocator; + +/** + * Delegate to available service locator + * @author hengsin + * + */ +public class DelegatingServiceLocator implements IServiceLocator { + + private IServicesHolder locatorsHolder; + + public DelegatingServiceLocator() { + DynamicServiceLocator serviceLocator = new DynamicServiceLocator(); + locatorsHolder = serviceLocator.list(IServiceLocator.class); + } + + private IServiceLocator[] getLocators() { + List locators = locatorsHolder.getServices(); + return locators.toArray(new IServiceLocator[0]); + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class) + */ + @Override + public IServiceHolder locate(Class type) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServiceHolder t = locator.locate(type); + if (t != null) + holder.addServiceHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, java.lang.String) + */ + @Override + public IServiceHolder locate(Class type, String serviceType) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServiceHolder t = locator.locate(type, serviceType); + if (t != null) + holder.addServiceHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, org.adempiere.base.ServiceQuery) + */ + @Override + public IServiceHolder locate(Class type, ServiceQuery query) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServiceHolder t = locator.locate(type, query); + if (t != null) + holder.addServiceHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServiceHolder locate(Class type, String serviceId, ServiceQuery query) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServiceHolder t = locator.locate(type, serviceId, query); + if (t != null) + holder.addServiceHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, java.lang.String, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServiceHolder locate(Class type, String serviceType, + String serviceId, ServiceQuery query) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServiceHolder t = locator.locate(type, serviceType, serviceId, query); + if (t != null) + holder.addServiceHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class) + */ + @Override + public IServicesHolder list(Class type) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServicesHolder t = locator.list(type); + if (t != null) + holder.addServicesHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, java.lang.String) + */ + @Override + public IServicesHolder list(Class type, String serviceType) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServicesHolder t = locator.list(type, serviceType); + if (t != null) + holder.addServicesHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, org.adempiere.base.ServiceQuery) + */ + @Override + public IServicesHolder list(Class type, ServiceQuery query) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServicesHolder t = locator.list(type, query); + if (t != null) + holder.addServicesHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServicesHolder list(Class type, String serviceId, ServiceQuery query) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServicesHolder t = locator.list(type, serviceId, query); + if (t != null) + holder.addServicesHolder(t); + } + return holder; + } + + /* (non-Javadoc) + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, java.lang.String, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServicesHolder list(Class type, String serviceType, + String serviceId, ServiceQuery query) { + DelegatingServiceHolder holder = new DelegatingServiceHolder(); + for(IServiceLocator locator : getLocators()) { + IServicesHolder t = locator.list(type, serviceType, serviceId, query); + if (t != null) + holder.addServicesHolder(t); + } + return holder; + } + +} diff --git a/org.adempiere.base/src/org/adempiere/base/IServiceHolder.java b/org.adempiere.base/src/org/adempiere/base/IServiceHolder.java new file mode 100644 index 0000000000..a8e07dc8fa --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/IServiceHolder.java @@ -0,0 +1,30 @@ +/****************************************************************************** + * 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; + +/** + * + * @author hengsin + * + * @param + */ +public interface IServiceHolder { + + /** + * + * @return service instance. null if not available or no matching service found + */ + public T getService(); + +} diff --git a/org.adempiere.base/src/org/adempiere/base/IServiceLocator.java b/org.adempiere.base/src/org/adempiere/base/IServiceLocator.java index 45f8ecc984..7941a4bca1 100644 --- a/org.adempiere.base/src/org/adempiere/base/IServiceLocator.java +++ b/org.adempiere.base/src/org/adempiere/base/IServiceLocator.java @@ -16,25 +16,99 @@ *****************************************************************************/ package org.adempiere.base; -import java.util.List; - /** * A service locator looks up services. * This is the central authority for adempiere service definition, * because each service defined has to be looked up via this interface. * - * A service in adempiere is an interface extended from the tagging interface IService. + * A service in adempiere is an implementation for the registered interface, expose through osgi service registry or equinox extension registry * * @author viola * */ public interface IServiceLocator { - T locate(Class type); - T locate(Class type, String extensionPointId); - T locate(Class type, ServiceQuery query); - T locate(Class type, String extensionPointId, ServiceQuery query); - List list(Class type); - List list(Class type, String extensionPointId); - List list(Class type, ServiceQuery query); - List list(Class type, String extensionPointId, ServiceQuery query); + /** + * + * @param type service interface + * @return holder for dynamic service + */ + IServiceHolder locate(Class type); + + /** + * + * @param type + * @param serviceType equinox extension point id, ignore by osgi service locator + * type.getName + * @return holder for dynamic service + */ + IServiceHolder locate(Class type, String serviceType); + + /** + * + * @param type + * @param query + * @return + */ + IServiceHolder locate(Class type, ServiceQuery query); + + /** + * + * @param type + * @param serviceId component name or extension id + * @param query + * @return holder for dynamic service + */ + IServiceHolder locate(Class type, String serviceId, ServiceQuery query); + + /** + * + * @param type + * @param serviceType equinox extension point id, ignore by osgi service locator + * @param serviceId component name or extension id + * @param query + * @return holder for dynamic service + */ + IServiceHolder locate(Class type, String serviceType, String serviceId, ServiceQuery query); + + /** + * + * @param type + * @return holder for list of dynamic service + */ + IServicesHolder list(Class type); + + /** + * + * @param type + * @param serviceType equinox extension point id, ignore by osgi service locator + * @return holder for list of dynamic service + */ + IServicesHolder list(Class type, String serviceType); + + /** + * + * @param type + * @param query + * @return holder for list of dynamic service + */ + IServicesHolder list(Class type, ServiceQuery query); + + /** + * + * @param type + * @param serviceId component name or extension id + * @param query + * @return holder for list of dynamic service + */ + IServicesHolder list(Class type, String serviceId, ServiceQuery query); + + /** + * + * @param type + * @param serviceType equinox extension point id, ignore by osgi service locator + * @param serviceId component name or extension id + * @param query + * @return holder for list of dynamic service + */ + IServicesHolder list(Class type, String serviceType, String serviceId, ServiceQuery query); } diff --git a/org.adempiere.base/src/org/adempiere/base/IServicesHolder.java b/org.adempiere.base/src/org/adempiere/base/IServicesHolder.java new file mode 100644 index 0000000000..e16b9ed23d --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/IServicesHolder.java @@ -0,0 +1,32 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.base; + +import java.util.List; + +/** + * + * @author hengsin + * + * @param + */ +public interface IServicesHolder { + + /** + * + * @return list of service instance. null if not available or no matching service found + */ + public List getServices(); + +} diff --git a/org.adempiere.base/src/org/adempiere/base/Service.java b/org.adempiere.base/src/org/adempiere/base/Service.java index dcdbdecbe3..65a65c0b64 100644 --- a/org.adempiere.base/src/org/adempiere/base/Service.java +++ b/org.adempiere.base/src/org/adempiere/base/Service.java @@ -16,8 +16,6 @@ *****************************************************************************/ package org.adempiere.base; -import java.util.List; - /** * This is a very simple factory for service locators * @@ -26,66 +24,13 @@ import java.util.List; */ public class Service { - private static final String LOCATOR_CLASS = "ServiceLocator"; - private static final String DEFAULT_LOCATOR_CLASS = "org.adempiere.base.equinox.EquinoxServiceLocator"; - - private static IServiceLocator theLocator; + private static IServiceLocator theLocator = new DelegatingServiceLocator(); + /** + * + * @return service locator instance + */ public static IServiceLocator locator() { - if (theLocator == null) { - synchronized (Service.class) { - if (theLocator == null) { - theLocator = createServiceLocator(); - } - } - } return theLocator; } - - private static IServiceLocator createServiceLocator() { - String className = System.getProperty(LOCATOR_CLASS); - if (className==null) - className = DEFAULT_LOCATOR_CLASS; - try { - Class clazz = Class.forName(className); - IServiceLocator locator = (IServiceLocator) clazz.newInstance(); - System.out.println("Started service locator: " + locator); - return locator; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public static T locate(Class type) { - return locate(type, type.getName()); - } - - public static T locate(Class type, String id) { - return locator().locate(type, id); - } - - public static T locate(Class type, ServiceQuery query) { - return locate(type, type.getName(), query); - } - - public static T locate(Class type, String id, ServiceQuery query) { - return locator().locate(type, id, query); - } - - public static List list(Class type) { - return list(type, type.getName()); - } - - public static List list(Class type, String id) { - return locator().list(type, id); - } - - public static List list(Class type, ServiceQuery query) { - return locator().list(type, type.getName(), query); - } - - public static List list(Class type, String id, ServiceQuery query) { - return locator().list(type, id, query); - } } diff --git a/org.adempiere.base/src/org/adempiere/base/ServiceQuery.java b/org.adempiere.base/src/org/adempiere/base/ServiceQuery.java index 74bd10a424..1358bae09c 100644 --- a/org.adempiere.base/src/org/adempiere/base/ServiceQuery.java +++ b/org.adempiere.base/src/org/adempiere/base/ServiceQuery.java @@ -1,10 +1,13 @@ package org.adempiere.base; -import java.util.HashMap; +import java.util.LinkedHashMap; -public class ServiceQuery extends HashMap { +/** + * A sequence of name value pair filter + * @author hengsin + * + */ +public class ServiceQuery extends LinkedHashMap { private static final long serialVersionUID = -3624488575106821781L; - - public static final String EXTENSION_ID = "Extension.ID"; } diff --git a/org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceHolder.java b/org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceHolder.java new file mode 100644 index 0000000000..96a29dd57b --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceHolder.java @@ -0,0 +1,63 @@ +/****************************************************************************** + * 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.ds; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.adempiere.base.IServiceHolder; +import org.adempiere.base.IServicesHolder; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; + +/** + * @author hengsin + * + */ +public class DynamicServiceHolder implements IServiceHolder, IServicesHolder { + + private ServiceTracker serviceTracker; + + /** + * @param tracker + */ + public DynamicServiceHolder(ServiceTracker tracker) { + serviceTracker = tracker; + if (serviceTracker.getTrackingCount() == -1) + serviceTracker.open(); + } + + @Override + public T getService() { + T service = serviceTracker.getService(); + return service; + } + + @Override + public List getServices() { + List services = new ArrayList(); + ServiceReference[] objects = serviceTracker.getServiceReferences(); + List> references = new ArrayList>(); + if (objects != null && objects.length > 0) { + references = Arrays.asList(objects); + } + Collections.sort(references, Collections.reverseOrder()); + for(ServiceReference reference : references) { + services.add(serviceTracker.getService(reference)); + } + return services; + } +} diff --git a/org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceLocator.java b/org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceLocator.java new file mode 100644 index 0000000000..7f2dfae0af --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/ds/DynamicServiceLocator.java @@ -0,0 +1,166 @@ +/****************************************************************************** + * 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.ds; + +import org.adempiere.base.BaseActivator; +import org.adempiere.base.IServiceHolder; +import org.adempiere.base.IServiceLocator; +import org.adempiere.base.IServicesHolder; +import org.adempiere.base.ServiceQuery; +import org.osgi.framework.Filter; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.service.component.ComponentConstants; +import org.osgi.util.tracker.ServiceTracker; + +/** + * @author hengsin + * + */ +public class DynamicServiceLocator implements IServiceLocator { + + /** + * + */ + public DynamicServiceLocator() { + } + + /** + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class) + */ + @Override + public IServiceHolder locate(Class type) { + Filter filter = filter(type, null, null); + ServiceTracker tracker = BaseActivator.getServiceTracker(type, filter); + return new DynamicServiceHolder(tracker); + } + + /** + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, java.lang.String) + */ + @Override + public IServiceHolder locate(Class type, String serviceType) { + return locate(type); + } + + /** + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, org.adempiere.base.ServiceQuery) + */ + @Override + public IServiceHolder locate(Class type, ServiceQuery query) { + if (query == null || query.isEmpty()) + return locate(type); + + Filter filter = filter(type, null, query); + ServiceTracker tracker = BaseActivator.getServiceTracker(type, filter); + return new DynamicServiceHolder(tracker); + } + + /** + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServiceHolder locate(Class type, String serviceId, ServiceQuery query) { + if ((query == null || query.isEmpty()) && (serviceId == null || serviceId.trim().length() == 0)) + return locate(type); + + Filter filter = filter(type, serviceId, query); + ServiceTracker tracker = BaseActivator.getServiceTracker(type, filter); + + return new DynamicServiceHolder(tracker); + } + + /** + * @see org.adempiere.base.IServiceLocator#locate(java.lang.Class, java.lang.String, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServiceHolder locate(Class type, String serviceType, String serviceId, + ServiceQuery query) { + return locate(type, serviceId, query); + } + + /** + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class) + */ + @Override + public IServicesHolder list(Class type) { + Filter filter = filter(type, null, null); + ServiceTracker tracker = BaseActivator.getServiceTracker(type, filter); + + return new DynamicServiceHolder(tracker); + } + + /** + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, java.lang.String) + */ + @Override + public IServicesHolder list(Class type, String serviceType) { + return list(type); + } + + /** + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, org.adempiere.base.ServiceQuery) + */ + @Override + public IServicesHolder list(Class type, ServiceQuery query) { + if (query == null || query.isEmpty()) + return list(type); + + Filter filter = filter(type, null, query); + ServiceTracker tracker = BaseActivator.getServiceTracker(type, filter); + return new DynamicServiceHolder(tracker); + } + + /** + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServicesHolder list(Class type, String serviceId, ServiceQuery query) { + if ((query == null || query.isEmpty()) && (serviceId == null || serviceId.trim().length() == 0)) + return list(type); + + Filter filter = filter(type, serviceId, query); + ServiceTracker tracker = BaseActivator.getServiceTracker(type, filter); + return new DynamicServiceHolder(tracker); + } + + /** + * @see org.adempiere.base.IServiceLocator#list(java.lang.Class, java.lang.String, java.lang.String, org.adempiere.base.ServiceQuery) + */ + @Override + public IServicesHolder list(Class type, String serviceType, + String serviceId, ServiceQuery query) { + return list(type, serviceId, query); + } + + private Filter filter(Class type, String serviceId, ServiceQuery query) { + StringBuilder builder = new StringBuilder("(&(objectclass="); + builder.append(type.getName()).append(")"); + if (query != null) { + for(String key : query.keySet()) { + String value = query.get(key); + builder.append("(").append(key).append("=").append(value).append(")"); + } + } + if (serviceId != null && serviceId.trim().length() > 0) { + builder.append("(").append(ComponentConstants.COMPONENT_NAME).append("=").append(serviceId.trim()).append(")"); + } + builder.append(")"); + try { + return BaseActivator.getBundleContext().createFilter(builder.toString()); + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceHolder.java b/org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceHolder.java new file mode 100644 index 0000000000..d7e501e00f --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceHolder.java @@ -0,0 +1,46 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.base.equinox; + +import java.util.List; + +import org.adempiere.base.IServiceHolder; +import org.adempiere.base.IServicesHolder; + +/** + * @author hengsin + * + */ +public class EquinoxServiceHolder implements IServiceHolder, IServicesHolder { + + private ExtensionList extensionList; + + /** + * @param list + */ + public EquinoxServiceHolder(ExtensionList list) { + extensionList = list; + } + + @Override + public T getService() { + return extensionList.first(); + } + + @Override + public List getServices() { + return extensionList.asList(); + } + +} diff --git a/org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceLocator.java b/org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceLocator.java index 1a730d3669..c706c8387c 100644 --- a/org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceLocator.java +++ b/org.adempiere.base/src/org/adempiere/base/equinox/EquinoxServiceLocator.java @@ -16,9 +16,9 @@ *****************************************************************************/ package org.adempiere.base.equinox; -import java.util.List; - +import org.adempiere.base.IServiceHolder; import org.adempiere.base.IServiceLocator; +import org.adempiere.base.IServicesHolder; import org.adempiere.base.ServiceQuery; @@ -32,44 +32,60 @@ import org.adempiere.base.ServiceQuery; */ public class EquinoxServiceLocator implements IServiceLocator { - public List list(Class type) { + @Override + public IServicesHolder list(Class type) { return list(type, type.getName()); } @Override - public List list(Class type, String extensionPointId) { - ExtensionList list = new ExtensionList(type, extensionPointId); - return list.asList(); + public IServicesHolder list(Class type, String serviceType) { + ExtensionList list = new ExtensionList(type, serviceType); + return new EquinoxServiceHolder(list); } - public List list(Class type, ServiceQuery query) { - return list(type, type.getName(), query); + @Override + public IServicesHolder list(Class type, ServiceQuery query) { + return list(type, type.getName(), null, query); } @Override - public List list(Class type, String extensionPointId, + public IServicesHolder list(Class type, String serviceId, ServiceQuery query) { + ExtensionList list = new ExtensionList(type, null, serviceId, query); + return new EquinoxServiceHolder(list); + } + + @Override + public IServicesHolder list(Class type, String serviceType, String serviceId, ServiceQuery query) { - ExtensionList list = new ExtensionList(type, extensionPointId, query); - return list.asList(); + ExtensionList list = new ExtensionList(type, serviceType, serviceId, query); + return new EquinoxServiceHolder(list); } - public T locate(Class type) { + @Override + public IServiceHolder locate(Class type) { return locate(type, type.getName()); } @Override - public T locate(Class type, String extensionPointId) { - ExtensionList list = new ExtensionList(type, extensionPointId); - return list.first(); + public IServiceHolder locate(Class type, String serviceType) { + ExtensionList list = new ExtensionList(type, serviceType); + return new EquinoxServiceHolder(list); } - public T locate(Class type, ServiceQuery query) { - return locate(type, type.getName(), query); + @Override + public IServiceHolder locate(Class type, ServiceQuery query) { + return locate(type, type.getName(), null, query); } @Override - public T locate(Class type, String extensionPointId, ServiceQuery query) { - ExtensionList list = new ExtensionList(type, extensionPointId, query); - return list.first(); + public IServiceHolder locate(Class type, String serviceId, ServiceQuery query) { + ExtensionList list = new ExtensionList(type, null, serviceId, query); + return new EquinoxServiceHolder(list); + } + + @Override + public IServiceHolder locate(Class type, String serviceType, String serviceId, ServiceQuery query) { + ExtensionList list = new ExtensionList(type, serviceType, serviceId, query); + return new EquinoxServiceHolder(list); } } diff --git a/org.adempiere.base/src/org/adempiere/base/equinox/ExtensionList.java b/org.adempiere.base/src/org/adempiere/base/equinox/ExtensionList.java index 28dfb66469..e7ee533faa 100644 --- a/org.adempiere.base/src/org/adempiere/base/equinox/ExtensionList.java +++ b/org.adempiere.base/src/org/adempiere/base/equinox/ExtensionList.java @@ -41,7 +41,7 @@ import org.eclipse.core.runtime.Platform; */ public class ExtensionList implements Iterable{ - public class ExtensionIterator implements Iterator { + public class ExtensionIterator implements Iterator { private int index = 0; @@ -59,23 +59,22 @@ public class ExtensionList implements Iterable{ } private boolean accept(IConfigurationElement element) { + if (extensionId != null) { + String id = element.getDeclaringExtension().getUniqueIdentifier(); + if (!extensionId.equals(id)) + return false; + } for (String name : filters.keySet()) { String expected = filters.get(name); - if (name.equals(ServiceQuery.EXTENSION_ID)) { - String id = element.getDeclaringExtension().getUniqueIdentifier(); - if (!expected.equals(id)) - return false; - } else { - String actual = element.getAttribute(name); - if (!expected.equals(actual)) - return false; - } + String actual = element.getAttribute(name); + if (!expected.equals(actual)) + return false; } return true; } @SuppressWarnings("unchecked") - public T next() { + public E next() { iterateUntilAccepted(); IConfigurationElement e = elements[index++]; if (e.getAttribute("class") == null) { @@ -90,7 +89,7 @@ public class ExtensionList implements Iterable{ } } try { - return (T) e.createExecutableExtension("class"); + return (E) e.createExecutableExtension("class"); } catch (CoreException ex) { throw new IllegalStateException(ex); } @@ -104,8 +103,16 @@ public class ExtensionList implements Iterable{ private IConfigurationElement[] elements; private HashMap filters = new HashMap(); + private String extensionId; + /** + * @param clazz + * @param extensionPointId + */ public ExtensionList(Class clazz, String extensionPointId) { + if (extensionPointId == null) + extensionPointId = clazz.getName(); + try { elements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId); if (elements != null && elements.length > 1) { @@ -116,6 +123,16 @@ public class ExtensionList implements Iterable{ } } + public ExtensionList(Class type, String extensionPointId, String extensionId, ServiceQuery query) { + this(type, extensionPointId); + this.extensionId = extensionId; + if (query != null) { + for (String key : query.keySet()) { + addFilter(key, query.get(key)); + } + } + } + private IConfigurationElement[] sort(IConfigurationElement[] elementArray) { IConfigurationElement[] result = elementArray; TreeMap> elementMap = new TreeMap>(); @@ -152,13 +169,6 @@ public class ExtensionList implements Iterable{ return result; } - public ExtensionList(Class type, String extensionPointId, ServiceQuery query) { - this(type, extensionPointId); - for (String key : query.keySet()) { - addFilter(key, query.get(key)); - } - } - public Iterator iterator() { return new ExtensionIterator(); } diff --git a/org.adempiere.base/src/org/compiere/acct/DocManager.java b/org.adempiere.base/src/org/compiere/acct/DocManager.java index b89fae8fc3..3b2d00a234 100644 --- a/org.adempiere.base/src/org/compiere/acct/DocManager.java +++ b/org.adempiere.base/src/org/compiere/acct/DocManager.java @@ -135,7 +135,7 @@ public class DocManager { ServiceQuery query = new ServiceQuery(); query.put("gaap", as.getGAAP()); - List factoryList = Service.list(IDocFactory.class, query); + List factoryList = Service.locator().list(IDocFactory.class, query).getServices(); if (factoryList != null) { for(IDocFactory factory : factoryList) @@ -148,7 +148,7 @@ public class DocManager { query.clear(); query.put("gaap", "*"); - factoryList = Service.list(IDocFactory.class, query); + factoryList = Service.locator().list(IDocFactory.class, query).getServices(); if (factoryList != null) { for(IDocFactory factory : factoryList) @@ -175,7 +175,7 @@ public class DocManager { { ServiceQuery query = new ServiceQuery(); query.put("gaap", as.getGAAP()); - List factoryList = Service.list(IDocFactory.class,query); + List factoryList = Service.locator().list(IDocFactory.class,query).getServices(); if (factoryList != null) { for(IDocFactory factory : factoryList) @@ -188,7 +188,7 @@ public class DocManager { query.clear(); query.put("gaap", "*"); - factoryList = Service.list(IDocFactory.class,query); + factoryList = Service.locator().list(IDocFactory.class,query).getServices(); if (factoryList != null) { for(IDocFactory factory : factoryList) diff --git a/org.adempiere.base/src/org/compiere/db/CConnection.java b/org.adempiere.base/src/org/compiere/db/CConnection.java index 32a13ec1f6..e86e86e192 100644 --- a/org.adempiere.base/src/org/compiere/db/CConnection.java +++ b/org.adempiere.base/src/org/compiere/db/CConnection.java @@ -379,7 +379,7 @@ public class CConnection implements Serializable, Cloneable try { - Status status = Service.locate(Status.class); + Status status = Service.locator().locate(Status.class).getService(); m_version = status.getDateVersion(); } catch (Throwable t) @@ -408,7 +408,7 @@ public class CConnection implements Serializable, Cloneable { if (m_server == null) { - m_server = Service.locate(Server.class); + m_server = Service.locator().locate(Server.class).getService(); } return m_server; } // getServer @@ -1400,7 +1400,7 @@ public class CConnection implements Serializable, Cloneable return m_okApps; // false } - Status status = Service.locate(Status.class); + Status status = Service.locator().locate(Status.class).getService(); try { updateInfoFromServer(status); m_okApps = true; diff --git a/org.adempiere.base/src/org/compiere/db/Database.java b/org.adempiere.base/src/org/compiere/db/Database.java index fea34d002d..a2998e8e0a 100644 --- a/org.adempiere.base/src/org/compiere/db/Database.java +++ b/org.adempiere.base/src/org/compiere/db/Database.java @@ -60,7 +60,7 @@ public class Database { ServiceQuery query = new ServiceQuery(); query.put("id", type); - AdempiereDatabase db = Service.locate(AdempiereDatabase.class, query); + AdempiereDatabase db = Service.locator().locate(AdempiereDatabase.class, query).getService(); return db; } diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index 72ec4b6748..679a13f480 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -2886,7 +2886,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable { String className = cmd.substring(0,methodStart); //first, check matching extension id in extension registry - call = Service.locate(Callout.class, className); + call = Service.locator().locate(Callout.class, className).getService(); if (call == null) { //no match from extension registry, check java classpath Class cClass = Class.forName(className); diff --git a/org.adempiere.base/src/org/compiere/model/MTable.java b/org.adempiere.base/src/org/compiere/model/MTable.java index 0ad6c759be..b2060f1bb4 100644 --- a/org.adempiere.base/src/org/compiere/model/MTable.java +++ b/org.adempiere.base/src/org/compiere/model/MTable.java @@ -163,7 +163,7 @@ public class MTable extends X_AD_Table */ public static Class getClass (String tableName) { - List factoryList = Service.list(IModelFactory.class); + List factoryList = Service.locator().list(IModelFactory.class).getServices(); if (factoryList == null) return null; for(IModelFactory factory : factoryList) { @@ -322,7 +322,7 @@ public class MTable extends X_AD_Table } PO po = null; - List factoryList = Service.list(IModelFactory.class); + List factoryList = Service.locator().list(IModelFactory.class).getServices(); if (factoryList != null) { for(IModelFactory factory : factoryList) @@ -359,7 +359,7 @@ public class MTable extends X_AD_Table String tableName = getTableName(); PO po = null; - List factoryList = Service.list(IModelFactory.class); + List factoryList = Service.locator().list(IModelFactory.class).getServices(); if (factoryList != null) { for(IModelFactory factory : factoryList) { diff --git a/org.adempiere.install/src/org/compiere/install/ConfigurationData.java b/org.adempiere.install/src/org/compiere/install/ConfigurationData.java index 4d499ca374..170fef350e 100644 --- a/org.adempiere.install/src/org/compiere/install/ConfigurationData.java +++ b/org.adempiere.install/src/org/compiere/install/ConfigurationData.java @@ -79,7 +79,7 @@ public class ConfigurationData private void initDatabaseConfig() { - List configList = Service.list(IDatabaseConfig.class); + List configList = Service.locator().list(IDatabaseConfig.class).getServices(); m_databaseConfig = new IDatabaseConfig[configList.size()]; DBTYPE = new String[m_databaseConfig.length]; for(int i = 0; i < configList.size(); i++) diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/OSGiHandlerRegistry.java b/org.adempiere.pipo/src/org/adempiere/pipo2/OSGiHandlerRegistry.java index 6268e8b04b..1c868d39d7 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/OSGiHandlerRegistry.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/OSGiHandlerRegistry.java @@ -36,11 +36,11 @@ public class OSGiHandlerRegistry implements IHandlerRegistry { ServiceQuery query = new ServiceQuery(); query.put("id", id); - handler = Service.locate(ElementHandler.class, SERVICE_ID, query); + handler = Service.locator().locate(ElementHandler.class, SERVICE_ID, null, query).getService(); if (handler == null) { id = TABLE_GENERIC_HANDLER; query.put("id", id); - handler = Service.locate(ElementHandler.class, SERVICE_ID, query); + handler = Service.locator().locate(ElementHandler.class, SERVICE_ID, null, query).getService(); } return handler; } @@ -53,7 +53,7 @@ public class OSGiHandlerRegistry implements IHandlerRegistry { ElementHandler handler = null; ServiceQuery query = new ServiceQuery(); query.put("id", name); - handler = Service.locate(ElementHandler.class, SERVICE_ID, query); + handler = Service.locator().locate(ElementHandler.class, SERVICE_ID, null, query).getService(); return handler; } } diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java index af23a23bba..3c2f44130e 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java @@ -74,7 +74,7 @@ public class AdempiereActivator implements BundleActivator { protected void packIn(String trxName) { URL packout = context.getBundle().getEntry("/META-INF/2Pack.zip"); if (packout != null) { - IDictionaryService service = Service.locate(IDictionaryService.class); + IDictionaryService service = Service.locator().locate(IDictionaryService.class).getService(); try { // copy the resource to a temporary file to process it with 2pack InputStream stream = context.getBundle().getEntry("/META-INF/2Pack.zip").openStream(); diff --git a/org.adempiere.report.jasper/src/org/compiere/report/ReportStarter.java b/org.adempiere.report.jasper/src/org/compiere/report/ReportStarter.java index 020c54fb4c..bfb4b613a7 100644 --- a/org.adempiere.report.jasper/src/org/compiere/report/ReportStarter.java +++ b/org.adempiere.report.jasper/src/org/compiere/report/ReportStarter.java @@ -671,7 +671,7 @@ public class ReportStarter implements ProcessCall, ClientProcess // JasperExportManager.exportReportToPdfFile(jasperPrint, "BasicReport.pdf"); } else { log.info( "ReportStarter.startProcess run report -"+jasperPrint.getName()); - JRViewerProvider viewerLauncher = Service.locate(JRViewerProvider.class); + JRViewerProvider viewerLauncher = Service.locator().locate(JRViewerProvider.class).getService(); viewerLauncher.openViewer(jasperPrint, pi.getTitle()+" - " + reportPath); } } diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java index 3480d14de6..0d376ebc40 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java @@ -182,7 +182,7 @@ public class AdempiereServerMgr } //osgi server - List serverFactoryList = Service.list(IServerFactory.class); + List serverFactoryList = Service.locator().list(IServerFactory.class).getServices(); if (serverFactoryList != null && !serverFactoryList.isEmpty()) { for(IServerFactory factory : serverFactoryList ) diff --git a/org.adempiere.ui.swing/src/org/adempiere/client/Client.java b/org.adempiere.ui.swing/src/org/adempiere/client/Client.java index b8dcdfbe9e..9d9aec61dc 100644 --- a/org.adempiere.ui.swing/src/org/adempiere/client/Client.java +++ b/org.adempiere.ui.swing/src/org/adempiere/client/Client.java @@ -37,9 +37,7 @@ public class Client { * @return */ public static FormPanel getFormPanel(String extensionId) { - ServiceQuery query = new ServiceQuery(); - query.put(ServiceQuery.EXTENSION_ID, extensionId); - return Service.locate(FormPanel.class, "org.adempiere.apps.Form", query); + return Service.locator().locate(FormPanel.class, "org.adempiere.apps.Form", extensionId, null).getService(); } } diff --git a/org.adempiere.ui.swing/src/org/adempiere/client/InfoManager.java b/org.adempiere.ui.swing/src/org/adempiere/client/InfoManager.java index 3a5aa681ea..eaa1eeac34 100644 --- a/org.adempiere.ui.swing/src/org/adempiere/client/InfoManager.java +++ b/org.adempiere.ui.swing/src/org/adempiere/client/InfoManager.java @@ -47,7 +47,7 @@ public class InfoManager boolean multiSelection, String whereClause) { Info info = null; - List factoryList = Service.list(IInfoFactory.class); + List factoryList = Service.locator().list(IInfoFactory.class).getServices(); for(IInfoFactory factory : factoryList) { info = factory.create(frame, true, lookup, field, tableName, keyColumn, @@ -77,7 +77,7 @@ public class InfoManager { Info info = null; - List factoryList = Service.list(IInfoFactory.class); + List factoryList = Service.locator().list(IInfoFactory.class).getServices(); for(IInfoFactory factory : factoryList) { info = factory.create(frame, modal, WindowNo, tableName, keyColumn, value, diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java b/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java index 95ed1340fa..d68fa15bd6 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java @@ -55,7 +55,7 @@ public class AExport // exporterMap = new HashMap(); extensionMap = new HashMap(); - List exporterList = Service.list(IGridTabExporter.class); + List exporterList = Service.locator().list(IGridTabExporter.class).getServices(); for(IGridTabExporter exporter : exporterList) { String extension = exporter.getFileExtension(); diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditorFactory.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditorFactory.java index f6c67a3224..001638010f 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditorFactory.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditorFactory.java @@ -58,7 +58,7 @@ public class VEditorFactory public static VEditor getEditor (GridTab mTab, GridField mField, boolean tableEditor) { VEditor editor = null; - List factoryList = Service.list(IEditorFactory.class); + List factoryList = Service.locator().list(IEditorFactory.class).getServices(); for(IEditorFactory factory : factoryList) { editor = factory.getEditor(mTab, mField, tableEditor); diff --git a/org.adempiere.ui.zk.example/src/org/adempiere/ui/zk/example/action/ExportAction.java b/org.adempiere.ui.zk.example/src/org/adempiere/ui/zk/example/action/ExportAction.java index db9d370888..910be69dc8 100644 --- a/org.adempiere.ui.zk.example/src/org/adempiere/ui/zk/example/action/ExportAction.java +++ b/org.adempiere.ui.zk.example/src/org/adempiere/ui/zk/example/action/ExportAction.java @@ -89,7 +89,7 @@ public class ExportAction implements IAction, EventListener { private void doExport() { exporterMap = new HashMap(); extensionMap = new HashMap(); - List exporterList = Service.list(IGridTabExporter.class); + List exporterList = Service.locator().list(IGridTabExporter.class).getServices(); for(IGridTabExporter exporter : exporterList) { String extension = exporter.getFileExtension(); diff --git a/org.adempiere.ui.zk/META-INF/MANIFEST.MF b/org.adempiere.ui.zk/META-INF/MANIFEST.MF index 382accad47..f678c5be7d 100644 --- a/org.adempiere.ui.zk/META-INF/MANIFEST.MF +++ b/org.adempiere.ui.zk/META-INF/MANIFEST.MF @@ -12,8 +12,6 @@ Import-Package: javax.servlet, org.apache.ecs.xhtml, org.compiere.css, org.osgi.framework;version="1.5.0", - org.osgi.service.component;version="1.1.0", - org.osgi.util.tracker;version="1.5.0", org.slf4j;version="1.6.1", org.slf4j.helpers;version="1.6.1", org.slf4j.spi;version="1.6.1" @@ -59,3 +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 diff --git a/org.adempiere.ui.zk/OSGI-INF/defaulteditorfactory.xml b/org.adempiere.ui.zk/OSGI-INF/defaulteditorfactory.xml new file mode 100644 index 0000000000..d786feeb2c --- /dev/null +++ b/org.adempiere.ui.zk/OSGI-INF/defaulteditorfactory.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.ui.zk/OSGI-INF/defaultinfofactory.xml b/org.adempiere.ui.zk/OSGI-INF/defaultinfofactory.xml new file mode 100644 index 0000000000..bfcf4aa335 --- /dev/null +++ b/org.adempiere.ui.zk/OSGI-INF/defaultinfofactory.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.ui.zk/OSGI-INF/jrviewerprovider.xml b/org.adempiere.ui.zk/OSGI-INF/jrviewerprovider.xml new file mode 100644 index 0000000000..ed544e330f --- /dev/null +++ b/org.adempiere.ui.zk/OSGI-INF/jrviewerprovider.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.ui.zk/OSGI-INF/reportviewerprovider.xml b/org.adempiere.ui.zk/OSGI-INF/reportviewerprovider.xml new file mode 100644 index 0000000000..ccfc5b04bf --- /dev/null +++ b/org.adempiere.ui.zk/OSGI-INF/reportviewerprovider.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.ui.zk/OSGI-INF/resourcefinder.xml b/org.adempiere.ui.zk/OSGI-INF/resourcefinder.xml new file mode 100644 index 0000000000..788cb7d615 --- /dev/null +++ b/org.adempiere.ui.zk/OSGI-INF/resourcefinder.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/Extensions.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/Extensions.java index 90c97755d1..82a196438f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/Extensions.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/Extensions.java @@ -38,8 +38,6 @@ public class Extensions { * @return IFormController instance or null if extensionId not found */ public static IFormController getForm(String extensionId) { - ServiceQuery query = new ServiceQuery(); - query.put(ServiceQuery.EXTENSION_ID, extensionId); - return Service.locate(IFormController.class, "org.adempiere.webui.Form", query); + return Service.locator().locate(IFormController.class, "org.adempiere.webui.Form", extensionId, null).getService(); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java index ceb906ee74..af81929214 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java @@ -16,13 +16,9 @@ package org.adempiere.webui.action; import java.io.IOException; import java.io.InputStream; -import org.adempiere.webui.WebUIActivator; +import org.adempiere.base.IServiceHolder; +import org.adempiere.base.Service; import org.compiere.util.CCache; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Filter; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.service.component.ComponentConstants; -import org.osgi.util.tracker.ServiceTracker; import org.zkoss.image.AImage; /** @@ -33,36 +29,24 @@ import org.zkoss.image.AImage; public class Actions { private static final String ACTION_IMAGES_PATH = "/action/images/"; - private static CCache> trackerCache = new CCache>("ActionsServiceTracker", 5); + private static CCache> trackerCache = new CCache>("ActionsServiceTracker", 5); private static CCache imageCache = new CCache("ActionsImages",5); - private static final String COMPONENT_FILTER = "(&(objectclass=org.adempiere.webui.action.IAction)(" - + ComponentConstants.COMPONENT_NAME + "=?))"; - - public static ServiceTracker getActionTracker(String actionId) { - ServiceTracker actionTracker = null; + public static IServiceHolder getAction(String actionId) { + IServiceHolder action = null; synchronized (trackerCache) { - actionTracker = trackerCache.get(actionId); - } - if (actionTracker != null) - return actionTracker; - BundleContext context = WebUIActivator.getBundleContext(); - Filter filter = null; - try { - String sFilter = COMPONENT_FILTER.replaceFirst("[?]", actionId); - filter = context.createFilter(sFilter); - } catch (InvalidSyntaxException e) { - e.printStackTrace(); - } - - actionTracker = new ServiceTracker(context, filter, null); - if (actionTracker != null) { - actionTracker.open(); + action = trackerCache.get(actionId); + } + if (action != null) + return action; + + action = Service.locator().locate(IAction.class, actionId, null); + if (action != null) { synchronized (trackerCache) { - trackerCache.put(actionId, actionTracker); + trackerCache.put(actionId, action); } } - return actionTracker; + return action; } public static AImage getActionImage(String actionId) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index 1a52743bc2..075260c286 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.base.IServiceHolder; import org.adempiere.webui.AdempiereIdGenerator; import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.action.Actions; @@ -42,7 +43,6 @@ import org.compiere.model.X_AD_ToolBarButton; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Msg; -import org.osgi.util.tracker.ServiceTracker; import org.zkoss.image.AImage; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; @@ -609,8 +609,8 @@ public class ADWindowToolbar extends FToolbar implements EventListener if (mToolbarButtons != null && mToolbarButtons.length > 0) { for (MToolBarButton mToolBarButton : mToolbarButtons) { String actionId = mToolBarButton.getActionClassName(); - ServiceTracker serviceTracker = Actions.getActionTracker(actionId); - if (serviceTracker != null && serviceTracker.size() > 0) { + IServiceHolder serviceHolder = Actions.getAction(actionId); + if (serviceHolder != null && serviceHolder.getService() != null) { String labelKey = actionId + ".label"; String tooltipKey = actionId + ".tooltip"; String label = Msg.getMsg(Env.getCtx(), labelKey); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ToolbarCustomButton.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ToolbarCustomButton.java index d451d627f3..a142f98f6a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ToolbarCustomButton.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ToolbarCustomButton.java @@ -13,13 +13,13 @@ *****************************************************************************/ package org.adempiere.webui.adwindow; +import org.adempiere.base.IServiceHolder; import org.adempiere.webui.action.Actions; import org.adempiere.webui.action.IAction; import org.compiere.model.MToolBarButton; import org.compiere.util.Env; import org.compiere.util.Evaluatee; import org.compiere.util.Evaluator; -import org.osgi.util.tracker.ServiceTracker; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; @@ -43,9 +43,9 @@ public class ToolbarCustomButton implements EventListener, Evaluatee { @Override public void onEvent(Event event) throws Exception { - ServiceTracker serviceTracker = Actions.getActionTracker(actionId); - if (serviceTracker != null) { - IAction action = serviceTracker.getService(); + IServiceHolder serviceHolder = Actions.getAction(actionId); + if (serviceHolder != null) { + IAction action = serviceHolder.getService(); if (action != null) { action.execute(ADWindow.get(windowNo)); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java index 9a0a7c62aa..2df940e220 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java @@ -20,13 +20,10 @@ package org.adempiere.webui.editor; import java.util.List; import org.adempiere.base.Service; -import org.adempiere.webui.component.EditorBox; -import org.adempiere.webui.component.NumberBox; import org.adempiere.webui.factory.IEditorFactory; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.util.CLogger; -import org.zkoss.zul.impl.InputElement; /** * @@ -56,7 +53,7 @@ public class WebEditorFactory public static WEditor getEditor(GridTab gridTab, GridField gridField, boolean tableEditor) { WEditor editor = null; - List factoryList = Service.list(IEditorFactory.class); + List factoryList = Service.locator().list(IEditorFactory.class).getServices(); for(IEditorFactory factory : factoryList) { editor = factory.getEditor(gridTab, gridField, tableEditor); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/InfoManager.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/InfoManager.java index e00d659095..f9c6b9f7cf 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/InfoManager.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/InfoManager.java @@ -33,7 +33,7 @@ public class InfoManager { InfoPanel info = null; - List factoryList = Service.list(IInfoFactory.class); + List factoryList = Service.locator().list(IInfoFactory.class).getServices(); for(IInfoFactory factory : factoryList) { info = factory.create(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, lookup); @@ -49,7 +49,7 @@ public class InfoManager String whereClause) { InfoPanel ip = null; - List factoryList = Service.list(IInfoFactory.class); + List factoryList = Service.locator().list(IInfoFactory.class).getServices(); for(IInfoFactory factory : factoryList) { ip = factory.create(lookup, field, tableName, keyColumn, queryValue, false, whereClause); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java index 6cd0a5724a..a26b1ba670 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java @@ -78,7 +78,7 @@ public class ExportAction implements EventListener { exporterMap = new HashMap(); extensionMap = new HashMap(); - List exporterList = Service.list(IGridTabExporter.class); + List exporterList = Service.locator().list(IGridTabExporter.class).getServices(); for(IGridTabExporter exporter : exporterList) { String extension = exporter.getFileExtension(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java index 0ec2d649e0..323dcb2f7d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java @@ -108,7 +108,7 @@ public class FileImportAction implements EventListener importerMap = new HashMap(); extensionMap = new HashMap(); - List importerList = Service.list(IGridTabImporter.class); + List importerList = Service.locator().list(IGridTabImporter.class).getServices(); for(IGridTabImporter importer : importerList) { String extension = importer.getFileExtension(); diff --git a/org.adempiere.ui.zk/build.properties b/org.adempiere.ui.zk/build.properties index 7e0c8609c9..6287f60805 100644 --- a/org.adempiere.ui.zk/build.properties +++ b/org.adempiere.ui.zk/build.properties @@ -1,4 +1,3 @@ -source.. = WEB-INF/src/ output.. = WEB-INF/classes/ bin.includes = META-INF/,\ WEB-INF/,\ @@ -22,7 +21,12 @@ bin.includes = META-INF/,\ calendar.zul,\ calendar_mini.zul,\ divarrow.zul,\ - divtab.zul + divtab.zul,\ + OSGI-INF/reportviewerprovider.xml,\ + OSGI-INF/defaultinfofactory.xml,\ + OSGI-INF/defaulteditorfactory.xml,\ + OSGI-INF/jrviewerprovider.xml,\ + OSGI-INF/resourcefinder.xml src.includes = WEB-INF/classes/,\ WEB-INF/tld/,\ WEB-INF/web.xml,\ @@ -41,5 +45,6 @@ src.includes = WEB-INF/classes/,\ calendar_mini.zul,\ divarrow.zul,\ divtab.zul +source.. = WEB-INF/src/ bin.excludes = WEB-INF/src/,\ WEB-INF/web-2.5.xml diff --git a/org.adempiere.ui.zk/plugin.xml b/org.adempiere.ui.zk/plugin.xml index 35b2f2510a..9bf9c34dce 100644 --- a/org.adempiere.ui.zk/plugin.xml +++ b/org.adempiere.ui.zk/plugin.xml @@ -4,54 +4,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java index 928e6d8b4f..ef552678db 100644 --- a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java +++ b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java @@ -377,7 +377,7 @@ public class ReportCtl */ public static void preview(ReportEngine re) { - ReportViewerProvider viewer = Service.locate(ReportViewerProvider.class); + ReportViewerProvider viewer = Service.locator().locate(ReportViewerProvider.class).getService(); viewer.openViewer(re); }