Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Dropwizard 
-微服務架構框架- 
anthonychen
Once Upon a Time 
Hibernate 
Tomcat 
Spring 
JPA 
Spring 
MVC 
Jackson 
Freemarker 
or 
Thymeleaf 
Logback
Dropwizard 
Full Stack Framework 
with microservice architecture
Drop...wizard?
Jackson 
mustache 
JDBI 
Full Stack, RESTful and Open Source
Dropwizard Modules (v0.7.1) 
dropwizard-assets dropwizard-jackson dropwizard-migrations 
dropwizard-auth dropwizard-jdbi d...
Microservice 
Architecture 
The microservice architectural 
style is an approach to 
developing a single application as 
a...
Monolithic Micro Services 
pid 1234 8GB heap 
pid 5678 
2GB heap 
pid 5978 
2GB heap 
pid 1234 
2GB heap 
pid 9527 
2GB he...
Scalability
Project Management
P 
R 
O 
X 
Y 
Extensibility
Phlyty 
a microframework using ZF2 components. 
SleepyA RESTful framework for Go 
Microservice Frameworks
Why 
DropWizard?
http://www.oracle.com/us/technologies/java/gimmejava/usage-terms/index.html
Dropwizard - Pros 
Productivity – Do one thing at a time 
Do your best with what you have 
Simple & Lightweight 
Easy Test...
Dropwizard - Pros 
Productivity – Do one thing at a time 
Do your best with what you have 
Simple & Lightweight 
Easy Test...
http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=json&f=311c-1hq8-0-0
http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=db&f=311c-1hq8-0-0
http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=query&f=311c-1hq8-0-0
Dropwizard - Cons 
Frequently and Large-Scale Changes 
Nano-Service Architecture 
Complexity at Infrastructure Level 
No A...
How to Start 
DropWizard?
Overview 
Resource 
Application Bundle 
Configuration 
Representation 
Environment 
Views
Project Orginization 
com.example.myapplication: 
 api: Representations. 
 cli: Commands 
 client: Client implementatio...
Configuration Class 
public class BlogConfiguration extends Configuration { 
@Valid 
@NotNull 
@JsonProperty("database") 
...
Configuration File 
(YAML) 
server: 
type: simple 
applicationContextPath: /application 
adminContextPath: /admin 
databas...
Representation Class 
public class Notification { 
private String text; 
public Notification(String text) { 
this.text = t...
Application Class - Bundle 
public class BlogApplication extends Application<BlogConfiguration> { 
public static void main...
Application Class – Environment 
@Override 
public void run(BlogConfiguration configuration, Environment environment) thro...
View Layer 
Freemarker - http://freemarker.org 
Mustache - http://mustache.github.io
Health Check 
public class DatabaseHealthCheck extends HealthCheck { 
private final Database database; 
public DatabaseHea...
Demo- 
A Sample Blog
Build - A Fat JAR 
An easy maintainable, single deployable 
artifact 
maven-shade or maven-assembly-plugin
Run 
Command line: 
java -jar blog-sample-0.0.1-SNAPSHOT.jar server blog.yml 
exec-maven-plugin
More 
DropWizard?
Metric
AngularJS & 
DropWizard
Spring & 
DropWizard
Dropwizard Introduction
Upcoming SlideShare
Loading in …5
×

Dropwizard Introduction

2,952 views

Published on

Dropwizard introduction presentation slide for TWJUG Sep. event.

Published in: Technology
  • Be the first to comment

Dropwizard Introduction

  1. 1. Dropwizard -微服務架構框架- anthonychen
  2. 2. Once Upon a Time Hibernate Tomcat Spring JPA Spring MVC Jackson Freemarker or Thymeleaf Logback
  3. 3. Dropwizard Full Stack Framework with microservice architecture
  4. 4. Drop...wizard?
  5. 5. Jackson mustache JDBI Full Stack, RESTful and Open Source
  6. 6. Dropwizard Modules (v0.7.1) dropwizard-assets dropwizard-jackson dropwizard-migrations dropwizard-auth dropwizard-jdbi dropwizard-servlets dropwizard-client dropwizard-jersey dropwizard-spdy dropwizard-configuration dropwizard-jetty dropwizard-testing dropwizard-core dropwizard-lifecycle dropwizard-util dropwizard-db dropwizard-logging dropwizard-validation dropwizard-example dropwizard-metrics-ganglial dropwizard-views-freemarker dropwizard-forms dropwizard-metrics-graphite dropwizard-views-mustache dropwizard-hibernate dropwizard-metrics dropwizard-views
  7. 7. Microservice Architecture The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. - Martin Fowler
  8. 8. Monolithic Micro Services pid 1234 8GB heap pid 5678 2GB heap pid 5978 2GB heap pid 1234 2GB heap pid 9527 2GB heap
  9. 9. Scalability
  10. 10. Project Management
  11. 11. P R O X Y Extensibility
  12. 12. Phlyty a microframework using ZF2 components. SleepyA RESTful framework for Go Microservice Frameworks
  13. 13. Why DropWizard?
  14. 14. http://www.oracle.com/us/technologies/java/gimmejava/usage-terms/index.html
  15. 15. Dropwizard - Pros Productivity – Do one thing at a time Do your best with what you have Simple & Lightweight Easy Test, Deployment and Management Performance
  16. 16. Dropwizard - Pros Productivity – Do one thing at a time Do your best with what you have Simple & Lightweight Easy Test, Deployment and Management Performance
  17. 17. http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=json&f=311c-1hq8-0-0
  18. 18. http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=db&f=311c-1hq8-0-0
  19. 19. http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=query&f=311c-1hq8-0-0
  20. 20. Dropwizard - Cons Frequently and Large-Scale Changes Nano-Service Architecture Complexity at Infrastructure Level No Application Server Put More Effort on Monitoring and
  21. 21. How to Start DropWizard?
  22. 22. Overview Resource Application Bundle Configuration Representation Environment Views
  23. 23. Project Orginization com.example.myapplication:  api: Representations.  cli: Commands  client: Client implementation for your application  core: Domain implementation  jdbi: Database access classes  health: Health Checks  resources: Resources  MyApplication: The application class  MyApplicationConfiguration: configuration class
  24. 24. Configuration Class public class BlogConfiguration extends Configuration { @Valid @NotNull @JsonProperty("database") private DataSourceFactory database = new DataSourceFactory(); public DataSourceFactory getDatabase() { return database; }}
  25. 25. Configuration File (YAML) server: type: simple applicationContextPath: /application adminContextPath: /admin database: driverClass: com.mysql.jdbc.Driver user: anthonychen password: anthonychen url: jdbc:mysql://localhost:3306/blog validationQuery: "/* MyApplication Health Check */ SELECT 1"
  26. 26. Representation Class public class Notification { private String text; public Notification(String text) { this.text = text; } @JsonProperty public String getText() { return text; } @JsonProperty public void setText(String text) { this.text = text; }}
  27. 27. Application Class - Bundle public class BlogApplication extends Application<BlogConfiguration> { public static void main(String[] args) throws Exception { new BlogApplication().run(args); } @Override public void initialize(Bootstrap<BlogConfiguration> bootstrap) { bootstrap.addBundle(hibernateBundle); bootstrap.addBundle(new ViewBundle()); bootstrap.addBundle(new AssetsBundle("/assets/js", "/js", null, "js")); }}
  28. 28. Application Class – Environment @Override public void run(BlogConfiguration configuration, Environment environment) throws Exception { // Crete DAOs final ArticleDAO articleDAO = new ArticleDAO(hibernateBundle.getSessionFactory()); final UserDAO userDAO = new UserDAO(hibernateBundle.getSessionFactory()); // Create healthchecks final SessionFactoryHealthCheck dbHealthCheck = new SessionFactoryHealthCheck( hibernateBundle.getSessionFactory(), configuration.getDatabase().getValidationQuery() ); // Register resources, filters and healthchecks environment.jersey().register(new BlogResource(configuration.getSiteName(), articleDAO)); environment.jersey().register(new ArticleResource(articleDAO, userDAO)); environment.healthChecks().register("databaseHealthcheck", dbHealthCheck); }}
  29. 29. View Layer Freemarker - http://freemarker.org Mustache - http://mustache.github.io
  30. 30. Health Check public class DatabaseHealthCheck extends HealthCheck { private final Database database; public DatabaseHealthCheck(Database database) { this.database = database; } @Override protected Result check() throws Exception { if (database.isConnected()) { return Result.healthy(); } else { return Result.unhealthy("Cannot connect to " + database.getUrl()); } } }
  31. 31. Demo- A Sample Blog
  32. 32. Build - A Fat JAR An easy maintainable, single deployable artifact maven-shade or maven-assembly-plugin
  33. 33. Run Command line: java -jar blog-sample-0.0.1-SNAPSHOT.jar server blog.yml exec-maven-plugin
  34. 34. More DropWizard?
  35. 35. Metric
  36. 36. AngularJS & DropWizard
  37. 37. Spring & DropWizard

×