title: How to pass parameter to JsonSerializer?
body: <p>I have a simple data service :</p>
  
  <pre><code>@GET
  public Data getData(@QueryParam("id") Long id) {
    Data data = dataService.getData(id);
    return data;
  }
  </code></pre>
  
  <p>And a matching <code>DataSerializer</code> that implements <code>JsonSerializer&lt;Data&gt;</code> :
  The <code>DataSerializer</code> is registered to Jackson via :</p>
  
  <pre><code>simpleModule.addSerializer(Data.class , dataSerializer);
  ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(simpleModule);
  </code></pre>
  
  <p>It works well.
  But today , I want to add another <code>Locale</code> parameter , and hope the <code>DataSerializer</code> to output correspondent content :</p>
  
  <pre><code>@GET
  public Data getData(@QueryParam("id") Long id , @QueryParam("locale") Locale locale)
  </code></pre>
  
  <p>The '<code>Data</code>' itself contains various locale variations , and I hope to get the assigned locale output.</p>
  
  <p>But when I get the <code>locale</code> from the parameter , I don't know how to pass the <code>locale</code> value to the <code>DataSerializer</code> …</p>
  
  <p>Is there anyway to achieve this ?</p>
  
  <p>Except this solution :</p>
  
  <pre><code>Data data = dataService.getData(id.get() , locale);
  </code></pre>
  
  <p>which is not what I want.</p>
  
  <p>It seems <code>ThreadLocal</code> is the only way to achieve this , but I feel that is ugly. Any other feasible solutions ?</p>
  
  <p>Thanks.</p>
  
  <p>Environments : dropwizard-0.7.0-rc2 , jackson-core:jar:2.3.1</p>
  
  <p>===================== updated ==========</p>
  
  <p>reply to @andrei-i :</p>
  
  <p>Because my data itself already contains various locale versions.
  for example :</p>
  
  <pre><code>Data helloData = dataService.get("hello");
  helloData.getName(Locale.English) == "Hello";
  helloData.getName(Locale.France) == "Bonjour";
  helloData.getName(Locale.Germany) == "Hallo";
  </code></pre>
  
  <p>I want to directly pass the locale from URL to JsonSerializer , to get one version of the data presentation.</p>
  
  <p>And there 'may' be other version (not just locale) , so , inheriting Data mixing Locale is not considered.</p>