I find it a bit counter-intuitive to cache data inside the factories. I would find it more logical to cache the data in the providers instead. This allows to clearly separate the data loading from the data use.
I guess that the data is cached in the factories because some factories transform the data before caching it ? If the transformation is computation-intensive, then the current design makes good sense.
My ideas are too messy to be written down right now. I am toying with the idea of Java Services, as described here :
I believe I have found something that would work for me, but I am still trying to make sure it could accommodate the other use cases. I think this is the kind of topic where a live brainstorming session, in person, would be much more efficient than mail. Which is one of the many reasons why I am looking forward to Orekit Day !
Hi Yannick, Luc,
On Mon, 2017-11-13 at 12:16 +0100, MAISONOBE Luc wrote:
"JEANDROZ, Yannick [FR]" <email@example.com> a écrit :
Yannick, I'm interested in hearing your ideas. I've run in to the same issue when trying to use different EOP data sets within the same Orekit application. My thought is to:
1. Make the DataProviderManager (DPM) instaniable.
2. Make all the static factories (TimeScaleFactory, FramesFactory, etc.) instantiable and take a DPM in the constructor.
3. Ensure that for every contructor/method in Orekit that uses one of the static factories there is an equivalent method that receives the factory or the factory-created object as a parameter instead.
The existing static factory methods could be retained to make it easier for new users or simple applications.
Loaded data would still be cached in each of the factories, but the user application would now have more control over where the data is used. For example, application could use one TimeScaleFactory for the entire application to match the current behavior, or one TimeScaleFactory per thread to match Yannik's use case, or something more complex that makes sense for the specific application.
Here is an example of what the code would look like:
DataProviderManager dataSet1 = new DataProviderManager();
DataProviderManager dataSet2 = new DataProviderManager();
TimeScaleFactory tsf1 = new TimeScaleFactory(dataSet1);
TimeScaleFactory tsf2 = new TimeScaleFactory(dataSet2);
TimeScale utc = tsf1.getUTC(); // using original data set
TimeScale utcPlusHalf = tsf2.getUTC(); // using modified data set
Comments and criticisms welcome.
I agree with Luc that this would be a good topic to discuss at the Orekit Day.