osgi-jax-rs-connector
osgi-jax-rs-connector copied to clipboard
Provide a way to get the root path
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);
}
Hmm, this is strange. Do you think we need dedicated API to get the root path?
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.
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.
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.
I'll try to do some experimentation this week and see if I can come up with a more concrete proposal.
Perfect, thank you!