details: https://code.openbravo.com/erp/devel/pi/rev/f52dabf2bdc4
changeset: 15464:f52dabf2bdc4
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Mon Feb 13 17:58:29 2012 +0100
summary: Fixed issue 16868. ComponentProviders will be matched with modules
via the javapackage smartly:
- A class will be matched to a module if its javapackage starts with the
javapackage of the module (we no longer require the matching to be exact).
- If more than one module matches, the one with the longest Javapackage will be
picked. This is to resolve situations in which, for example, both org.openbravo
and org.openbravo.client.kernel match.
diffstat:
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
| 23 ++++++++-
1 files changed, 20 insertions(+), 3 deletions(-)
diffs (37 lines):
diff -r d573ede8052e -r f52dabf2bdc4
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
Mon Feb 13 16:34:12 2012 +0100
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
Mon Feb 13 17:58:29 2012 +0100
@@ -214,13 +214,30 @@
* if the module can not be found.
*/
public Module getModule(String javaPackage) {
+ Module chosenModule = null;
+ String chosenPackage = null;
for (Module module : getModulesOrderedByDependency()) {
// do trim to handle small typing errors, consider to do lowercase also
- if (module.getJavaPackage().trim().equalsIgnoreCase(javaPackage.trim()))
{
- return module;
+ if (javaPackage.trim().startsWith(module.getJavaPackage().trim())) {
+ // We pick a module if:
+ // - Its javapackage is a prefix of the javapackage of the class
+ // - We don't have a module yet, or the javapackage is longer than the
previously picked
+ // module
+ // We do this length check, in order to prioritize javapackages which
better fit the class.
+ // This is to avoid situations in which, for example, org.openbravo is
chosen over
+ // org.openbravo.client.kernel
+ if (chosenModule == null
+ || module.getJavaPackage().trim().length() >
chosenPackage.length()) {
+ chosenModule = module;
+ chosenPackage = module.getJavaPackage().trim();
+ }
}
}
- throw new OBException("No module found for java package " + javaPackage);
+ if (chosenModule == null) {
+ throw new OBException("No module found for java package " + javaPackage);
+ } else {
+ return chosenModule;
+ }
}
/**
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits