java on rails sv code camp 2014
Post on 31-Jul-2015
29 Views
Preview:
TRANSCRIPT
Tim HobsonPrincipal Engineer, Chief Caffeine Officer @
Java on Rails - Using Spring Boot For Rapid Application Development
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
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.
Rapid Application Development
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
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
7
Choices, Choices…
97,613 packages49,603 packages
87,864 packages89,387 packages
27,580 packages
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.
9
Choices, Choices…
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
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
Why Spring Boot?
?
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.
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
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>
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
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
19
Infrastructure Services
Audit
Metrics
Guages
Tracing
Configuration Views
Remote management via SSH
All Part of the Actuator Component
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
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”.
Code
To-Boot
https://github.com/hoserdude/to-boot
git clone git@github.com:hoserdude/to-boot.git
Sample App to demonstrate all manner of things, cobbled together in about 2 days.
See README.md for instructions
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
Closing Thoughts
26
Find Out More
• http://spring.io/projects
• http://spring.io/guides
THANK YOU
@hoserdude
@hoserdude
@hoserdude
hoserdude.com
top related