I first started thinking of this idea in a Jira issue:
https://issues.apache.org/jira/browse/OFBIZ-3125
I thought it would be easy to extend the framework to support a new Java object
type (or class). I wanted to be able to pass around a TimeDuration instance in
services, mini-lang, screen widgets, etc. I thought it would be easy. It wasn't.
Those framework artifacts convert Java objects from one type to another using
the ObjectType class. I had to make changes to a huge monolithic if-else-if
block in that class. Then I had to modify some code in the Entity Engine. I
couldn't get the Entity Engine to support the TimeDuration class because of two
monolithic switch statements where Java data types are mapped to integers, but
not in a centralized way.
I stopped trying to wedge the TimeDuration class into inflexible code, and
instead started working on making the code more flexible.
I replaced the monolithic if-else-if block in ObjectType with polymorphism. Now
components can extend the framework with their own Java object type conversions.
I still need to work on the Entity Engine. I would like to replace its
monolithic conditionals with the new conversion code. Before I get started, I
wanted to present the idea to the community to see if there were any objections.
The goal is to make it easier for developers to add new Java data types to the
framework. I see this as a big benefit to writing OFBiz add-ons or
customizations.
What do you think?
-Adrian