osgi-jax-rs-connector icon indicating copy to clipboard operation
osgi-jax-rs-connector copied to clipboard

Provide a way to get the root path

Open BryanHunt opened this issue 8 years ago • 6 comments

I need a way to get the root path for the registered resources. I tried registering a ConfigurationListener, and while I get the event when I configure the service root, the root key is not present in the service properties. Here is the code I tried:

  @Override
  public void configurationEvent(ConfigurationEvent event)
  {
    if(!"com.eclipsesource.jaxrs.connector".equals(event.getPid()) || event.getType() != ConfigurationEvent.CM_UPDATED)
      return;

    root = (String) event.getReference().getProperty("root");
    System.out.println("root: " + root);
  }

BryanHunt avatar Mar 19 '16 03:03 BryanHunt

Hmm, this is strange. Do you think we need dedicated API to get the root path?

hstaudacher avatar Apr 06 '16 15:04 hstaudacher

What I really need is a way to get the base uri of the server. I hacked some code together that does this by creating my own service to set the root and notify a root listener. I works, but it's kinda ugly.

One thing I didn't try was getting the config from ConfigurationAdmin when I get the change event to see if the root value comes back.

BryanHunt avatar Apr 06 '16 15:04 BryanHunt

Another thing to consider ... I believe when you set the root from a remote master using a REST call, the master may not get a good response code since Jersey can be reconfigured before the response is sent. It might be necessary to delay the setting of the root config.

Also, if the root config is set from some other mechanism (code or the Felix web console), I need a way to be notified of that change.

BryanHunt avatar Apr 06 '16 18:04 BryanHunt

But this is all done via config admin right? So, the config admin should send out the notification about changes to ConfigurationListeners. Not sure what is to do here.

hstaudacher avatar Apr 06 '16 18:04 hstaudacher

I'll try to do some experimentation this week and see if I can come up with a more concrete proposal.

BryanHunt avatar Apr 06 '16 18:04 BryanHunt

Perfect, thank you!

hstaudacher avatar Apr 06 '16 18:04 hstaudacher