Add model factory base class backed by Map and Lambda functional object
Description
Environment
Activity
Heng Sin Low November 11, 2021 at 7:49 AM
Heng Sin Low January 28, 2021 at 1:47 PM
Hi ,
Note that this is still a PR, is not approved yet.
It is an implementation of IModelFactory that’s means to simplify the development of custom model factory for plugin. However, since you will have to create one registration line for each model class, this is probably not the best approach if your plugin have large number of model classes.
The ticket also add a default mapped model factory service that plugin can use to register custom table to model class mapping. This should eliminate the need of many plugin to include a model factory service.
After this have been approved, similar approach will be used for other factories (for e.g process factory) that’s driven by name based mapping.
Regards,
Low
Chuck Boecking January 28, 2021 at 1:27 PM(edited)
Hi - sorry for the twenty questions… I want to help others understand the context. Do you see this as a new style of creating plugins in general moving forward, or this specific to models? What is the benefit of this approach over the existing iModelFactory? I will use this information to help create documentation if you wish.
BTW - Thank you for taking the time to help!
Heng Sin Low January 28, 2021 at 8:12 AM
Hi , example usage is in the org.idempiere.test/src/org/idempiere/test/model/MappedModelFactoryTest.java unit test class.
Chuck Boecking January 27, 2021 at 1:38 PM
Hi - do you have docs or references on this to help understand how to leverage or benefit from this effort? Thanks, Chuck
Implement a new model factory base class that's backed by Map and Lambda functional object.
Example Usage:
With following model class.
Developer can use one of the following approach:
At plugin Activator start method, register the model class.
Create an osgi component, at the bind method for the IMappedModelFactory service.
Create a subclass of MappedModelFactory, register as IModelFactory service (DO NOT register as IMappedModelFactory service).