views:

70

answers:

0

I am using Jersey 1.4 ea together with Spring 3.0 and the jersey-spring integration. Integrating Jersey and Spring works fine for resource classes as described here. How ever I want to inject a spring component into a ContainerRequestFilter to do some pre-processing of requests.

@Component
public class SecurityFilter implements ContainerRequestFilter {

    // UserManager is a declared spring component
    // Injecting it should work somehow
    @Autowired
    private UserManager userManager;

    @Override
    public ContainerRequest filter(ContainerRequest request) {
        System.out.println(userManager);
        // prints out null on request
    }
}

Both the filter and the user manager bean are registered when I deploy the application to Glassfish. I wonder what am I doing wrong. Is there a way to inject a spring managed bean into a ContainerRequestFilter?