Dropwizard/Jersey Resources and interfaces

313 views
Skip to first unread message

Brent Ryan

unread,
Jul 6, 2014, 10:37:34 PM7/6/14
to dropwiz...@googlegroups.com
Is it possible with Dropwizard to define a resource like this using interfaces?

@Path("/myResource")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface MyResource {

   @POST
   @Timed
   Response createSomething();
}

public class MyResourceImpl implements MyResource {

   @Override
   public Response createSomething() {
         ...//do some stuff
   }
}

When I tried several different patterns of adding this resource I couldn't get it to register with jersey properly.

environment.jersey().register(new MyResourceImpl());


The primary reason for even having this interface is so that we can dynamically generate a client from this interface by doing something like:

        DropwizardClientProxy<MyResource> clientProxy = new DropwizardClientProxy(config, e, MyResource.class);
        MyResource myResource = clientProxy.getResourceInterface();
        Response r = myResource.createSomething();

We got everything working to support this, but the only way we can get this working currently is to duplicate the annotations on the interface and the implementation.  I've read that a bunch of things like this seem to be supported in Jersey 2 (haven't tried it yet), but it seems like this should work with Jersey 1...

Anyone ever get this to work?


Thanks,
Brent

Brent Ryan

unread,
Jul 6, 2014, 11:27:17 PM7/6/14
to dropwiz...@googlegroups.com
So I found this post "http://jersey.576304.n2.nabble.com/Annotations-in-interfaces-how-to-use-with-jersey-td7582032.html" and it looks like JAX-RS just has some crappy specifications for how to handle annotation inheritance and Jersey is just implementing that crappy spec related to this.

If I remove all method, class, and parameter annotations from my concrete MyResourceImpl class then it works as expected.  This kinda sucks because you can't use things like @Override and I'm not sure this will really work anyways for other parameter level annotations that are required....

Let me know if someone finds other solutions to this problem.

Thanks!
Message has been deleted
Message has been deleted

Kevin Bunn

unread,
May 23, 2024, 6:14:39 AMMay 23
to dropwizard-user
https://t.me/dannyw23official
 
 
Polkadot Magic  Belgian Milk Chocolate is not only delicious, but it equates to 4 grams of psilocybin-containing . Aside from the fantastic, mind-blowing effects, you get from eating the bars and polka dot company chocolate, they are also a great way to microdose magic . Microdosing magic in the form of consumption. Polkadot Magic Belgian Milk Chocolate is not only delicious, but it equates to 4 grams of psilocybin-containing . Aside from the fantastic, mind-blowing effects, you get from eating the and polka dot company chocolate, they are also a great way to microdose magic  Microdosing magic in the form of consuming  chocolate bars 
 
 
 
 
 
 

Konyu Godwin

unread,
Jun 9, 2024, 11:41:21 AMJun 9
to dropwizard-user
There is a growing number of people who wish to buy shrooms online. It is often hard to tell which form of products to buy since you cannot see it physically. This is sometimes peculiar to newbies who haven’t tried shrooms before. They just don’t know how to go about it. Shroom Edibles are not so popularly discussed as often as you think. A lot of experienced shroom users have not even had a taste of these Psilonauts Psilocybin Chocolate Bar goodness that offer a premium psychedelic trip.
https://t.me/trippyworld710/911
https://t.me/trippyworld710/908?single
https://t.me/trippyworld710/882?single
https://t.me/trippyworld710/879?single
https://t.me/trippyworld710/877
https://t.me/trippyworld710/872?single
https://t.me/trippyworld710/870
https://t.me/trippyworld710/865
https://t.me/trippyworld710/864
https://t.me/trippyworld710/863?single
https://t.me/trippyworld710/859?single
https://t.me/trippyworld710/848
https://t.me/trippyworld710/844
https://t.me/trippyworld710/841
https://t.me/trippyworld710/837
https://t.me/trippyworld710/833
https://t.me/trippyworld710/831?single
https://t.me/trippyworld710/829?single
https://t.me/trippyworld710/823?single
https://t.me/trippyworld710/821
https://t.me/trippyworld710/817
https://t.me/trippyworld710/816
https://t.me/trippyworld710/815
https://t.me/trippyworld710/811
https://t.me/trippyworld710/810
https://t.me/trippyworld710/808
https://t.me/trippyworld710/806
https://t.me/trippyworld710/803
https://t.me/trippyworld710/790
https://t.me/trippyworld710/783?single
https://t.me/trippyworld710/780
https://t.me/trippyworld710/779?single
https://t.me/trippyworld710/769
https://t.me/trippyworld710/754
https://t.me/trippyworld710/741
https://t.me/trippyworld710/737
https://t.me/trippyworld710/732
https://t.me/trippyworld710/730
https://t.me/trippyworld710/727
https://t.me/trippyworld710/724
https://t.me/trippyworld710/704
https://t.me/trippyworld710/679?single
https://t.me/trippyworld710/655
https://t.me/trippyworld710/649?single
https://t.me/trippyworld710/648
https://t.me/trippyworld710/647
https://t.me/trippyworld710/570?single
https://t.me/trippyworld710/557?single
https://t.me/trippyworld710/552?single
https://t.me/trippyworld710/547
https://t.me/trippyworld710/545?single
https://t.me/trippyworld710/537
https://t.me/trippyworld710/522
https://t.me/trippyworld710/519?single
https://t.me/trippyworld710/484?single
https://t.me/trippyworld710/448?single
https://t.me/trippyworld710/446
https://t.me/trippyworld710/211
https://t.me/trippyworld710/198
https://t.me/trippyworld710/183?single
https://t.me/trippyworld710/182
Reply all
Reply to author
Forward
Message has been deleted
0 new messages