title: How can I control @Provider in JAX-RS runtime
body: <p>I'm using a customised ContextResolver with my JAX-RS application.</p>
  
  <pre class="lang-java prettyprint-override"><code>@Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  @Provider
  public class ObjectMapperContextResolver
      implements ContextResolver&lt;ObjectMapper&gt; {
  
      public ObjectMapperContextResolver() {
          super();
          // I want to control this
          objectMapper = new ObjectMapper()
              .configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
          objectMapper.registerModule(new JaxbAnnotationModule());
      }
  
      @Override
      public ObjectMapper getContext(final Class&lt;?&gt; type) {
          return objectMapper;
      }
  
      private final ObjectMapper objectMapper;
  }
  </code></pre>
  
  <p>As you can see, there is an option(<code>MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME</code>) customised.</p>
  
  <p>How can I turn off that option on demand in JAX-RS resources?</p>
  
  <pre class="lang-java prettyprint-override"><code>@Path("/items")
  public class ItemsResource {
  
      @GET
      @Produces({APPLICATION_JSON, APPLICATION_XML})
      public Response read(@QueryParam("wrap") final boolean wrap) {
          if (wrap) {
              // turn off MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME
              // and then return response of [Items]
          } else {
              // turn on MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME
              // and then return response of [List&lt;Item&gt;]
          }
      }
  }
  </code></pre>
  
  <p>Is there any way to be injected with the provider?</p>