This repository has been archived by the owner on Sep 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update bundle and JDBI interfaces, update gradlew, add example applic…
…ation
- Loading branch information
1 parent
537519d
commit b325372
Showing
12 changed files
with
115 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.gradle | ||
.idea | ||
build | ||
out | ||
|
||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ database: | |
driverClass: org.h2.Driver | ||
user: test | ||
password: test | ||
url: jdbc:h2:mem | ||
url: jdbc:h2:mem:db |
32 changes: 32 additions & 0 deletions
32
src/main/java/net/winterly/dropwizard/hk2bundle/jdbi/HandleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.winterly.dropwizard.hk2bundle.jdbi; | ||
|
||
import org.glassfish.hk2.api.Factory; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
import org.skife.jdbi.v2.DBI; | ||
import org.skife.jdbi.v2.Handle; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
public class HandleFactory implements Factory<Handle> { | ||
|
||
private final Provider<DBI> dbi; | ||
|
||
@Inject | ||
public HandleFactory(Provider<DBI> dbi) { | ||
this.dbi = dbi; | ||
} | ||
|
||
@Override | ||
@RequestScoped | ||
public Handle provide() { | ||
return dbi.get().open(); | ||
} | ||
|
||
@Override | ||
public void dispose(Handle instance) { | ||
instance.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/test/java/net/winterly/dropwizard/hk2bundle/ExampleAppBinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
package net.winterly.dropwizard.hk2bundle; | ||
|
||
import net.winterly.dropwizard.hk2bundle.health.ExampleHealthCheck; | ||
import net.winterly.dropwizard.hk2bundle.jdbi.ExampleDAO; | ||
import net.winterly.dropwizard.hk2bundle.jdbi.SqlObjectFactory; | ||
import net.winterly.dropwizard.hk2bundle.metric.ExampleGauge; | ||
import net.winterly.dropwizard.hk2bundle.spi.DropwizardBinder; | ||
import net.winterly.dropwizard.hk2bundle.validation.InjectValidatorBundle; | ||
|
||
import javax.inject.Singleton; | ||
|
||
public class ExampleAppBinder extends DropwizardBinder { | ||
@Override | ||
protected void configure() { | ||
bundle(InjectValidatorBundle.class); | ||
|
||
metric(ExampleGauge.class); | ||
healthCheck(ExampleHealthCheck.class); | ||
|
||
bindFactory(SqlObjectFactory.class) | ||
.to(ExampleDAO.class) | ||
.in(Singleton.class); | ||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
src/test/java/net/winterly/dropwizard/hk2bundle/jdbi/ExampleDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package net.winterly.dropwizard.hk2bundle.jdbi; | ||
|
||
import org.glassfish.hk2.api.UseProxy; | ||
import org.skife.jdbi.v2.sqlobject.Bind; | ||
import org.skife.jdbi.v2.sqlobject.SqlQuery; | ||
|
||
@UseProxy | ||
public interface ExampleDAO { | ||
|
||
@SqlQuery("SELECT :i") | ||
int selectNumber(int i); | ||
int selectNumber(@Bind("i") int i); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters