Hello,
We're currently working on a project that has >200 custom
model classes. Declaring all of them inside model providers seems
a bit tedious, made me wonder if any of you guys had to deal with
a similar situation.
We'd like to exchange ideas with other developers that had faced a similar issue and perhaps know how they had sorted it out.
Some ideas we're currently considering are:
Any thoughts would be welcome.
Best regards,
Saulo Gil | Orbital Software | +54 911 3049 4237 |
Hello Andreas, thank you for the quick response.
We've thought about a similar approach, resembling classic
Compiere class model resolution. Although it's simple enough,
we're supposed to be wary of using Class.forName(String)
under OSGi's realm (see
https://developer.ibm.com/articles/osgi-demystified-part-3-avoiding-dynamic-class-loading/).
This is relevant for us since one of our projects have classes
that clash with some iDempiere classes and we won't be able to
change that for a while.
As a side note, we're a bit suprised that the core is still using
Class.forName. Would it make sense
to change it to something like the following?
Class clazz = packageAdmin.getExportedPackage(packageName).getExportingBundle().loadClass(className);
At this moment we're considering auto-generating class model registration code, since Java annotations don't seem to go well with X* model classes (they're not supposed to be edited).
Best regards,
Saulo Gil | Orbital Software | +54 911 3049 4237 |
--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/0de9bee8-b955-45d6-98e5-d40a86ee8aa8n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/01000178fb4cd911-274c5296-127a-42f9-a2a9-94a07f36303d-000000%40email.amazonses.com.
I'd rather to mix both options a bit, since:
I really liked your idea of using a custom model generator, I'll
come back to this thread with some code.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/CAC%3D6jXG97nDBZygAsoruRWxBc6vjko0EoBnAFNj9qBmTfzcXvA%40mail.gmail.com.
We've created an
experimental branch where we register model classes using
annotations.
Here we rely on the ClassIndex library, which builds a list of all annotated classes at compile time. By using annotation processors we get faster and cleaner association between each table and its model class, since it avoids using Class.forName. Might be needless to say that we also avoid runtime class scanning, which is slow and error-prone. The one thing we didn't like about this approach is that Eclipse requires annotation processors to be configured manually.
Though we haven't tested this approach extensively, we haven't
found issues consuming these annotations from plugins. Creating IModelFactory implementations should be
trivial enough.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/010001790b7c3696-6d69de55-0eff-48b3-acfb-e3580e295db5-000000%40email.amazonses.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/010001791ba6852b-1b5c77a2-6481-44e6-ba71-9889fc67b0e9-000000%40email.amazonses.com.
Hello,
These changes should be stable, although that branch was created as a proof of concept. If you core developers like this approach we could move ahead and follow the extra steps (FR, documentation, testing, etc) targeting production quality.
Please confirm.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/CAC%3D6jXH46SM0EqwMC%2B6XrLd-eQe13wBEd0DD8c9HmWCfrcxNmg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/01000179a88f80f6-42a66c90-c3c4-4576-9cd3-e2428e9feb2d-000000%40email.amazonses.com.
Hello,
Please see my replies below. We're submitting a FR soon.
Best regards
1. The approach looks good to me.
2. I think this should be created as a new model factory with higher service.ranking than the current default model factory. This way, it can fall back to the current default model factory.
3. Have you tested with the model class from the plugin ? I'm not sure whether there would be class loader issues here. If there are, I think it should be easy for plugins to reuse the new model factory added at #2.
4. It seems at Eclipse, you have to configure the annotation processor by each individual project. Do you know whether there is a simpler approach ?
Not that I'm aware of, but we'll take a second look hoping we can at least inject this configuration on the project(s).
Please see https://github.com/atteo/classindex#eclipse
5. What's the impact on our maven tycho build ? just some pom changes ?
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/CAC%3D6jXGwhy1dNSeC%3DZS2zdoWFu2iJtJ0si5Sg9CYRa0a-chxqA%40mail.gmail.com.