hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
191 stars 98 forks source link

Provide a way to get the root path #142

Open BryanHunt opened 8 years ago

BryanHunt commented 8 years ago

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);
  }
hstaudacher commented 8 years ago

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

BryanHunt commented 8 years ago

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 commented 8 years ago

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.

hstaudacher commented 8 years ago

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.

BryanHunt commented 8 years ago

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

hstaudacher commented 8 years ago

Perfect, thank you!