HubSpot/dropwizard-guice

Question: AOP requires binding resources with Guice?

Closed this issue · 1 comments

oddcb commented

Hi, I have the following setup for GuiceBundle in initialize:

guiceBundle = GuiceBundle.<AppConfiguration>newBuilder()
        .addModule(new AppModule)
        .setConfigClass(AppConfiguration.class)
        .build(Stage.DEVELOPMENT);

        bootstrap.addBundle(guiceBundle);

Resources are setup with the normal env.jersey().register(SomeResource.class) and get their dependencies injected. But it seems our intercept setup in Guice is not running on requests to the resources:

// class-level @Transacational
bindInterceptor(annotatedWith(Transactional.class), any(), transactionInterceptor);
// method-level @Transacational
bindInterceptor(any(), annotatedWith(Transactional.class), transactionInterceptor);

As per Squarespace/jersey2-guice#17 I've registered the resources also in Guice with just a normal bind(SomeResource.class) and then the interceptor works. Is there a way to avoid duplicating this registration?

oddcb commented

Nevermind. Just registrering them in Guice gets them properly setup as resources. :-)