Page 1 of 1

Configuration changes event ?

Posted: Thu Jan 12, 2023 6:59 pm
by Vince
Hello,

Is there a configuration changes event emitted ?

My use case is to detect proxy settings changes in order to rebuild plugin http client according to this new settings.

Regards,
Vincent

Re: Configuration changes event ?

Posted: Fri Jan 13, 2023 9:29 am
by Radu
Hi Vincent,
We do not have such callbacks, does the client change the HTTP proxy configuration from inside Oxygen or from the operating system?
Regards,
Radu

Re: Configuration changes event ?

Posted: Fri Jan 13, 2023 7:39 pm
by Vince
Hi Radu,

Our plugin load the HTTP proxy configuration from inside Oxygen.
If the settings are modified from preferences pages, we need to restart oXygen to force rebuild the HTTP client and load the new settings.
If an event or callback was sent, we could intercept it to rebuild the client without restarting oXygen.

Thx

Re: Configuration changes event ?

Posted: Mon Jan 16, 2023 9:41 am
by Radu
Hi,

Maybe you can try something like:

Code: Select all

        PluginWorkspaceProvider.getPluginWorkspace().addGlobalOptionListener(new OptionListener() {
          @Override
          public void optionValueChanged(OptionChangedEvent event) {
            if(event.getOptionKey() != null && event.getOptionKey().startsWith("http.proxy")) {
              //Proxy setting changed
            }
          }
        });
Regards,
Radu

Re: Configuration changes event ?

Posted: Mon Jan 16, 2023 12:43 pm
by Vince
I try your suggestion but it doesn't work. No event is recieved.
Regards,
Vicnent

Re: Configuration changes event ?

Posted: Mon Jan 16, 2023 12:56 pm
by Radu
Hi,

Could you tell me exactly what setting you changed in the Oxygen Preferences->"Network Connection Settings / Proxy" page to see if change events are received in the plugin? I could try to test this on my side.

Regards,
Radu

Re: Configuration changes event ?

Posted: Tue Jan 17, 2023 12:30 am
by Vince
In proxy settings page, I changed from direct connection to manual proxy configuration.
I set Web proxy http address and port.
Finally, i saved preferences.

Regards,
Vincent

Re: Configuration changes event ?

Posted: Tue Jan 17, 2023 9:21 am
by Radu
Hi Vincent,

I tested on my side and the code should look something like this:

Code: Select all

      String[] proxyKeys = new String[] {
	  "http.proxy.direct",
          "http.proxy.system",
          "http.proxy.set",
          "http.proxy.manual",
          "http.proxy.port",
          "http.proxy.host",
          "http.proxy.user",
          "http.proxy.password",
      };
      for (int i = 0; i < proxyKeys.length; i++) {
        PluginWorkspaceProvider.getPluginWorkspace().addGlobalOptionListener(new OptionListener(proxyKeys[i]) {
          @Override
          public void optionValueChanged(OptionChangedEvent event) {
            System.err.println(event.getOptionKey());
          }
        });
      }
So you need to add a separate option listener for each Oxygen specific option key related to the proxy.
If you change multiple fields in the preferences, you will receive notifications for each of the changed values.

Regards,
Radu

Re: Configuration changes event ?

Posted: Thu Jan 19, 2023 10:44 am
by Vince
Hello,
Thank you for sharing this code. That works.
Regards,