Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure multiple Jersey provider packages using javax dynamic servlet registration

I am using javax.servlet.Registration to dynamically configure/register servlets.

I'd like to know how I could configure multiple provider packages for Jersey. I can add a single package using the setInitParamater method as follows:

public class MyWebInitalization implements WebApplicationInitializer {

  @Override
  public void onStartup(final ServletContext servletContext) throws ServletException {
    //... some code
    final ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", ServletContainer.class);
    dispatcher.setInitParameter("jersey.config.server.provider.packages", "com.package1"); // how to add more packages?
    //... more code
  }
} 

To give you an idea of what I mean, this is an equivalent if I would have used web.xml:

<servlet>
    ...
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.package1;com.package2</param-value>
    </init-param>
    ...
</servlet>
like image 331
Diyarbakir Avatar asked Sep 23 '15 09:09

Diyarbakir


1 Answers

Do you try something like this dispatcher.setInitParameter("jersey.config.server.provider.packages", "com.package1;com.package2"); ?

like image 55
Dzmitry Dydyshka Avatar answered Nov 07 '22 22:11

Dzmitry Dydyshka