New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guice will not inject properties on JndiDataSourceProvider in PrivateModules #19

Merged
merged 3 commits into from Feb 25, 2014

Conversation

Projects
None yet
3 participants
@jeffgbutler
Member

jeffgbutler commented Feb 21, 2014

This may be a bug in Guice. The problem is that properties are not being injected into the JndiDataSourceProvider when it is used in a PrivateModule. This patch fixes the issue by making an injection required on the constructor (as the other DataSource providers work). I believe this is an acceptable change to make because the jndi.dataSource property is really a required property - it had been set as optional previously.

public void setInitialContext(@Named("jndi.initialContext") final String initialContext) {
properties.setProperty(JndiDataSourceFactory.INITIAL_CONTEXT, initialContext);
@Inject
public JndiDataSourceProvider(@Named("jndi.dataSource") final String dataSource) {

This comment has been minimized.

@jeffgbutler

jeffgbutler Feb 21, 2014

Member

Adding a required injection to the constructor seems to "wake up" Guice and all the other properties will be injected as expected.

@jeffgbutler

jeffgbutler Feb 21, 2014

Member

Adding a required injection to the constructor seems to "wake up" Guice and all the other properties will be injected as expected.

@christianpoitras

This comment has been minimized.

Show comment
Hide comment
@christianpoitras

christianpoitras Feb 25, 2014

Member

It seems reasonable.
Personally, I don't see how jndi.dataSource can be optional.

Member

christianpoitras commented Feb 25, 2014

It seems reasonable.
Personally, I don't see how jndi.dataSource can be optional.

jeffgbutler added a commit that referenced this pull request Feb 25, 2014

Merge pull request #19 from jeffgbutler/master
Guice will not inject properties on JndiDataSourceProvider in PrivateModules

@jeffgbutler jeffgbutler merged commit 5b5cc6b into mybatis:master Feb 25, 2014

1 check passed

default The Travis CI build passed
Details

@emacarron emacarron added the bug label Mar 15, 2014

@emacarron emacarron added this to the 3.6 milestone Mar 15, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment