title: Resteasy PreProcessInterceptor for logging request attributes (not parameters)
body: <p>We're using JBoss and Resteasy to implement a web service, and one requirement is that we log parameters and attributes passed to the web service before processing starts.  the PreProcessInterceptor is ideal for this.  I have it working and logging the request <em>parameters</em> just fine, but some of the information is going to be passed as attributes, and I can't work out how to access them.</p>
  
  <p>Below is the code I use to log the request parameters; can anyone tell me how to get the attributes as well?</p>
  
  <pre><code>@Provider
  @ServerInterceptor
  public class ParameterLoggingInterceptor implements PreProcessInterceptor {
      @Inject
      private Logger logger;
  
  @Override
  public ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws UnauthorizedException {
      StringBuilder sb = new StringBuilder();
      MultivaluedMap&lt;String, String&gt; mMap = request.getUri().getQueryParameters();
      Set&lt;String&gt; keys = mMap.keySet();
      int mapSize = keys.size();
      if (mapSize &gt; 0) {
          sb.append("Incoming parameters: ");
          int processedParams = 1; 
          for (String key : keys) {
              sb.append(key).append("=");
              sb.append(mMap.get(key));
              if (processedParams &lt; mapSize) {
                  sb.append(", ");
              }
              processedParams++;
          }
          logger.debug(sb.toString());
      }
      return null;
  }
  </code></pre>
  
  <hr>
  
  <p>Edited to add the following in response to Eiden's answer:</p>
  
  <p>Thanks, Eiden.  I just gave it a try.  Do you mean something like the following?  If so, it doesn't seem to work (and if not, please clarify). What attributeName provides is: "org.jboss.weld.context.AbstractConversationContext", and attributeValue is the same. This is the same result I got when using the org.jboss.resteasy.spi.HttpRequest object. </p>
  
  <pre><code>@Provider
  @ServerInterceptor
  public class ParameterLoggingInterceptor implements PreProcessInterceptor {
      @Context HttpServletRequest servletRequest;
  
      @Inject
      private Logger logger;
  
  @Override
  public ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws UnauthorizedException {
      Enumeration&lt;String&gt; attributeNames = servletRequest.getAttributeNames();
      StringBuilder sb = new StringBuilder();
      while (attributeNames.hasMoreElements()) {
          String attributeName = (String) attributeNames.nextElement();
          String attributeValue = (String) servletRequest.getAttribute(attributeName);
          // Do something with attributeValue and attributeName
      }
  }
  </code></pre>