Allow Feature to register resources
It would be nice if javax.ws.rs.core.Features could also be used to register resources as well (and not only providers).
Then I could package a complete API unit like this:
public class AdminFeature implements Feature {
@Override
public boolean configure(FeatureContext context) {
context.register(AdminMessageBodyWriter.class);
context.register(AdminExceptionMapper.class);
context.register(AdminFilter.class);
context.register(UsersResource.class);
context.register(RolesResource.class);
context.register(JobsResource.class);
return true;
}
}
And in my application, I would only have to do:
@ApplicationPath("api")
public class MyApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
return Set.of(
AdminFeature.class, // registers providers + resources
SpecificResource.class,
SpecificFilter.class
);
}
}
I know resources don't have a contract to be registered for but if that is a problem, a new method (FeatureContext.registerResource) could be added.
I currently do not see a need for this. Can you please share a real-world use case?
I can see some value in the proposal, but I'd like to know more about the problem that this solves. It seems like you could package the classes configured in the AdminFeature into it's own "admin.jar" and then package that JAR file in another WAR file - then use auto-discovery (via @Path and @Provider annotations) for them to be auto-registered.
Thanks for opening the issue.