title: JEE: how to pass parameter to an interceptor
body: <p>In my JEE application, running on glassfish 3, I have the following situation:</p>
  
  <p><strong>MyFacade class</strong></p>
  
  <pre><code>@Interceptors(SomeInterceptor.class)
  public void delete(Flag somethingForTheInterceptor, String idToDelete) {
      .......
  }
  
  @Interceptors(SomeInterceptor.class)
  public void update(Flag somethingForTheInterceptor, MyStuff newStuff) {
      .......
  }
  </code></pre>
  
  <p>The variable <code>somethingForTheInterceptor</code> is not used in these methods, it is only used in the interceptor:</p>
  
  <p><strong>SomeInterceptor class</strong></p>
  
  <pre><code>@AroundInvoke
  public Object userMayAccessOutlet(InvocationContext ctx) throws Exception {
     Flag flag = extractParameterOfType(Arrays.asList(ctx.getParameters()), Flag.class);
     // some checks on the flag
  }
  </code></pre>
  
  <p>Somehow it doesn't feel good to have a parameter that is not used in the method. Is there another way to "send" <code>somethingForTheInterceptor</code> to the interceptor?</p>
  
  <p><strong>UPDATE</strong>: The callers of <code>delete()</code> and <code>update()</code> have different ways of calculating the <code>somethingForTheInterceptor</code> variable. And this is not a constant. The information needed to calculate it is in the REST call. But the 2 REST methods have different input objects so it is not enough to inject the http request. </p>
  
  <p>These are the callers:</p>
  
  <p><strong>MyResource class</strong></p>
  
  <pre><code>@DELETE
  @Path("/delete/{" + ID + "}")
  public Response delete(@PathParam(ID) final String id) {
     Flag flag = calculateFlagForInterceptor(id);
     facade.delete(flag, id);
  }
  
  @POST
  @Path("/update")
  @Consumes(MediaType.APPLICATION_JSON + RestResourceConstants.CHARSET_UTF_8)
  public Response update(final WebInputDTO updateDetails) throws ILeanException {
     Flag flag = calculateFlagForInterceptor(updateDetails);
     facade.update(flag, convertToMyStuff(updateDetails));
  }
  </code></pre>
  
  <p>I was thinking - is it possible for the methods in the Resource to set the flag in some kind of Context, that can be later injected in the Interceptor?</p>