I have jetty running inside karaf and I am able to register a servlet at "/products" but now I want to have another servlet registered at a different context say : /animals ? How to do that ?
Even if create a separate connector on jetty , I'd still have to override the "root" property of the same jaxrs connector that would mean overwriting the previous one which would mean now /animals would work and /products won't.
Any way around this problem ?
private void updateConfiguration() throws IOException
{
LOGGER.info("Entering in method updateConfiguration,Configuration web services will be published on context path: {}", CONTEXT_PATH);
configureJerseyConfiguration();
configureJaxRsPublisher();
}
private void configureJerseyConfiguration()
{
Configuration componentConfiguration;
try
{
componentConfiguration = getServiceConfiguration(JERSEY_SERVER_PID);
Dictionary<String, Object> properties = componentConfiguration.getProperties();
if (properties == null)
{
properties = new Hashtable<String, Object>();
}
properties.put(JERSEY_CONFIG_SERVER_WADL_DISABLE_WADL, DISABLE_WADL_PROPERTY);
componentConfiguration.update(properties);
LOGGER.debug("Inside configureJerseyConfiguration,Configured the Jeresy wadl: {}", DISABLE_WADL_PROPERTY);
}
catch (IOException | ConfigurationException e)
{
LOGGER.error("Inside configureJerseyConfiguration,There was a problem in upgrading the JAX RS connector configuration,Exception occured is: {}", e.getMessage());
}
}
/**
* @param componentContext
*/
private void configureJaxRsPublisher()
{
LOGGER.debug("Entering in method configureJaxRsPublisher,Configuring the JAX RS connector.");
Configuration componentConfiguration;
try
{
componentConfiguration = getServiceConfiguration(JAXRS_CONNECTOR_PID);
componentConfiguration.getBundleLocation();
Dictionary<String, Object> properties = componentConfiguration.getProperties();
if (properties == null)
{
properties = new Hashtable<String, Object>();
}
properties.put("root", "/products"); // <<<<<<<<<<<<<<< Look here
componentConfiguration.update(properties);
LOGGER.debug("Inside configureJaxRsPublisher, Configured the JAX RS connector with contextPath: {}", CONTEXT_PATH);
}
catch (IOException | ConfigurationException e)
{
LOGGER.error("Inside configureJaxRsPublisher,There was a problem in upgrading the JAX RS connector configuration, Exception occured is: {}", e.getMessage());
}
}
Problem:
I have jetty running inside karaf and I am able to register a servlet at "/products" but now I want to have another servlet registered at a different context say : /animals ? How to do that ?
Even if create a separate connector on jetty , I'd still have to override the "root" property of the same jaxrs connector that would mean overwriting the previous one which would mean now /animals would work and /products won't.
Any way around this problem ?