dropwizard

Jersey custom method parameter injection with inbuild injection

旧城冷巷雨未停 提交于 2019-11-30 05:27:26
问题 Hello I am building an application using dropwizard, that is using jersey 2.16 internally as REST API framework. For the whole application on all resource methods I need some information so to parse that information I defined a custom filter like below @java.lang.annotation.Target(ElementType.PARAMETER) @java.lang.annotation.Retention(RetentionPolicy.RUNTIME) public @interface TenantParam { } The tenant factory is defined below public class TenantFactory implements Factory<Tenant> { private

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

↘锁芯ラ 提交于 2019-11-30 04:47:59
问题 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

How to use IN operator with JDBI?

巧了我就是萌 提交于 2019-11-30 02:50:53
问题 I'm trying to do a IN query using MYSQL JDBI on Dropwizard (not relevant, I assume). @SqlQuery("SELECT id FROM table where field in (<list>)") List<Integer> findSomething(@BindIn("list") List<String> someList); As suggested here, I've also annotated the class with @UseStringTemplate3StatementLocator But when I'm starting the application, I get the following error: Exception in thread "main" java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.skife

DropWizard:用Java轻轻的写一个RESTful Service

落花浮王杯 提交于 2019-11-30 01:03:09
1.关于Dropwizard的一些闲扯 在我的上一篇博客《 Embedded Server:像写main函数一样写Web Server 》中,提到了使用Jetty Embedded Server进行 Java Web Server的开发比传统的Web Container 的方式进行开发的优势。如果直接使用Jetty提供的API进行Web Server的开发,特别是RESTful service的开发,难免看起来还是简单粗暴了一些。 然后期望着更多的程序员逃离java世界,奔向看起来很美好的Ruby, Python等等。我自己而言,我不关心java是不是已经死在沙滩上了,更多的是想,新语言引入的新的技术,或者一些新的思潮,能够折射出我们Java语言或者开发环境中的哪些不足。 有很多用Ruby on Rails的人,在对ruby知之甚少的情况下,就开始吭哧吭哧的写Server了。Rails提供了开发一个Server的完整技术栈,可以很方便的进行开发,后来又有很多人提供了很多RoR的的插件。 Dropwizard也是这么一个东西,提供了使用Java进行RESTful开发的所需要的最小的技术集合,使用了最轻量级的library。如之前博客里提到的Jetty,还有Jersey,Jackson等等。在Dropwizard官网上对其自身的介绍还是比较客气的

Looking for a dropwizard example [closed]

不想你离开。 提交于 2019-11-29 22:33:11
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 a start and would earn "accepted" by me. Take a look at some of my Dropwzard projects In particular the MultiBit Merchant projects (Admin, Store and Platform) will provide you with a wealth of demonstration code that shows how to get stuff done in Dropwizard. There is also an example of

Issue with custom Authorization in DropWizard

让人想犯罪 __ 提交于 2019-11-29 16:32:48
I am trying to add custom authorization in dropwizard but not able to successed. I have a custom authentication added for dropwizard by binding it to authFactory Authenticator ssoAuthenticator = createSSOAuthenticator(configuration.getSsoGrantClientConfiguration()); environment.jersey().register(AuthFactory.binder( new SSOTokenAuthFactory<SSOGrant>( ssoAuthenticator, SYSTEM_PREFIX, SSOGrant.class)) ); and adding a dynamicfeature for authorization environment.jersey().register(PermissionDynamicFeature.class); Below is the annotation created @Documented @Retention(java.lang.annotation

Getting object from @PathParam

烈酒焚心 提交于 2019-11-29 12:54:07
I'm creating a RESTful service for accessing data. So I started writing that service, first I created a ReadOnlyResource interface with the following code: public interface ReadOnlyResource<E, K> { Collection<E> getAll(); E getById(K id); } Where E is the returned type and K is the key element. So if I'm implementing with <Integer, Integer> I'll inject the key like t @GET @Path("/{id}") @Override public Integer getById(@PathParam("id") Integer id) { return null; } But when my key is more complex, like this: public class ComplexKey { private String name; private int value; } How can I inject

Can DropWizard serve assets from outside the jar file?

百般思念 提交于 2019-11-29 11:47:08
问题 In looking at the documentation, it appears that DropWizard is only able to serve static content living in src/main/resources. I'd like to keep my static files in a separate directory outside the jar file. Is that possible? Or do most people use nginx/Apache for their static content? 回答1: yes, it can, using this plugin - https://github.com/bazaarvoice/dropwizard-configurable-assets-bundle 回答2: Working off of Marcello Nuccio's answer, it still took me the better part of my day to get it right,

Access HttpServletRequest from an Authenticator using Dropwizard

☆樱花仙子☆ 提交于 2019-11-29 11:42:35
Using DropWizard(Jersey Server), Is it possible to access HttpServletRequest from an Authenticator? I would give it an attribute. I tried with: @Context private HttpServletRequest servletRequest; But it's not injected. I registered my Authenticator using: env.jersey().register( new AuthDynamicFeature(new BasicCredentialAuthFilter.Builder<User>().setAuthenticator(new FooAuthentificator()) .setRealm("Realm").buildAuthFilter())); It's possible, but the problem is, the Authenticator never goes through the DI lifecycle, so it never gets a chance to get injected. What we can do though is explicitly

DropWizard Auth Realms

落花浮王杯 提交于 2019-11-29 07:06:05
In DropWizard, I can set up basic auth like so (in the Application#run impl): BasicAuthProvider<SimplePrincipal> authProvider = new BasicAuthProvider(authenticator, "SECRET_REALM"); environment.jersey().register(authProvider); I am wondering what the significance of the String realm (" SECRET_REALM ") is? From general security concepts, I understand a "realm" to be a place (database, directory, file, keystore, etc.) where users and roles/permissions are stored. What does a realm mean in DropWizard, and what's the significance of specifying it inside BasicAuthProvider ? Does it create something