Skip to content

Add Dropwizard 1.0.0 Support #86

Merged
jhaber merged 3 commits into
HubSpot:masterfrom
alianza-dev:master
Aug 5, 2016
Merged

Add Dropwizard 1.0.0 Support #86
jhaber merged 3 commits into
HubSpot:masterfrom
alianza-dev:master

Conversation

@heldeen
Copy link
Copy Markdown

@heldeen heldeen commented Aug 1, 2016

This adds support for dropwizard 1.0. I didn't see a contributions type doc so let me know if there is one and/or there need to be any changes for this to be merged.

I'm not completely happy with the baseInjector concept I introduced in GuiceBundle but I wanted to get some feedback before I over engineered it. Everything else seems straight forward to me.

Heath Eldeen added 2 commits August 1, 2016 13:31
    update to latest or dropwizard matching versions of dependencies. Most importantly `io.dropwizard:dropwizard:1.0.0 and `com.squarespace.jersey2-guice:jersey2-guice-impl:1.0.6`
    Update `GuiceBundle` to setup guice and hk2 using the newest `jersey2-guice` way: `com.squarespace.jersey2.guice.JerseyGuiceUtils#install`
    Small tweaks to exists tests to match new dependencies versions of apis
  update `README.md` to match new dependencies apis
@heldeen
Copy link
Copy Markdown
Author

heldeen commented Aug 1, 2016

Oh, also let me know how you'd like me to handle the aopalliance classpath dups that show up. Adding an exclusion to either guice or hk2-api results in an error like:

[WARNING] Exclusions must be removed for managed dependency org.glassfish.hk2:hk2-api:jar

@jhaber
Copy link
Copy Markdown
Member

jhaber commented Aug 1, 2016

Thanks so much! I'll try to get this reviewed and merged this week

@mtraynham
Copy link
Copy Markdown

mtraynham commented Aug 5, 2016

@heldeen, thanks for this! I tried out your branch and it works great! I excluded aopalliance-repackaged on the hk2-api as you've described above and didn't encounter any issue. Just one thing I noticed when building is that metrics-core needed to be added as a dependency.

diff --git a/pom.xml b/pom.xml
index 63f775e..311e353 100755
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,12 @@
                 <groupId>org.glassfish.hk2</groupId>
                 <artifactId>hk2-api</artifactId>
                 <version>2.4.0-b34</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.glassfish.hk2.external</groupId>
+                        <artifactId>aopalliance-repackaged</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>javax.ws.rs</groupId>
@@ -144,6 +150,10 @@
         </dependency>
         <dependency>
             <groupId>io.dropwizard.metrics</groupId>
+            <artifactId>metrics-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.dropwizard.metrics</groupId>
             <artifactId>metrics-healthchecks</artifactId>
         </dependency>
         <dependency>

@heldeen
Copy link
Copy Markdown
Author

heldeen commented Aug 5, 2016

I'm a little weary of excluding aopalliance-repackaged on the hk2-api since that jar contains more classes than the aopalliance jar it's conflicting with. Do you have any knowledge around if or how those extra classes are used?

My bad on the metrics-core dep. I've got it locally but missed it in the commit because I was mucking w/ the dup classes problem.

  exclude `aopalliance-repackaged` from hk2-api until I know better
  add `metrics-core` dependency that was missed due to the duplicate classes problem
@jhaber jhaber merged commit 1cead64 into HubSpot:master Aug 5, 2016
@mtraynham
Copy link
Copy Markdown

mtraynham commented Aug 5, 2016

I think your guess is as good as mine. I tried the exclusion on both. Both passed the tests of this library and both worked with my own webapp. I don't really use Glassfish projects or h2k, so I can't comment on the usage of it. Maven Central does show the package age for each, the Glassfish version is much newer (2016) compared to Guice's dependency (2007).

@heldeen
Copy link
Copy Markdown
Author

heldeen commented Aug 5, 2016

Those are my findings as well @mtraynham. We'll go w/ it until it is a problem. 😄

@mtraynham
Copy link
Copy Markdown

Sounds good to me! Thanks again 🍻

@jhaber
Copy link
Copy Markdown
Member

jhaber commented Aug 5, 2016

We've had 2.4.0-b34 with this exclusion in our basepom for a while without issue so I think it should be fine

@jhaber
Copy link
Copy Markdown
Member

jhaber commented Aug 5, 2016

I just pushed cb924b0 with some POM cleanup and cut a release for version 1.0.0, thanks for the PR!

modules.add(new ServletModule());

initInjector();
JerseyGuiceUtils.install(new ServiceLocatorGenerator() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble injecting Provider<SecurityContext> in my services, I think it's because the install call here is after the initInjector call.

@jhaber @heldeen is there any way you see to make the Jersey services like SecurityContext available?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vvondra, I am able to inject Provider<SecurityContext> in my quick tests. Would you want to create an issue w/ a simple example project that can duplicate the issue you are seeing?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to sum up an example in #87

https://github.com/HubSpot/dropwizard-guice/pull/87/files#r75596536

Maybe it's because I'm not injecting the Provider to a resource, but to a service that is a dependecy of the resource?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants