dropwizard

Create @UnitOfWork-aware proxies of existing objects

一曲冷凌霜 提交于 2019-12-12 16:39:08
问题 I have the following classes: public FooDAO extends AbstractDAO<Foo> { // Dropwizard DAO @Inject FooDAO(SessionFactory sf) { super(sf); } public void foo() { /* use SessionFactory */ } } public class FooService { private final FooDAO fooDAO; // Constructor-injected dependency @Inject FooService (FooDAO fooDAO) { this.fooDAO = fooDAO; } @UnitOfWork public void foo() { this.fooDAO.foo(); System.out.println("I went through FooService.foo()"); } } Now, FooService is not a resource, so Dropwizard

How to use swagger with dropwizard .0.7.0

柔情痞子 提交于 2019-12-12 08:16:47
问题 I have the latest dropwizard setup. Now I have created a simple API and I am trying to add Swagger on top. There is a Swagger implementation for dropwizard but the sample code is against Yammer dropwizard 0.6.2 which requires addProvider and addResource. The io.dropwizard environment doesn't seem to have this function. Can you please let me know how I can do this under io.dropwizard? 回答1: For Dropwizard 0.7.0 I configure swagger like this: void configureSwagger(Environment environment) {

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present

雨燕双飞 提交于 2019-12-12 05:14:15
问题 I Am not able to fetch data from Rest Server.Following Error is coming: "Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access." Response is coming as "0", This is not hitting the Rest Method also. Rest APT: @POST @Timed @Path("updateScore") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateScore

Dropwizard customAuthorizationFilter with DynamicFeature

牧云@^-^@ 提交于 2019-12-12 05:04:48
问题 I have followed all the steps given in Answer by pandadb in below link How to Optionally Protect a Resource with Custom Dropwizard Filter I added my custom annotaion to the resource method but the custom authorisation filter is not being called. can anyone tell me what i might have missed. Update:- I am using dropwizard 1.0 using java8 and building the app using maven. 回答1: First of all check this Dropwizard Feature example and Dropwizard Authorization. Then please provide more details, what

Parse request parameters without writing wrapper class

泄露秘密 提交于 2019-12-12 04:29:51
问题 How to handle json requests and parse the request parameters in dropWizard? @POST @Path("/test") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String test(@Context final HttpServletRequest request) { JSONObject data=new JSONObject(); System.out.println(request); System.out.println(request.getParameterMap()); System.out.println(">>>>>>>>>"); return "{\"status\":\"ok\"}"; } I wrote the above code and tried the following request. curl -XPOST -H "Content-Type:

Dropwizard Jersey set URL pattern breaking Swagger 404?

旧街凉风 提交于 2019-12-12 04:08:25
问题 I added swagger to my Dropwizard service a while back and it was working fine. However now that I am wanting to add a simple html page and configure the resource path to serve content from /assets it has broken swagger and the api with 404 responses This is my code public class NumericodeApplication extends Application<NumericodeConfiguration> { public static void main(final String[] args) throws Exception { new NumericodeApplication().run(args); } @Override public String getName() { return

Is it possible to expose Dropwizard metrics in logs

大兔子大兔子 提交于 2019-12-11 17:06:01
问题 I'm trying to set up a logging scheme in an application to show the thread count count in Dropwizard. When I go to the admin port on 8081, I can see the metrics that Dropwizard provides for an application. For example, under Gauges, you can see jvm.memory.total.used, along with the value. I'd like to set up the slf4j logs to show that in some of my requests. So, for example, my GET requests might look something like this: @GET @TIME @Produces(MediaType.Application_JSON) public List<String>

Postgresql array comparision with List input Dropwizard JDBI

試著忘記壹切 提交于 2019-12-11 15:47:19
问题 My question is similar to this PostgreSQL check if array contains any element from left-hand array but I want to execute (same query which is given in the above question) i.e. "&& operator" query via code. Dropwizard + JDBI framework. @SqlQuery("SELECT ARRAY[1,2,3,4] && <input_array>") public abstract Object query(@BindIn("input_array") List<Integer> list); @BindIn annotation does not work. Getting below error. ! org.postgresql.util.PSQLException: ERROR: operator does not exist: integer[] &&

Dropwizard Yaml for graphite server configuration

社会主义新天地 提交于 2019-12-11 13:07:55
问题 I am using metrics with dropwizard and I am reporting these to the graphite server. Almost the same way described in the tutorial. https://dropwizard.github.io/metrics/3.1.0/manual/graphite/#manual-graphite But I wanted to configure the graphite properties in the dropwizard yaml file. Something like the following metrics: reporters: - type: graphite host: graphite_server port: 2003 prefix: some_example_metrics How do I then configure this in my dropwizard configuration class in order to use

Two Exception Mappers in Dropwizard

笑着哭i 提交于 2019-12-11 12:23:42
问题 I have parent pom with Dropwizard service. In that service I have some exception mapper declaration, for example: @Provider class ExceptionMapperForClassA {...} Now in my child pom I'm extending this parent service and I want to create New Exception mapper for ClassA and I would like to extend it from ExceptionMapperForClassA . I couldn't find any information in Jersey doc, which describes behaviour of Jersey when two exception mappers for same class are declared. https://jersey.java.net