<commit_before>This library allows you to wrap the invocation of Jersey 1 resource methods the way you can with a good ol' servlet `javax.servlet.Filter`.

When writing `Filter`s, it's easy to have code like this:

```
setUpSomeStuff();
chain.doFilter(request, response);
takeSomeMeasurements();
```

Since you're directly in the method invocation chain, you can easily take timing measurements, use local variables, etc.

Jersey has request and response filters, but those don't really do the same thing. They make it easy to inspect or modify incoming requests or outgoing responses, but since your code isn't wrapping the actual invocation of the request processing logic, taking timing measurements or anything else best done with local variables is tricky. You can use thread locals, but it's messy.

Fortunately, Jersey has `ResourceMethodDispatchAdapter` and `ResourceMethodDispatchProvider` which, together with a `RequestDispatcher`, are involved in actually calling your JAX-RS resource methods. You can use these to do `Filter`-style logic that directly wraps the invocation of your resource logic, but it takes a fair amount of wiring.

This library makes that wiring easier by using Guice.

First, define a `ResourceMethodDispatchWrapper`. This is what will actually be involved in the request method invocation. Here, we'll have a wrapper that simply prints out the resource method name that it's invoking.
```
class LoggingWrapper implements ResourceMethodDispatchWrapper {

    private final String resourceMethodName;

    LoggingWrapper(String resourceMethodName) {
        this.resourceMethodName = resourceMethodName;
    }

    @Override
    public void wrapDispatch(Object resource, HttpContext context,
        ResourceMethodDispatchWrapperChain chain) {
        System.out.println("Executing method " + resourceMethodName);
        chain.wrapDispatch(resource, context);
    }
}<commit_msg>clarify wording<commit_after>This library allows you to wrap the invocation of Jersey 1 resource methods like how you can wrap servlets with a good ol' servlet `javax.servlet.Filter`.

When writing `Filter`s, it's easy to have code like this:

```
setUpSomeStuff();
chain.doFilter(request, response);
takeSomeMeasurements();
```

Since you're directly in the method invocation chain, you can easily take timing measurements, use local variables, etc.

Jersey has request and response filters, but those don't really do the same thing as servlet filters. They make it easy to inspect or modify incoming requests or outgoing responses, but since your code isn't wrapping the actual invocation of the request processing logic, taking timing measurements or anything else best done with local variables is tricky. You can use thread locals, but it's messy.

Fortunately, Jersey has `ResourceMethodDispatchAdapter` and `ResourceMethodDispatchProvider` which, together with a `RequestDispatcher`, are involved in actually calling your JAX-RS resource methods. You can use these to do `Filter`-style logic that directly wraps the invocation of your resource logic, but it takes a fair amount of wiring.

This library makes that wiring easier (with an assist from Guice).

First, define a `ResourceMethodDispatchWrapper`. This is what will actually be involved in the request method invocation. Here, we'll have a wrapper that simply prints out the resource method name that it's invoking.
```
class LoggingWrapper implements ResourceMethodDispatchWrapper {

    private final String resourceMethodName;

    LoggingWrapper(String resourceMethodName) {
        this.resourceMethodName = resourceMethodName;
    }

    @Override
    public void wrapDispatch(Object resource, HttpContext context,
        ResourceMethodDispatchWrapperChain chain) {
        System.out.println("Executing method " + resourceMethodName);
        chain.wrapDispatch(resource, context);
    }
}
{'fraction_non_alphanumeric': 0.054681454733041014, 'fraction_numerical': 0.0005158627805003869, 'mean_word_length': 4.866868381240544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3969022', 'n_tokens_mistral': 927, 'n_tokens_neox': 864, 'n_words': 466}