background preloader

Dropwizard

Facebook Twitter

Java and JavaEE blog : Getting started with Dropwizard: Connecting to external REST Web-services using Jersey Client. Imagine a situation that you would like to create a currency conversion API using Dropwizard, but exchange rates are fickle and change on daily if not hourly basis.

Java and JavaEE blog : Getting started with Dropwizard: Connecting to external REST Web-services using Jersey Client

So, you need an external source of exchange rate data and luckily, Google search returns a list of such APIs. In this tutorial will connect to Open Exchange Rates which has a free option. To use the API one needs to obtain a free API key which is an alphanumeric string supplied as part of request string when accessing the API. Here is the description of how to obtain the key. From this moment it is supposed that you have obtained the key, otherwise you will be unable to follow the examples from this tutorial. Let’s play a little with the API before we start writing the actual code. API key> from your browser, where <Your API key> should be replaced with the actual key you obtained earlier.

Second, to obtain conversion rates one should navigate the browser to the following URL API key>, localhost:8080/converter/1.5? Resources. Java and JavaEE blog : Getting started with Dropwizard: Connecting to a Database using Hibernate. We'll begin with adding parameters of database connection including credentials, connection URI and database driver name to the application's configuration file.

Java and JavaEE blog : Getting started with Dropwizard: Connecting to a Database using Hibernate

The snippet below shows how to configure the database connection. MySQL RDBMS was used for our example, but some other DBMS can be used. As we'll use Hibernate to talk to our database, switching databases is a snap, it's only necessary to change the name of the driver in the snippet above. The benefit of using Hibernate is that it knows how to work with different database management systems, and there is no necessity to change application's code after switching to a different RDBMS. Our next step would be changing pom.xml of the application. Then, after the required dependencies were added, we can change the Configuration class, called DWGettingStartedConfiguration in the example application. Java and JavaEE blog : Getting Started with Dropwizard: Authentication, Configuration and HTTPS.

In the previous installment of this series we discussed how to create a Dropwizard project using Maven archetype as well as how to create a simple RESTful API and access it.

Java and JavaEE blog : Getting Started with Dropwizard: Authentication, Configuration and HTTPS

API security is an important topic and today we'll discuss how to use authentication and HTTPS with Dropwizard. Also, the problem of configuring Dropwizard applications will be touched. All the code for the examples below can be found here. Authentication Basic Authentication is a simplest way to secure access to a resource. This authentication scheme is a non-secure one as it uses unencrypted credentials. To start working with authentication on should add a dependency to the pom-file. Let's talk about how to add Basic Authentication to your Dropwizard REST API and then discuss how to access secured resources both from command line and browser and finally, at the end of this article, we'll see how to test password-protected sub-resource methods.

Instead of using the @Default annotation, or F12 tools of a browser. Java and JavaEE blog : Getting started with Dropwizard: First steps. Dropwizard is a bunch of superb frameworks glued together to provide a fast way of building web applications including REST APIs.

Java and JavaEE blog : Getting started with Dropwizard: First steps

We'll talk about great frameworks which are parts of Dropwizard as we go over our examples. The full code for the examples can be obtained here. The simplest way to create a Dropwizard project is to use the Maven archetype called java-simple which is a part of Dropwizard. This can be accomplished either via the command line or using your favorite IDE. Let's stick to the former approach. After the project was created it can be modified using an editor or opened in an IDE. There are multiple sub-packages and two classes that were created for us in a package com.javaeeeee.dwstart. There is a special package, com.javaeeeee.dwstart.recources for placing resource classes or an appropriate folder can be found from the screenshot above if you use a text editor and not an IDE. mvn package. Dropwizard. Upload javaeeeee Loading...

Dropwizard

Working... ► Play all Dropwizard by javaeeeee6 videos42 viewsLast updated on Oct 9, 2015 Play all Sign in to YouTube Sign in History. Emerging Technology Trends for 2015. Dropwizard. Dropwizard.