Skip to content

Jersey feature installer

CoreInstallersBundle / JerseyFeatureInstaller

Recognition

Detects classes implementing jakarta.ws.rs.core.Feature and register their instances in jersey.

It may be useful to configure jersey inside guice components:

public class MyClass {
    ...   
    public static class ConfigurationFeature implements Feature {
        @Override
        public boolean configure(FeatureContext context) {
            context.register(RolesAllowedDynamicFeature.class);
            context.register(new AuthValueFactoryProvider.Binder(User.class));
            return true;
        }
    }
}

Inner classes are also recognized by classpath scan.

But often the same could be achieved by injecting Environment instance.

@Singleton
public class MyClass {

    @Inject
    public MyClass(Environment environment) {
        environment.jersey().register(RolesAllowedDynamicFeature.class);
        environment.jersey().register(
                new AuthValueFactoryProvider.Binder(User.class));
    }    
}