Java on Rails SV Code Camp 2014
-
Upload
tim-hobson -
Category
Software
-
view
31 -
download
0
Transcript of Java on Rails SV Code Camp 2014
![Page 1: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/1.jpg)
Tim HobsonPrincipal Engineer, Chief Caffeine Officer @
Java on Rails - Using Spring Boot For Rapid Application Development
![Page 2: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/2.jpg)
2
About Me
Software Developer with a bad habit of leveraging frameworks
Not a fan of re-inventing wheels every project
Still believe you can move fast with good architecture
![Page 3: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/3.jpg)
3
Agenda
Why Spring Boot
Code
RAD
GOAL: Spring Boot has been demystified, looks promising, and you are inspired to give it a test drive.
![Page 4: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/4.jpg)
Rapid Application Development
![Page 5: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/5.jpg)
Rapid Application Development
Components, Frameworks and Platforms
The platform choice you make should enable you to move fast using the best of breed frameworks and
components
![Page 6: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/6.jpg)
6
Components
High-level software systems are built using components (or modules)
Leveraging existing components – saves time, – reduces opportunity for defects, – lets you focus on your value added work.
EG: Database connection pools, JSON and XML Parsers, Security libraries, HTTP Clients etc…
As an application developer, you are not being paid to build commodity services
![Page 7: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/7.jpg)
7
Choices, Choices…
97,613 packages49,603 packages
87,864 packages89,387 packages
27,580 packages
![Page 8: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/8.jpg)
8
Frameworks
Frameworks typically provide a collection of curated Components that work seamlessly togetherFrameworks provide implied (or explicit) patterns and practices to help maintain good architecture and maintainabilityFrameworks provide proven combinations of components in use for known use cases.
![Page 9: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/9.jpg)
9
Choices, Choices…
![Page 10: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/10.jpg)
10
PlatformsPlatforms go beyond software components and frameworks– Tooling– Deployment– Management– Testing– Maintenance– Versioning
Platforms are trying to create cohesive technology experiences for developers and businesses
Less for you to worry about, more time to focus on your domain
![Page 11: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/11.jpg)
11
Making Good ChoicesWhat do I need in the short term?
What might I need in the future?
How has the framework evolved, will it continue?
Are there enough people skilled in this framework?
Is the documentation and support good?
Is it an ordeal or a joy to work with?
There are more considerations than how easy “Hello World” is
![Page 12: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/12.jpg)
Why Spring Boot?
![Page 13: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/13.jpg)
?
![Page 14: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/14.jpg)
A Cohesive Platform
The Spring Platform consists of components and frameworks that are useful in and of themselves, but are brought together through Boot in a way that lends itself to true RAD.
The framework is road-tested, and continues to be actively developed, keeping up with the latest technologies and patterns (Big Data, Reactive, HATEOS, Microservices, Cloud-deployed) and actively partnering with other OSS projects.
![Page 15: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/15.jpg)
Spring Boot
What is it?– Dependency Management “Simplification”– Automatic Component Configuration– Cross-cutting infrastructure services– Deployment and Packaging alternatives
How does it do it?– “Starter Packs” of dependencies– Convention-based configuration– Production-ready services such as metrics, health,
app lifecycle.– Maven and Gradle plugins
![Page 16: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/16.jpg)
16
Dependency Management
Starter Packs bring together Spring and Third-Party dependencies needed to do something functionally:– Web– Data– Security– Test
Versioning controlled by a parent pom.xml
Include the starter packs you need, and go. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
![Page 17: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/17.jpg)
17
The Magic of Auto-Configuration
Configures based on what is in your classpathConfigures based on what @Beans are in place and which aren’tConfigures based on your application.yml or application.properties
@EnableAutoConfiguration
![Page 18: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/18.jpg)
18
So What’s So Great About That?EG: Writing a JSON Service that reads from a DB
Spring Boot Way
• Use/Include Spring Boot Starter Parent in pom/Gradle, add Spring Boot Starter Web and JPA
• Write Controller, Service, Repository Beans and Domain Objects
• Write Application class with @EnableAutoConfiguration
• Run as a Jar.
Old Spring Way• Configure Web Container• Create Web Project• Configure POM/Gradle/Ant dependencies
(with versions) build and and packaging (150 lines +)
• Configure web.xml with Spring context config files, dispatcher servlet, servlet mapping, Spring security Filter, etc..
• Write Controller, Service, Repository Beans and Domain Objects
• Configure *.xml files (Or annotated @Configuration Beans) with Bean definitions, View resolvers, content-negotiation, controller mapping, resource handling, error handlers, db pooling, connections, profiles, transactionmanager, jdbc templates or JPA config.
• Write code to import initial data from script
![Page 19: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/19.jpg)
19
Infrastructure Services
Audit
Metrics
Guages
Tracing
Configuration Views
Remote management via SSH
All Part of the Actuator Component
![Page 20: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/20.jpg)
20
Package and Deployment Alternatives
Package as a JAR– Choose embedded container (Jetty, Tomcat)– Configure container programmatically and/or via
application config– Run using java –jar
Package as a WAR– No web.xml required– Spring Dispatcher Servlet is auto-configured– Deploy to any Servlet container
![Page 21: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/21.jpg)
Choices, Choices…
Do you already use Spring?
• Simplify your configuration
• Keep up with the latest version compatibility matrix
• Introduce Circuit Breaker patterns, distributed configuration, metrics and management APIs
• Get stuff done faster
Are you considering using Spring?• Skip the rewrite for the
JVM and write durable code!
• Leverage Dependency Injection, AOP, abstractions and integrations for major data stores, security standards, web standards and more.
• Fail to understand why it was known as “hard to use”.
![Page 22: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/22.jpg)
Code
![Page 23: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/23.jpg)
To-Boot
https://github.com/hoserdude/to-boot
git clone [email protected]:hoserdude/to-boot.git
Sample App to demonstrate all manner of things, cobbled together in about 2 days.
See README.md for instructions
![Page 24: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/24.jpg)
24
Things We Will Explore
Boostrapping (POM, Application.class)
Controllers (Routes, Marshalling, Resource Handling)
Views (Thymeleaf, AngularJS)
APIs (Swagger, DTO definition)
Security
Persistence (Config, Repositories, Domain Beans)
Application Structure, DI
Monitoring and Metrics
Deployment Options
![Page 25: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/25.jpg)
Closing Thoughts
![Page 26: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/26.jpg)
26
Find Out More
• http://spring.io/projects
• http://spring.io/guides
![Page 27: Java on Rails SV Code Camp 2014](https://reader036.fdocuments.net/reader036/viewer/2022062420/55baccdebb61eb526f8b4713/html5/thumbnails/27.jpg)
THANK YOU
@hoserdude
@hoserdude
@hoserdude
hoserdude.com