Dynamically loading of default provider in DataProviderManager

Hi, we have an existing application that uses Orekit Default provider at various places in the code. We would like to dynamically load the default provider. We can implement this by READ/WRITE lock in java that will only allow loading of files when no READ/processing is being done. We will start a new READ/processing when there is no WRITE (loading of files is happening).

However, to implement this, it will require us to modify code at lot of places which is error prone as we may miss some libraries.

Does anyone have some ideas on how to do this. Thanks for your help.

Hi @atul4us welcome

I am not sure to understand. Do you mean you want to reload new values dynamically or simply to delay the first load?
Did you look at the non-default provider, i.e. using data context?

I want to load new values dynamically. Scenario is

  1. We load it at the start of application
  2. Application can use these values
  3. A message comes in kafka queue that should trigger reloading
    Reloading should not happen if old values are being used.
    Application should not use the values if we are reloading.
    I can implement this using READ/WRITE lock but it will mean changing existing code - where ever we are using the values, we have to do a READ lock to prevent loading of the files.

Is there a simpler solution that I have not thought about or Orekit has implemented.

This definitely looks as a use case for data context. You can create a new data context when new data is available and use it in subsequent calls (for example you get new Earth Orientation Parameters or something like that). This however implies you use the API that have a data context as a parameter. There are many places where is is possible, with one API using the default context and another API allowing users to proved their context.

DataContext by itself is an interface, so you can implement it by yourself if you need to (it is the intent of this interface). We do provide one default implementation, LazyLoadedDataContext, that is based on a DataProviderManager, but this does not fit your needs as you have no control on when it loads its data, so I guess you should implement DataContext by yourself. Note that if only some of the factories need to be reloaded, you can of course delegate the general parts to the default context. This would most probably be the case for the celestial bodies as I doubt you change the JPL ephemerides during the run.

Thanks. Passing data context as a parameter looks promising. I can also have a class that gives the data context whenever data context is required. However it does mean that I will have to change existing code.

I can remove the existing provider from DataProviderManager and load the new provider.

Could make sense to add in Orekit an interface DataContextModifier, whose default implementations would wrap an underlying one. What do you think?

Cheers,
Romain