dropwizard

Implementing long polling server using Dropwizard 0.7.0

点点圈 提交于 2019-11-30 22:08:27
问题 I'm trying to implement a long polling server using Dropwizard 0.7.0 framework. I've been suggested to use jetty integration. After some googling, I got really confused by things like websockets, jetty continuation, cometd. My question is, what are these things and which one should I choose? And any example is really appreciated! Edited Our server has many clients, including mobile (ios, android), pc and web. Is websocket only available in web browser? 回答1: Websocket is available in all the

JDBI How can I dynamically create a WHERE clause while preventing SQL Injection?

风流意气都作罢 提交于 2019-11-30 21:14:57
I want to dynamically filter a JDBI query. The a list of parameters is passed from the UI via REST e.g. http://localhost/things?foo=bar&baz=taz http://localhost/things?foo=buz Which is (clumsily) built (Jersey @Context UriInfo::getQueryParameters -> StringBuilder) to something like this: WHERE foo=bar AND baz=taz And passed to JDBI which looks like this: @UseStringTemplate3StatementLocator public interface ThingDAO { @SqlQuery("SELECT * FROM things <where>) List<Thing> findThingsWhere(@Define("where") String where); } As far as I understand the current implementation is vulnerable to SQL

how to get my configuration values in yml - using dropwizard (microservice) Jersey D.I @Injection?

こ雲淡風輕ζ 提交于 2019-11-30 20:23:34
here's my code snippets. here's my yml file: productionServer: host: production-server.amazonaws.com publicIp: xx.xx.xx.xx privateIp: xx.xx.xx.xx userName: xx.xx.xx.xx password: xx.xx.xx.xx remoteFilePath: fake/path/ fileName: test.txt privateKey: private-public-key.ppk server: applicationConnectors: - type: http port: 8080 - type: https port: 8443 keyStorePath: key.keystore keyStorePassword: password validateCerts: false adminConnectors: - type: http port: 8081 - type: https port: 8444 keyStorePath: key.keystore keyStorePassword: password validateCerts: false MyConfiguration class: import io

Running async jobs in dropwizard, and polling their status

跟風遠走 提交于 2019-11-30 20:02:32
问题 In dropwizard, I need to implement asynchronous jobs and poll their status. I have 2 endpoints for this in resource: @Path("/jobs") @Component public class MyController { @POST @Produces(MediaType.APPLICATION_JSON) public String startJob(@Valid MyRequest request) { return 1111; } @GET @Path("/{jobId}") @Produces(MediaType.APPLICATION_JSON) public JobStatus getJobStatus(@PathParam("id") String jobId) { return JobStatus.READY; } } I am considering to use quartz to start job, but only single

How to maintain user sessions in DropWizard?

人盡茶涼 提交于 2019-11-30 19:57:56
I am looking for a persistent session manager which saves the session on file system (like PHP) that can be used with DropWizard. I see there is one Environment.getSessionHandler() , but I see no documentation on it. I could write my own but I am hoping for a cooked meal. Will the above SessionHandler is what I am looking for? And how to use that? With dropwizard>0.7 environment.jersey().register(HttpSessionProvider.class); environment.servlets().setSessionHandler(new SessionHandler()); And then use @Session annotation in your resource classes. Madhan Dennis DropWizard does not support

IllegalStateException within method with Response paramether

半腔热情 提交于 2019-11-30 18:02:39
I wrote a simple class to test response reading entity method (if it works as I expect). But it didn't worked well. When I launch my class I get following error at response.readEntity() : Exception in thread "main" java.lang.IllegalStateException: Method not supported on an outbound message. at org.glassfish.jersey.message.internal.OutboundJaxrsResponse.readEntity(OutboundJaxrsResponse.java:150) And here's the code I wrote public static void main(String[] args) { List<Entity> representations = new ArrayList<>(); representations.add(new Entity("foo", "baz", false)); representations.add(new

Dropwizard: How to stop service programmatically

夙愿已清 提交于 2019-11-30 17:53:19
To start the service, I know one uses new MyService().run(args) . How to stop it? I need to start and stop programmatically for setUp() and tearDown() in my tests. You can start the service in new thread, once the test ends the service will shutdown automatically. However starting in dropwizard 0.6.2 the dropwizard-testing module contains a junit rule exactly for this use case ( see here ). Usage of this rule will look something like this: Class MyTest { @ClassRule public static TestRule testRule = new DropwizardServiceRule<MyConfiguration>(MyService.class, Resources.getResource("service.yml")

Looking for a dropwizard example [closed]

北城以北 提交于 2019-11-30 10:48:51
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 months ago . Looking for a dropwizard example I found: https://github.com/codahale/dropwizard/tree/master/dropwizard-example But I am interested in a more complete example with at least: a 1:n relationship like customer - account a html gui represenation at least with forms full crud support for xml 2 out of three would be

Overriding server connector config with env variables with dropwizard

假装没事ソ 提交于 2019-11-30 06:56:55
问题 I have posted this question on dw mailing list but didnt get an answer. Can I assume the YML format below doesnt work for DW 0.7.0 anymore? (The use of @ char to insert env var) server: applicationConnectors: - type: http bindHost: @OPENSHIFT_DIY_IP@ port: @OPENSHIFT_DIY_PORT@ Error: Malformed YAML at line: 28, column: 17; while scanning for the next token; found character @ '@' that cannot start any token. (Do not use @ for indentation); in 'reader', line 28, column 17: bindHost: @OPENSHIFT

Enabling cors in dropwizard not working

别来无恙 提交于 2019-11-30 06:36:54
I'm working on a dropwizard application and js ui to interacte with the api. I need to load json data to update views but I have to enable cors in dropwizard before that. I did some staff but it seems not working because dropwizard returns allways 204 no content. @Override public void run(final BGConfiguration configuration, final Environment environment) throws Exception { final Map<String, String> params = new HashMap<>(); params.put("Access-Control-Allow-Origin", "/*"); params.put("Access-Control-Allow-Credentials", "true"); params.put("Access-Control-Expose-Headers", "true"); params.put(