From 9a3b1f3a4c0a2a14483dbf88ce1b8342e658a92f Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 26 Oct 2010 19:07:40 +0800 Subject: [PATCH] Added support to search extension by extension point id + extension id. Enhance search of "class" attribute. --- .../adempiere/base/equinox/ExtensionList.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) 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 b9e70686a6..fd93726d85 100644 --- a/org.adempiere.base/src/org/adempiere/base/equinox/ExtensionList.java +++ b/org.adempiere.base/src/org/adempiere/base/equinox/ExtensionList.java @@ -30,9 +30,9 @@ import org.eclipse.core.runtime.Platform; * This List looks up services as extensions in equinox. * The extension point must be the class name of the service interface. * The query attributes are checked against the attributes - * of the extension configuration element. - * - * In order to minimize equinox lookups, a filtering iterator is used. + * of the extension configuration element. + * + * In order to minimize equinox lookups, a filtering iterator is used. * @author viola * * @param The service this list holds implementations of. @@ -59,9 +59,15 @@ public class ExtensionList implements Iterable{ private boolean accept(IConfigurationElement element) { for (String name : filters.keySet()) { String expected = filters.get(name); - String actual = element.getAttribute(name); - if (!expected.equals(actual)) - return false; + if (name.equals("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; + } } return true; } @@ -70,6 +76,17 @@ public class ExtensionList implements Iterable{ public T next() { iterateUntilAccepted(); IConfigurationElement e = elements[index++]; + if (e.getAttribute("class") == null) { + IConfigurationElement[] childs = e.getChildren(); + if (childs != null && childs.length > 0) { + for(IConfigurationElement child : childs) { + if (child.getAttribute("class") != null) { + e = child; + break; + } + } + } + } try { return (T) e.createExecutableExtension("class"); } catch (CoreException ex) { @@ -93,7 +110,7 @@ public class ExtensionList implements Iterable{ System.out.println(ex.getMessage()); } } - + public ExtensionList(Class type, String extensionPointId, ServiceQuery query) { this(type, extensionPointId); for (String key : query.keySet()) {