Hi,

I am sorry if this question has been addressed before. I searched the
forums but I didn't find anything that could resolve my issue. I am
trying to inject a JDBC connection into my TransactionInterceptor that
I have registered with my Guice AOP module. To return a connection, I
am providing a DataSource that is injected into my Connection provider
to return a connection. When I use regular Provider instead of
ThrowingProvider, I am able to inject a connection, but Guice throws
an configuration error

No implementation for java.sql.Connection annotated with
@com.guicejdbc.transaction.support.ThrowingProviderIssueTest
$DatabaseAnnotation() was bound. But I was able to detect the binding
in the Injector
ProviderInstanceBinding[key=Key[type=com.guicejdbc.transaction.support.ThrowingProviderIssueTest.com.guicejdbc.transaction.support.ThrowingProviderIssueTest
$DefaultConnectionProvider<java.sql.Connection>,
annotati...@com.guicejdbc.transaction.support.throwingproviderissuetest
$DatabaseAnnotation],
source=com.google.inject.throwingproviders.ThrowingProviderBinder
$SecondaryBinder.to(ThrowingProviderBinder.java:110),
scope=Scopes.NO_SCOPE,
provider=com.google.inject.throwingproviders.ThrowingProviderBinder
$secondarybinde...@1042fcc]

My module binding when using ThrowingProviders is given below:

public static final class ThrowingProviderIssueModule extends
AbstractModule {
                @Override
                protected void configure() {
                        ThrowingProviderBinder.create(binder()).bind(
                                DefaultConnectionProvider.class, 
Connection.class)
                        
.annotatedWith(DatabaseAnnotation.class).to(ConnectionProvider.class);
                        
bind(DataSource.class).toProvider(DataSourceProvider.class);
                }
        }

My provider implementations
public interface DefaultConnectionProvider<T> extends
ThrowingProvider<T, SQLException> {}

private static final class ConnectionProvider implements
DefaultConnectionProvider<Connection> {
                private final DataSource dataSource;
                @Inject
                public ConnectionProvider(DataSource dataSource) {
                        this.dataSource = dataSource;
                }
                @Override
                public Connection get() throws SQLException {
                        return this.dataSource.getConnection();
                }
}

Any advice on resolving this issue would be appreciated.

My binding when not using ThrowingProvider
private static final class WorkingModule extends AbstractModule {
                @Override
                protected void configure() {
                        
bind(Connection.class).annotatedWith(DatabaseAnnotation.class)
                            .toProvider(RegularConnectionProvider.class);
                        
bind(DataSource.class).toProvider(DataSourceProvider.class);
                }
        }

I can try to upload my test but I am not able to upload any files on
this group.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to