SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
GETTINGGROOVY
WITH MICRONAUT & JHIPSTER
Web and JVM developer with a decade of
experience
Husband of Dad of
OSS contributor
2GM Team Member at OCI
ABOUTME
ZACHARY KLEIN, SENIOR SOFTWARE ENGINEER
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
💇 🙆 👸 👶🙋
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
AGENDA
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATISMICRONAUT?
• A framework for microservice & serverless applications
• Leverages Ahead Of Time (AOT) for DI, AOP, and
configuration injection
• Reactive HTTP layer built on Netty
• Declarative HTTP Client
• “Natively Cloud Native”
• Accompanied by a suite of official and community-
contributed integrations and libraries
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATCANYOUBUILDWITHMICRONAUT?
• Microservices
• Serverless Applications
• Message-Driven Applications with Kafka/Rabbit
• CLI Applications
• Android Applications
• Anything with static void main(String..args)
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATMAKESMICRONAUTDIFFERENT?
• Ahead of Time (AOT) Compilation
• No Reflection, Runtime Proxies, or Dynamic Classloading
• Optimized for GraalVM (and standard JVM)
• Natively Reactive
• Capable of running in low-memory environments with sub
second startup time
• Polyglot: supports Java, Kotlin, and Groovy
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATMAKESMICRONAUTDIFFERENT?
• Configurations offered for…
• Cloud platforms (AWS, Google Cloud, Microsoft Azure)
• Messaging frameworks (Kafka, RabbitMQ, nats.io)
• Data access (MongoDB, Neo4j, Redis, SQL/JDBC, Cassandra
• Open API documentation (Swagger)
• Metrics libraries (Micrometer, rate limiting libraries)
• Server-side view rendering
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MICRONAUTANDGROOVY
• First-class support for Groovy
• Controllers, filters, beans, factories, configuration
• @MicronautTest for Spock
• AST Transformations
• Static Compilation
• Interoperability
https://launch.micronaut.io9
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
DEPENDENCYINJECTION&AOP
• Full Featured Dependency Injection (DI) Container
• JSR-330 Compliant
• Minimizes Runtime Reflection
• AOP APIs
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
Generated Bytecode resides in
the same package as your source
code - your code is never altered
by Micronaut
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
import javax.inject.Singleton
@Singleton
class MessageHelper {
String createMessage() { // … }
}
Mind the package!
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import javax.inject.Inject
@Controller("/")
class HelloController {
@Inject
MessageHelper messageHelper
// ...
}
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
@Controller("/")
class HelloController {
MessageHelper messageHelper
public HelloController(MessageHelper messageHelper) {
this.messageHelper = messageHelper
}
// ...
}
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CONFIGURATION
• Configuration formats: YML (default), Groovy, JSON, Java
Properties
• Environment detection and env-specific config
• Configuration injection via annotations or
@ConfigurationProperties
info.demo.string = "demo string"
info.demo.number = 123
info.demo.map = [key: 'value',
other_key: 123]
application.groovy
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CONTROLLERS
package example
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
@Controller('/')
class GroovyHelloController {
@Get('/hello/{name}')
String hello(String name) {
"Hello $name From Groovy"
}
}
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CLIENTS
package example
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
@Client(‘/') // or (id = ‘service-id’)
class GroovyHelloClient {
@Get('/hello/{name}')
String hello(String name)
}
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MANAGEMENTENDPOINTS
• Provided by the micronaut-management library
• Similar conceptually to Actuator endpoints in Spring
Boot/Grails
• Endpoints can be defined as sensitive (requiring
authentication)
• Support GET, POST, and DELETE requests
• Can be exposed via JMX
• Custom endpoints supported
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
/beans Returns information about the loaded bean definitions in
the application
/info Returns static information from the state of the
application
/health Returns information about the "health" of the application
/metrics Return the application metrics. Requires the micrometer-
core configuration on the classpath
/refresh Refreshes bean state
/routes Returns information about URIs available to be called for
your application
/stop Shuts down the application server (disabled by default)
/loggers View and mutate logging configuration (e.g, POST to change
log levels at runtime)
/env Returns all currently resolved configuration properties
DEFAULT MANAGEMENT ENDPOINTS
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MICRONAUT&GROOVY
• Groovy is a 1st class language in Micronaut!
• Applications can be generated with Groovy
as the default language (e.g, code-gen for
controllers, clients, Application class, etc)
• Groovy supported as configuration syntax
• Compile-time DI/AOP provided using Groovy
AST Transformations
• Groovy classes can also be used within Java
Micronaut apps (e.g, Spock tests, helper/util
classes)
❤
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MICRONAUT&GROOVY
• Groovy can be used for:
• Controllers & Clients
• Filters
• All bean types
• AOP advice
• Configuration
• Serverless functions
❤
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
“ADEVELOPMENTPLATFORMTO
QUICKLYGENERATE,DEVELOP,&
DEPLOYMODERNWEBAPPLICATIONS
&MICROSERVICEARCHITECTURES.”
HTTPS://WWW.JHIPSTER.TECH
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATISJHIPSTER?
• Project generator for modern JVM web apps
• Originally designed for Spring Boot and Angular
• Now supports React and Vue.js frontends, and Micronaut as a
backend via the Hipster blueprint
• Provides user admin UI, management UI, and “scaffolding” views for
database entities
• Offers features to easily enable OAuth2 authentication
• JDL (JHipster Domain Language) can be used to define the domain
model (and project options) for your app
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
JHIPSTER&MICRONAUT
• Development sponsored by Object Computing, Inc
• Custom Blueprint supplies a Micronaut backend
• Still in active development!
• Features currently supported include:
• Maven (default) or Gradle
• MySQL, Postgres, H2
• JWT or OAuth 2.0 authentication
• Angular or React client app
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CREATINGAJHIPSTERAPPLICATION
1. Install MHipster
◦ npm install -g generator-jhipster-micronaut
2. Create a new folder for your application
3. Start MHipster
◦ mhipster
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
JHIPSTER/MICRONAUT+GROOVY!
• JHipster projects use Java only by default, :( however…
• Groovy can be added to the project with fairly minimal build
configuration! :)
• Groovy can be used for project configuration (?)
• Micronaut’s joint-compilation support for Groovy allows
bidirectional DI within your app
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
DEMO!DEMO!DEMO!
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WRAPUP
• Micronaut is a powerful, performant framework for JVM apps -
including Groovy!
• JHipster allows you to quickly bootstrap a full-featured
application with Micronaut with very little coding
• With a bit of custom config, you can take advantage of Groovy
and Micronaut’s support for the Groovy language within your
JHipster project
• Approach is applicable to any Micronaut project (not just
JHipster)
❤
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
QUESTIONS?
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
THANKYOU
ZACHARY KLEIN
SENIOR SOFTWARE ENGINEER
GRAILS & MICRONAUT CORE TEAM MEMBER
KLEINZ@OBJECTCOMPUTING.COM
@ZACHARYAKLEIN
https://micronaut.io
https://objectcomputing.com/resources/events
SAMPLE CODE: HTTPS://GITHUB.COM/ZACHARYKLEIN/GROOVY-JHIPSTER

Contenu connexe

Tendances

GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
GR8Conf
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
Shreedhar Ganapathy
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
Shekhar Gulati
 

Tendances (20)

Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019
 
GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
 
Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019
Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019
Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019
 
Bringing Docker to the Cloud
Bringing Docker to the CloudBringing Docker to the Cloud
Bringing Docker to the Cloud
 
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
 
A realtime infrastructure for Android apps: Firebase may be what you need..an...
A realtime infrastructure for Android apps: Firebase may be what you need..an...A realtime infrastructure for Android apps: Firebase may be what you need..an...
A realtime infrastructure for Android apps: Firebase may be what you need..an...
 
Bootiful Development with Spring Boot and React - Richmond JUG 2018
Bootiful Development with Spring Boot and React - Richmond JUG 2018Bootiful Development with Spring Boot and React - Richmond JUG 2018
Bootiful Development with Spring Boot and React - Richmond JUG 2018
 
Open Service Broker APIとKubernetes Service Catalog #k8sjp
Open Service Broker APIとKubernetes Service Catalog #k8sjpOpen Service Broker APIとKubernetes Service Catalog #k8sjp
Open Service Broker APIとKubernetes Service Catalog #k8sjp
 
Seven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuseSeven Simple Reasons to Use AppFuse
Seven Simple Reasons to Use AppFuse
 
Micronaut: A new way to build microservices
Micronaut: A new way to build microservicesMicronaut: A new way to build microservices
Micronaut: A new way to build microservices
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015
 
Spring Up Your Graph
Spring Up Your GraphSpring Up Your Graph
Spring Up Your Graph
 
Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
 
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
 
Java Web Application Security - UberConf 2011
Java Web Application Security - UberConf 2011Java Web Application Security - UberConf 2011
Java Web Application Security - UberConf 2011
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeed
 
Html5 with Vaadin and Scala
Html5 with Vaadin and ScalaHtml5 with Vaadin and Scala
Html5 with Vaadin and Scala
 

Similaire à Getting Groovy with JHipster and Micronaut

week 4_watermark.pdfffffffffffffffffffff
week 4_watermark.pdfffffffffffffffffffffweek 4_watermark.pdfffffffffffffffffffff
week 4_watermark.pdfffffffffffffffffffff
anushka2002ece
 

Similaire à Getting Groovy with JHipster and Micronaut (20)

Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut FrameworkNative Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
 
Week 4 lecture material cc (1)
Week 4 lecture material cc (1)Week 4 lecture material cc (1)
Week 4 lecture material cc (1)
 
week 4_watermark.pdfffffffffffffffffffff
week 4_watermark.pdfffffffffffffffffffffweek 4_watermark.pdfffffffffffffffffffff
week 4_watermark.pdfffffffffffffffffffff
 
First Bucharest GTUG event 02 Mar 2010
First Bucharest GTUG event 02 Mar 2010First Bucharest GTUG event 02 Mar 2010
First Bucharest GTUG event 02 Mar 2010
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
 
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
 
Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsug
 
Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 
Masterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM RolesMasterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM Roles
 
Intro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry Meetup
Intro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry MeetupIntro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry Meetup
Intro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry Meetup
 
How to Architect and Develop Cloud Native Applications
How to Architect and Develop Cloud Native ApplicationsHow to Architect and Develop Cloud Native Applications
How to Architect and Develop Cloud Native Applications
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
Building Microservices with Micronaut:  A Full-Stack JVM-Based FrameworkBuilding Microservices with Micronaut:  A Full-Stack JVM-Based Framework
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
 
Spring Native and Spring AOT
Spring Native and Spring AOTSpring Native and Spring AOT
Spring Native and Spring AOT
 
Kubernetes Operability Tooling (GOTO Chicago 2019)
Kubernetes Operability Tooling (GOTO Chicago 2019)Kubernetes Operability Tooling (GOTO Chicago 2019)
Kubernetes Operability Tooling (GOTO Chicago 2019)
 
Why Kubernetes? Cloud Native and Developer Experience at Zalando - Enterprise...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - Enterprise...Why Kubernetes? Cloud Native and Developer Experience at Zalando - Enterprise...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - Enterprise...
 
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
 
Develop Azure compute solutions Part - 2
Develop Azure compute solutions Part - 2Develop Azure compute solutions Part - 2
Develop Azure compute solutions Part - 2
 

Dernier

Dernier (20)

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Buy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptxBuy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptx
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 

Getting Groovy with JHipster and Micronaut

  • 2. Web and JVM developer with a decade of experience Husband of Dad of OSS contributor 2GM Team Member at OCI ABOUTME ZACHARY KLEIN, SENIOR SOFTWARE ENGINEER ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 💇 🙆 👸 👶🙋
  • 3. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 AGENDA
  • 4. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 WHATISMICRONAUT? • A framework for microservice & serverless applications • Leverages Ahead Of Time (AOT) for DI, AOP, and configuration injection • Reactive HTTP layer built on Netty • Declarative HTTP Client • “Natively Cloud Native” • Accompanied by a suite of official and community- contributed integrations and libraries
  • 5. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 WHATCANYOUBUILDWITHMICRONAUT? • Microservices • Serverless Applications • Message-Driven Applications with Kafka/Rabbit • CLI Applications • Android Applications • Anything with static void main(String..args)
  • 6. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 WHATMAKESMICRONAUTDIFFERENT? • Ahead of Time (AOT) Compilation • No Reflection, Runtime Proxies, or Dynamic Classloading • Optimized for GraalVM (and standard JVM) • Natively Reactive • Capable of running in low-memory environments with sub second startup time • Polyglot: supports Java, Kotlin, and Groovy
  • 7. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 WHATMAKESMICRONAUTDIFFERENT? • Configurations offered for… • Cloud platforms (AWS, Google Cloud, Microsoft Azure) • Messaging frameworks (Kafka, RabbitMQ, nats.io) • Data access (MongoDB, Neo4j, Redis, SQL/JDBC, Cassandra • Open API documentation (Swagger) • Metrics libraries (Micrometer, rate limiting libraries) • Server-side view rendering
  • 8. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 MICRONAUTANDGROOVY • First-class support for Groovy • Controllers, filters, beans, factories, configuration • @MicronautTest for Spock • AST Transformations • Static Compilation • Interoperability
  • 10. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 DEPENDENCYINJECTION&AOP • Full Featured Dependency Injection (DI) Container • JSR-330 Compliant • Minimizes Runtime Reflection • AOP APIs
  • 11. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 Generated Bytecode resides in the same package as your source code - your code is never altered by Micronaut
  • 12. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 import javax.inject.Singleton @Singleton class MessageHelper { String createMessage() { // … } } Mind the package!
  • 13. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Get import javax.inject.Inject @Controller("/") class HelloController { @Inject MessageHelper messageHelper // ... }
  • 14. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Get @Controller("/") class HelloController { MessageHelper messageHelper public HelloController(MessageHelper messageHelper) { this.messageHelper = messageHelper } // ... }
  • 15. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 CONFIGURATION • Configuration formats: YML (default), Groovy, JSON, Java Properties • Environment detection and env-specific config • Configuration injection via annotations or @ConfigurationProperties info.demo.string = "demo string" info.demo.number = 123 info.demo.map = [key: 'value', other_key: 123] application.groovy
  • 16. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 CONTROLLERS package example import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Get @Controller('/') class GroovyHelloController { @Get('/hello/{name}') String hello(String name) { "Hello $name From Groovy" } }
  • 17. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 CLIENTS package example import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Get @Client(‘/') // or (id = ‘service-id’) class GroovyHelloClient { @Get('/hello/{name}') String hello(String name) }
  • 18. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 MANAGEMENTENDPOINTS • Provided by the micronaut-management library • Similar conceptually to Actuator endpoints in Spring Boot/Grails • Endpoints can be defined as sensitive (requiring authentication) • Support GET, POST, and DELETE requests • Can be exposed via JMX • Custom endpoints supported
  • 19. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 /beans Returns information about the loaded bean definitions in the application /info Returns static information from the state of the application /health Returns information about the "health" of the application /metrics Return the application metrics. Requires the micrometer- core configuration on the classpath /refresh Refreshes bean state /routes Returns information about URIs available to be called for your application /stop Shuts down the application server (disabled by default) /loggers View and mutate logging configuration (e.g, POST to change log levels at runtime) /env Returns all currently resolved configuration properties DEFAULT MANAGEMENT ENDPOINTS
  • 20. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 MICRONAUT&GROOVY • Groovy is a 1st class language in Micronaut! • Applications can be generated with Groovy as the default language (e.g, code-gen for controllers, clients, Application class, etc) • Groovy supported as configuration syntax • Compile-time DI/AOP provided using Groovy AST Transformations • Groovy classes can also be used within Java Micronaut apps (e.g, Spock tests, helper/util classes) ❤
  • 21. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 MICRONAUT&GROOVY • Groovy can be used for: • Controllers & Clients • Filters • All bean types • AOP advice • Configuration • Serverless functions ❤
  • 22. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 “ADEVELOPMENTPLATFORMTO QUICKLYGENERATE,DEVELOP,& DEPLOYMODERNWEBAPPLICATIONS &MICROSERVICEARCHITECTURES.” HTTPS://WWW.JHIPSTER.TECH
  • 23. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 WHATISJHIPSTER? • Project generator for modern JVM web apps • Originally designed for Spring Boot and Angular • Now supports React and Vue.js frontends, and Micronaut as a backend via the Hipster blueprint • Provides user admin UI, management UI, and “scaffolding” views for database entities • Offers features to easily enable OAuth2 authentication • JDL (JHipster Domain Language) can be used to define the domain model (and project options) for your app
  • 24. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 JHIPSTER&MICRONAUT • Development sponsored by Object Computing, Inc • Custom Blueprint supplies a Micronaut backend • Still in active development! • Features currently supported include: • Maven (default) or Gradle • MySQL, Postgres, H2 • JWT or OAuth 2.0 authentication • Angular or React client app
  • 25. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 CREATINGAJHIPSTERAPPLICATION 1. Install MHipster ◦ npm install -g generator-jhipster-micronaut 2. Create a new folder for your application 3. Start MHipster ◦ mhipster
  • 26. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 JHIPSTER/MICRONAUT+GROOVY! • JHipster projects use Java only by default, :( however… • Groovy can be added to the project with fairly minimal build configuration! :) • Groovy can be used for project configuration (?) • Micronaut’s joint-compilation support for Groovy allows bidirectional DI within your app
  • 27. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 DEMO!DEMO!DEMO!
  • 28. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 WRAPUP • Micronaut is a powerful, performant framework for JVM apps - including Groovy! • JHipster allows you to quickly bootstrap a full-featured application with Micronaut with very little coding • With a bit of custom config, you can take advantage of Groovy and Micronaut’s support for the Groovy language within your JHipster project • Approach is applicable to any Micronaut project (not just JHipster) ❤
  • 29. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 QUESTIONS?
  • 30. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020 THANKYOU ZACHARY KLEIN SENIOR SOFTWARE ENGINEER GRAILS & MICRONAUT CORE TEAM MEMBER KLEINZ@OBJECTCOMPUTING.COM @ZACHARYAKLEIN https://micronaut.io https://objectcomputing.com/resources/events SAMPLE CODE: HTTPS://GITHUB.COM/ZACHARYKLEIN/GROOVY-JHIPSTER