<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Edgar Espina on Medium]]></title>
        <description><![CDATA[Stories by Edgar Espina on Medium]]></description>
        <link>https://medium.com/@espina.edgar?source=rss-8d30443086b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mHIr1ug9y-YU8O3pO0Pfjw.jpeg</url>
            <title>Stories by Edgar Espina on Medium</title>
            <link>https://medium.com/@espina.edgar?source=rss-8d30443086b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:50:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@espina.edgar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Jooby: Export your Java/Kotlin API to Swagger/RAML]]></title>
            <link>https://medium.com/@espina.edgar/jooby-export-your-java-kotlin-api-to-swagger-raml-c73b18e3e642?source=rss-8d30443086b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c73b18e3e642</guid>
            <category><![CDATA[jooby]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[open-api]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Edgar Espina]]></dc:creator>
            <pubDate>Tue, 02 Jan 2018 18:40:57 GMT</pubDate>
            <atom:updated>2018-01-02T18:40:57.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>Documentation is essential while writing software, specially if you write complex business requirements, open source software, APIs, etc..</p><blockquote>Everybody wants good documentation, but nobody wants to write it.</blockquote><p>Writing good documentation is hard, takes time and always always get out of date.</p><p>I found these rules useful while writing documentation:</p><ol><li>keep documentation simple (without being too simple)</li><li>treat documentation like a requirement</li><li>use a tool to keep documentation up to date</li></ol><p>For example, JavaDoc (rule #3) it is a nice tool that:</p><ul><li>keep documentation close to source code</li><li>generates a static site that reflect the current state of your source code</li></ul><p>Of course, you need to keep JavaDoc comments updated but at least the documentation is close enough to your source code and for example can be enforced as part of development process via tooling and/or code reviews (rule #2).</p><p>In this post we are going export a <a href="http://jooby.org/">Jooby</a> API to Swagger and RAML</p><h3>ApiTool</h3><p>The <a href="http://jooby.org/doc/apitool">ApiTool</a> module is similar to JavaDoc. It is a tool that scans your code and produces an intermediate representation that can be exported to Swagger or RAML.</p><p>The goals of the ApiTool module are:</p><ul><li><em>Developer first</em>. You focus on your API and business requirements (don’t need to think about Swagger/RAML details).</li><li><em>Clean source code</em>. Your methods are not full of annotations.</li><li><em>Uses JavaDoc</em>. Documentation is extracted from existing JavaDoc comments (write documentation once).</li></ul><h3>demo</h3><p>We are going to mimic a subset of the <a href="http://petstore.swagger.io/#">Petstore</a> API demo from <a href="https://swagger.io/">swagger.io</a>.</p><p>To make it a bit more fun we are going to:</p><ul><li>Write the API using <a href="https://kotlinlang.or/">Kotlin</a></li><li>Use <a href="http://jooby.org/doc/jackson">Jackson</a> for JSON processing</li><li>Use <a href="http://jooby.org/jdbc">Hikari</a> database connection pool</li><li>Run database migrations with <a href="http://jooby.org/doc/flyway">Flyway</a></li><li>Access database with <a href="http://jooby.org/doc/jdbi3">Jdbi</a></li></ul><p>Sounds like a lot, right? Luckily enough the API is just a couple of lines in <a href="http://jooby.org/">Jooby</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/486d320f5e2bda2e47f251c446d6ceda/href">https://medium.com/media/486d320f5e2bda2e47f251c446d6ceda/href</a></iframe><p>We install a couple of modules via <a href="https://static.javadoc.io/org.jooby/jooby/1.2.3/org/jooby/Jooby.html#use-org.jooby.Jooby.Module-">use</a> method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9485f353deb06761a8a4fd69db61767/href">https://medium.com/media/a9485f353deb06761a8a4fd69db61767/href</a></iframe><p>The <a href="http://jooby.org/doc/jackson">Jackson</a> module for JSON processing.</p><p>The <a href="http://jooby.org/doc/jdbc">Jdbc</a> module creates a high performance connection pool using <a href="https://github.com/brettwooldridge/HikariCP">Hikari</a>. Database details (url, user, password) are listed in the application.conffile.</p><p>The <a href="http://jooby.org/doc/flyway">Flyway</a> module picks the database created previously and run database migrations from the src/resources/db/migration directory.</p><p>The <a href="http://jooby.org/doc/jdbi3">Jdbi</a> module gives you database access via DAO/Repository like classes. <a href="http://jdbi.org/">Jdbi</a> is also a very lightweight library you we must install or add new feature via plugins. We add here repository support and <a href="https://kotlinlang.org/">Kotlin</a>related plugins.</p><p>And finally we install the <a href="http://jooby.org/doc/apitool">ApiTool</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d1f95e256ca20d0c485c76bb436c409/href">https://medium.com/media/6d1f95e256ca20d0c485c76bb436c409/href</a></iframe><p>We don’t want to export ALL our routes, only those under the /api path and that is what the filter line does.</p><p>The calls swagger() and raml() export our API to those formats.</p><p>If you run the application you should see something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*70CR7QtqEFMAl082FU2U8Q.png" /></figure><h3>apitool goals</h3><p>Let’s review one of the routes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a68bd479fe7e98f5f2d9dc91cb498af/href">https://medium.com/media/5a68bd479fe7e98f5f2d9dc91cb498af/href</a></iframe><p>As promised the ApiTool module</p><ul><li>let you focus on your API,</li><li>keep the code clean and</li><li>complement the output with JavaDoc comments.</li></ul><p>There is nothing related to Swagger/RAML in the source code.</p><h3>final note</h3><p>The <a href="http://jooby.org/doc/apitool">ApiTool</a> module automatically exports your API to Swagger/RAML. You don’t need to waste time adding anything extra.</p><p>There is a bit of overhead while running the application in development mode, due the <a href="http://jooby.org/doc/apitool">ApiTool</a> scans and analyzes the code to produce Swagger/RAML. This overhead is eliminated once you deploy your application by adding a compile-time process to your Maven/Gradle project.</p><p>The <a href="http://jooby.org/doc/apitool">ApiTool</a> also:</p><ul><li>Works with Kotlin and Java code</li><li>Supports script/lambda routes, as well as Mvc routes</li></ul><p>Source code is available <a href="https://github.com/jooby-project/apitool-kotlin-starter">here</a></p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c73b18e3e642" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin idioms in Jooby]]></title>
            <link>https://medium.com/@espina.edgar/kotlin-idioms-in-jooby-cf3c8655d4ee?source=rss-8d30443086b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf3c8655d4ee</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[jooby]]></category>
            <dc:creator><![CDATA[Edgar Espina]]></dc:creator>
            <pubDate>Tue, 29 Aug 2017 18:12:53 GMT</pubDate>
            <atom:updated>2017-08-29T18:12:53.834Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGRJxErbaE7Tmta8-h1XTw.jpeg" /></figure><h3>Overview</h3><p><a href="http://jooby.org/">Jooby</a> wasn’t original designed as a Kotlin framework, but thanks to the power and expressiveness of Kotlin we were able to write a nice and tiny <a href="http://jooby.org/doc/lang-kotlin">module</a> that let you write idiomatic Kotlin in <a href="http://jooby.org/">Jooby</a>.</p><h3>Bootstrap idiom</h3><p>The bootstrap idiom comes in two flavors:</p><p>run function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb79eaf1272286b09eed5e3061e2c807/href">https://medium.com/media/cb79eaf1272286b09eed5e3061e2c807/href</a></iframe><p>Kooby class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b719f0888ed1de17d1cf0f7e40273ed3/href">https://medium.com/media/b719f0888ed1de17d1cf0f7e40273ed3/href</a></iframe><p>The <em>run idiom</em> is nice to quickly bootstrap an application, but doesn’t work well if you want to write unit and/or integration tests.</p><h3>Request idiom</h3><p>The <em>request idiom</em> give us implicit access to request functions and properties. So, instead of:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34bd1c7d0a5c5f1db68851f329b75953/href">https://medium.com/media/34bd1c7d0a5c5f1db68851f329b75953/href</a></iframe><p>Just need:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa3f3b00c1ba667816af079f86d808b2/href">https://medium.com/media/aa3f3b00c1ba667816af079f86d808b2/href</a></iframe><p>Works for body and form-submits too:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d45a685987c503788593012862ef91c2/href">https://medium.com/media/d45a685987c503788593012862ef91c2/href</a></iframe><h4>param, header and body idioms</h4><p>Previous examples used the Java API for accessing request objects. The <em>request idiom</em> comes with a couple of reified functions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53ab6197f95b01c2b42efbfbd11b7a34/href">https://medium.com/media/53ab6197f95b01c2b42efbfbd11b7a34/href</a></iframe><p>Nice ugh?</p><h3>Route idiom</h3><p>The route idiom group two or more routes under a common path, like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0149113f0a7b7ab239a3b5976bcfa994/href">https://medium.com/media/0149113f0a7b7ab239a3b5976bcfa994/href</a></iframe><h3>Class idiom</h3><p>The class idiom is a small enhancement that allow you to provide a Kotlin class reference while adding MVC routes, requiring dependencies, etc…</p><p>Just write: Pet::class where a class reference is required, instead of Pet::class.java</p><h3>Conclusion</h3><p>As said before <a href="http://jooby.org/">Jooby</a> wasn’t a Kotlin framework but luckily enough the <a href="http://jooby.org/doc/lang-kotlin/">kotlin module</a> close the gap and help you write <em>idiomatic</em> Kotlin.</p><p>Here is another example of a minimal HTTP API using the <a href="http://jooby.org/doc/jackson">Jackson</a> and <a href="http://jooby.org/doc/jdbi">Jdbi</a> modules:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c711900851d37ad874222b08d09bd5d7/href">https://medium.com/media/c711900851d37ad874222b08d09bd5d7/href</a></iframe><p>In addition to the <a href="http://jooby.org/doc/lang-kotlin">kotlin module,</a> <a href="http://jooby.org/">Jooby</a> comes with two starter projects:</p><ul><li><a href="https://github.com/jooby-project/kotlin-starter">kotlin-starter</a>: Maven project with everything setup and ready to run.</li><li><a href="https://github.com/jooby-project/kotlin-gradle-starter">kotlin-gradle-starter</a>: Gradle project with everything setup, ready to run and <a href="http://spekframework.org/">spek</a> for unit and integration tests</li></ul><p>That’s all for now. Happy Kotlin coding!</p><p><strong>Related articles:</strong></p><ul><li><a href="https://medium.com/@espina.edgar/java-micro-frameworks-why-jooby-59f0b346e819">Java micro-frameworks: Why Jooby?</a></li><li><a href="https://hackernoon.com/building-large-scale-applications-with-jooby-bde699f3e9e0">Building large scale applications with Jooby</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf3c8655d4ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building large scale applications with Jooby]]></title>
            <link>https://medium.com/hackernoon/building-large-scale-applications-with-jooby-bde699f3e9e0?source=rss-8d30443086b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/bde699f3e9e0</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jooby]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-framework]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Edgar Espina]]></dc:creator>
            <pubDate>Fri, 11 Aug 2017 13:49:16 GMT</pubDate>
            <atom:updated>2019-04-30T05:37:11.399Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGRJxErbaE7Tmta8-h1XTw.jpeg" /><figcaption>Jooby a modular micro framework</figcaption></figure><h3>Overview</h3><p><a href="http://jooby.org/">Jooby</a> is a <a href="http://jooby.org/modules/">modular</a> micro-framework for building web applications in <a href="http://jooby.org/">Java</a> and <a href="http://jooby.org/doc/lang-kotlin">Kotlin</a>. If this is first time you heard about <a href="http://jooby.org/">Jooby</a>? Checkout my previous article on <a href="https://medium.com/@espina.edgar/java-micro-frameworks-why-jooby-59f0b346e819"><strong>why you should choose</strong> <strong>Jooby</strong></a>.</p><p>Micro-frameworks are ideal for building small applications, but are they good for medium or complex applications?</p><p>In this article we’ll learn what options <a href="http://jooby.org/">Jooby</a> offers to build <a href="https://hackernoon.com/tagged/large-scale">large scale</a> web applications and keep the source code <strong>organized</strong> and <strong>maintainable</strong>.</p><h3>Initial application development</h3><p>Let’s say you want to build a HTTP API for users. An initial application might looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/414a444f81c89dffdb08322caf93b7cc/href">https://medium.com/media/414a444f81c89dffdb08322caf93b7cc/href</a></iframe><p>Done! Your application is ready. It looks clean and easy to understand. <em>Simplicity is one the </em><a href="http://jooby.org/"><em>Jooby</em></a><em> goals</em>.</p><h3>Large scale application development</h3><p>Suppose you want to extend your application with:</p><ul><li>A HTTP API for blogs.</li><li>A HTTP API for comments.</li><li>UI for users, blogs and comments.</li></ul><p>We can keep what we did before and extend the number of lines in our App.java. It is perfectly fine to do that, after all you own the application :)</p><p>But what if you want to <strong>better organize your source code</strong>? How can you? This is missing feature for most micro-frameworks but not in <a href="http://jooby.org/">Jooby</a>.</p><p><a href="http://jooby.org/">Jooby</a> provides some features and patterns that let you compose and organize your application.</p><h3>MVC routes (a.k.a. Controller)</h3><p>This is well-known pattern in <a href="https://hackernoon.com/tagged/java">Java</a> frameworks were you annotated methods and make them accessible via HTTP:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3237e64ff1f3a220bc32123baa4b9cb/href">https://medium.com/media/e3237e64ff1f3a220bc32123baa4b9cb/href</a></iframe><p>We can replace the <strong>script routes</strong> with our new controller so now our application looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d827b063f161f9573d05c98a8f39d81a/href">https://medium.com/media/d827b063f161f9573d05c98a8f39d81a/href</a></iframe><p>You can apply the same pattern for blogs, comments and UI controllers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef03785f106a91d93a808421a1cc9049/href">https://medium.com/media/ef03785f106a91d93a808421a1cc9049/href</a></iframe><p>This is how you usually split an application into multiple components using controller classes and annotations.</p><p>Wouldn’t be nice if we can keep the <strong>script routes</strong> and keep source code organized?</p><h3>Embedded applications</h3><p>This pattern let you compose one or more applications into one big application.</p><blockquote>It’s perfect if you love <strong>script routes</strong> and want to keep them organized.</blockquote><p>We split our application into 4 components, like we did before with controllers. But this time each component is an <em>application by itself</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce335d12bff9c38a0ec13945105985ea/href">https://medium.com/media/ce335d12bff9c38a0ec13945105985ea/href</a></iframe><p>Time to embedded it as we as we did in the controller example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/834b810b6efd329297d745d593df99b4/href">https://medium.com/media/834b810b6efd329297d745d593df99b4/href</a></iframe><blockquote>This approach let you build standalone applications that can be easily embedded into a major application.</blockquote><h3>Conclusion</h3><p>In this article we illustrated how to build large scale applications with Jooby using <strong>MVC</strong> or <strong>script routes</strong>.</p><p>Some users prefer <strong>MVC routes</strong> over <strong>script routes</strong>, but the truth is that you can use both or <strong>mix them together</strong>. <a href="http://jooby.org/">Jooby</a> just make sure to give you the right tools. Like always, decision is yours.</p><p>That’s all for now. Thank you for reading! If you are not yet convinced about <a href="http://jooby.org/">Jooby</a> here is nice article on why you should give it a try:</p><ul><li><a href="https://medium.com/@espina.edgar/java-micro-frameworks-why-jooby-59f0b346e819">Java micro-frameworks: Why Jooby?</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bde699f3e9e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/building-large-scale-applications-with-jooby-bde699f3e9e0">Building large scale applications with Jooby</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is new in Jooby 1.1 ?]]></title>
            <link>https://medium.com/@espina.edgar/what-is-new-in-jooby-1-1-a647cd463acc?source=rss-8d30443086b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a647cd463acc</guid>
            <category><![CDATA[web-framework]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[jooby]]></category>
            <dc:creator><![CDATA[Edgar Espina]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 11:55:02 GMT</pubDate>
            <atom:updated>2017-04-06T16:47:16.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGRJxErbaE7Tmta8-h1XTw.jpeg" /></figure><p>We recently announced a <a href="https://github.com/jooby-project/jooby/releases/tag/v1.1.0">new stable release</a> for <a href="http://jooby.org/">Jooby</a>. This new release comes with a couple of new and exciting features.</p><p>In this post we are going to talk about some of these features.</p><h3>Kotlin first-class support</h3><p><a href="http://jooby.org/doc/lang-kotlin">Kotlin</a> support is <strong>definitely</strong> the most exciting feature in 1.1. It’s well known that Java libraries just works in <a href="http://kotlinlang.org/">Kotlin</a>, so library/framework providers don’t need to do anything special.</p><p>For example here is how it looks a <a href="http://jooby.org/">Jooby</a> application in <a href="http://kotlinlang.org/">Kotlin</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3650759568a5ab4cf19191633a03f140/href">https://medium.com/media/3650759568a5ab4cf19191633a03f140/href</a></iframe><p>Not bad, but there isn’t anything special here we just make one–to-one translation from Java to <a href="http://kotlinlang.org/">Kotlin</a>.</p><h4>kotlin idioms</h4><p>Because we love <a href="http://kotlinlang.org/">Kotlin</a>, we do provide a <a href="http://jooby.org/doc/lang-kotlin">Kotlin module</a> which allow us to write idiomatic <a href="http://kotlinlang.org/">Kotlin</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3486a9b0bd4283fff34ba0b15aeac57b/href">https://medium.com/media/3486a9b0bd4283fff34ba0b15aeac57b/href</a></iframe><p>Much better, ugh?</p><p>The run function is type-safe builder which give you implicit access to a Jooby instance. Same for get function, but this time give you implicit access to the Request object.</p><p>Here is another idiom:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb5b82052cc8b1b20bf7f267c224e4aa/href">https://medium.com/media/cb5b82052cc8b1b20bf7f267c224e4aa/href</a></iframe><p>The route idiom group one or more route under a common path, like:/api/pets</p><ul><li>More at the <a href="http://jooby.org/doc/lang-kotlin">http://jooby.org/doc/lang-kotlin</a></li><li>Checkout the kotlin starter project: <a href="https://github.com/jooby-project/rocker-starter">https://github.com/jooby-project/kotlin-starter</a></li></ul><h3>LiveReload</h3><p>No more browser refresh button!!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f8f5c1fb3289909d2219c7f1a0eb5d9/href">https://medium.com/media/8f8f5c1fb3289909d2219c7f1a0eb5d9/href</a></iframe><p>The <a href="http://jooby.org/doc/livereload/">LiveReload module</a> listen for file changes and automatically reload the browser.</p><ul><li>More at <a href="http://jooby.org/doc/livereload">http://jooby.org/doc/livereload</a></li></ul><h3>rocker templates</h3><p><a href="https://github.com/fizzed/rocker">Rocker</a> is a fast, safe and statically typed template engine:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c97c31c2ef3ddecd5654944dfa7f961b/href">https://medium.com/media/c97c31c2ef3ddecd5654944dfa7f961b/href</a></iframe><p>You can efficiently render them from your application:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fede5518347b91eb873ebccf34970f21/href">https://medium.com/media/fede5518347b91eb873ebccf34970f21/href</a></iframe><ul><li>More at <a href="http://jooby.org/doc/requery/">http://jooby.org/doc/rocker</a></li><li>Checkout the rocker starter project: <a href="https://github.com/jooby-project/rocker-starter">https://github.com/jooby-project/rocker-starter</a></li></ul><h3>requery db</h3><p><a href="https://github.com/requery/requery">Requery</a> is a modern SQL, statically typed persistence engine:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b50ec803b27b8bb8f0ee24e80aca3465/href">https://medium.com/media/b50ec803b27b8bb8f0ee24e80aca3465/href</a></iframe><ul><li>More at <a href="http://jooby.org/doc/requery">http://jooby.org/doc/requery</a></li><li>Checkout the rocker starter project: <a href="https://github.com/jooby-project/rocker-starter">https://github.com/jooby-project/requery-starter</a></li></ul><h3>there is more</h3><ul><li>We now support MVC Web sockets: <a href="http://jooby.org/doc/#web-sockets-listener">http://jooby.org/doc/#web-sockets-listener</a></li><li>Improved performance. Jooby is now 2x/3x faster. <a href="https://github.com/networknt/microservices-framework-benchmark">https://github.com/networknt/microservices-framework-benchmark</a></li></ul><p>Hope you enjoy it!</p><p>Complete release notes are available here: <a href="https://github.com/jooby-project/jooby/releases/tag/v1.1.0">https://github.com/jooby-project/jooby/releases/tag/v1.1.0</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a647cd463acc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java micro-frameworks: Why Jooby?]]></title>
            <link>https://medium.com/@espina.edgar/java-micro-frameworks-why-jooby-59f0b346e819?source=rss-8d30443086b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/59f0b346e819</guid>
            <category><![CDATA[jooby]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[framework]]></category>
            <dc:creator><![CDATA[Edgar Espina]]></dc:creator>
            <pubDate>Thu, 30 Mar 2017 15:57:46 GMT</pubDate>
            <atom:updated>2020-06-02T19:22:08.209Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the last years the number of new micro-frameworks increased dramatically. The days where we have to choose between two or three frameworks are gone and won’t be back!</p><p>Today, we can choose between <a href="http://www.pippo.ro/">Pippo</a>, <a href="http://www.rapidoid.org/">Rapidoid</a>, <a href="http://sparkjava.com/">Sparkjava</a>, <a href="http://www.ninjaframework.org/">Ninjaframework</a>, …, etc.</p><p>Some of these might be considered micro-frameworks, while others aren’t. Also, didn’t want to mention <a href="https://projects.spring.io/spring-boot">Spring Boot</a> and <a href="https://www.playframework.com/">Play Framework</a> because they definitely aren’t.</p><p>In this post going to talk about <a href="https://jooby.io/">Jooby</a> <em>a scalable, fast and modular micro-framework for the JVM</em>.</p><h3>What is a micro-framework?</h3><p>Hard to tell, but some benefits a micro-framework could be:</p><ul><li>Fast. Fast bootstrap and responses.</li><li>Easy. To learn, setup, maintain and extend.</li></ul><p><em>Long bootstrap</em> and <em>over-engineering</em> are usually a symptom of <em>bloated</em> library or framework.</p><p>Also, I would love to agree that micro-frameworks (in general) are <strong>NOT toys</strong>. Some people tend to under estimate micro-frameworks without giving them a chance.</p><blockquote>Simplicity is goal that every framework developer should follow. Complexity comes from business requirements (problem to solve). It should never come from our technology stack.</blockquote><p>Seriously, it is time to build Java web application as quick and easy without compromising scalability and application performance.</p><p>Don’t you think?</p><h3><strong>jooby: do more, more easily</strong></h3><p><a href="https://jooby.io/">Jooby</a> is a <em>minimally opinionated</em> micro-framework with a <strong>modern</strong> and <strong>powerful</strong> HTTP API for building web applications in Java, <a href="http://jooby.org/doc/lang-js">JavaScript</a> or <a href="http://jooby.org/doc/lang-kotlin">Kotlin</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8269210e02625e8e043c2f11b61272b5/href">https://medium.com/media/8269210e02625e8e043c2f11b61272b5/href</a></iframe><p>These 14 lines give you a <strong>beautiful</strong> Hello World web application. The route / accepts an optional name parameter and sends back a friendly message to the client:</p><pre>GET /            =&gt; Hello World!<br>GET /?name=Mundo =&gt; Hello Mundo!</pre><p>There is one point here worth mentioning:</p><blockquote><em>The use of the instance initializer.</em></blockquote><pre>{<br>  get(&quot;/&quot;, () -&gt; &quot;Hello World!&quot;)<br>}</pre><p>Which means you need an <strong>instance</strong> to run an application. Here is the exact same application without extending <a href="http://jooby.org/">Jooby</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a0e0031389f0c57836af00b4bdc0f3c/href">https://medium.com/media/8a0e0031389f0c57836af00b4bdc0f3c/href</a></iframe><p>See? No <strong>shared/static/global state.</strong> This is probably obvious for you but you will be surprised with the number of (micro-)frameworks that make <strong>use and abuse of shared state</strong>.</p><h3>programming models</h3><p><a href="https://jooby.io/">Jooby</a> offers two programming models:</p><ul><li><strong>Script</strong>: based on <em>Java 8 lambdas which is annotation </em>and<em> reflection free</em>. Similar to <a href="http://www.sinatrarb.com/">sinatra</a>, <a href="https://expressjs.com/">express.js</a>, etc…</li><li><strong>MVC</strong>: based on <em>Java class that depends on annotations and reflection</em>. Similar to <a href="https://jersey.java.net/">Jersey</a>, <a href="https://spring.io/">Spring</a>, etc…</li></ul><p>You can choose one or <em>mix them both</em> in one application. <strong>It is</strong> <strong>your call</strong>.</p><p>The next example uses script routes for HTML templates and mvc routes for business logic (JSON API):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/beea2ac2d44f2387d135071aa81a7c2b/href">https://medium.com/media/beea2ac2d44f2387d135071aa81a7c2b/href</a></iframe><p>From script routes we access the application services via require method:</p><pre>Pets pets = require(Pets.class);</pre><p>From mvc routes we access the application services via @Inject annotation:</p><pre>@Inject<br>public Pets(Database db) {<br>  ...<br>}</pre><p>In both cases, <a href="https://github.com/google/guice">Guice</a> is going to provisioning those services.</p><p>The example also uses two modules:</p><ul><li><a href="http://jooby.org/doc/jackson">Jackson</a> for JSON processing</li><li><a href="http://jooby.org/doc/rocker">Rocker</a> for type-safe and super fast templates</li></ul><h3>micro or full-stack</h3><p>Does a micro-framework setup a connection pool? an ORM? a template engine?</p><p>The answer to all these questions is: NO. Why? Because a micro-framework usually does <em>one thing only</em>.</p><p>This is partially true for <a href="https://jooby.io/">Jooby</a>. It is micro at his core with only three hard dependencies (<a href="https://github.com/typesafehub/config">config</a>, <a href="https://logback.qos.ch/">logback</a> and g<a href="https://github.com/google/guice">uice</a>). Everything else is pluggable (even the HTTP server).</p><p>You can extend and compose your application via modules:</p><blockquote>Modules are thin and do a lot of work to bootstrap and configure an external library, but they don’t provide a new level of abstraction nor [do] they provide a custom API to access functionality in that library. Instead they expose the library components as they are (major difference with other Java Web frameworks).</blockquote><p>If you think twice, it is a <strong>sane and safe approach to provide new features</strong>. Users don’t have to learn a new API for using their favorite library, even more users have complete control of the library. This increases developer productivity and simplifies development of modules.</p><p>A Module looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80ee7cb9f80dc067958a95556286a92e/href">https://medium.com/media/80ee7cb9f80dc067958a95556286a92e/href</a></iframe><p>The configure callback has three parameter:</p><ol><li>env: which give you access to environment where the application runs: dev, prod, etc… and to application core components.</li><li>conf: application configuration properties.</li><li>binder: Guice binder where you can define and wire application services.</li></ol><p>Once defined, you need to install it. Installation is done via use method:</p><pre>{<br>  use(<strong>new</strong> MyModule());<br>}</pre><p>In similar fashion your module might expose routes too:</p><pre><strong>void</strong> configure(Env env, Config conf, Binder binder) {<br>  Router router = env.router();<br>  router.get(&quot;/ping&quot;, () -&gt; &quot;pong!&quot;);<br>}</pre><p>Modules are a key concept in <a href="https://jooby.io/">Jooby</a> and help you to progressively build full-stack applications.</p><h3>productivity</h3><p>There are plenty of modules ready to use: <a href="http://jooby.org/modules">https://jooby.io/modules</a>. There are modules for connection pool, all kind of datastore, ORMs, ESB, Swagger, Raml, Template Engines, Job Scheduler, Async/Reactive programming among others.</p><p>Did you change a Java class? Forget about long restarts, jooby:run quickly restart the application and your changes are immediately available.</p><p>There is a LiveReload module in addition to jooby:run. So you don’t ever need to hit the refresh button on your browser.</p><h3>tests</h3><p>This is another issue or concern when choosing a micro-framwork. It is a valid concern and not all the micro-frameworks supports unit or integration tests.</p><p>Luckily enough, both are covered by <a href="https://jooby.io/">Jooby</a>.</p><p>Let’s see how to do a unit test against a Hello World application:</p><pre>@Test<br><strong>public</strong> <strong>void</strong> unitTest() {<br>  MockRouter router = new MockRouter(new App());<br>  assertEquals(&quot;Hello World!&quot;, router.get(&quot;/&quot;));<br>}</pre><p>and the integration test:</p><pre>@ClassRule<br><strong>private</strong> <strong>static</strong> JoobyRule bootstrap <strong>=</strong> <strong>new</strong> JoobyRule(<strong>new</strong> MyApp());</pre><pre>@Test<br><strong>public</strong> <strong>void</strong> integrationTest() {<br>  get<strong>(</strong>&quot;/&quot;<strong>)</strong><br>      <strong>.</strong>then<strong>()</strong><br>      <strong>.</strong>assertThat<strong>()</strong><br>      <strong>.</strong>body<strong>(</strong>equalTo<strong>(</strong>&quot;Hello World!&quot;<strong>));</strong><br>}</pre><h3>code quality</h3><p>Code quality is the only way to build rock solid software.</p><p>We took code quality very serious in <a href="https://jooby.io/">Jooby</a> with more than 4000 tests with a code coverage of 99.5%.</p><p>See it by yourself: <a href="https://coveralls.io/github/jooby-project/jooby">https://coveralls.io/github/jooby-project/jooby</a></p><h3>performance</h3><p><a href="http://jooby.org/">Jooby</a> isn’t only easy to use but also has good/decent performance (compared to some big players).</p><p>We invite you to check these two 3rd party benchmarks:</p><ol><li><a href="https://www.techempower.com/benchmarks/">https://www.techempower.com/benchmarks</a></li><li><a href="https://github.com/networknt/microservices-framework-benchmark">https://github.com/networknt/microservices-framework-benchmark</a></li></ol><p>I’m going to talk about thread-model in a another post. For now you need to know <a href="https://jooby.io/">Jooby</a> uses an <strong>event-loop</strong> model and your code <strong>always runs in a worker thread</strong>. What this mean? You can safely block a worker thread and your application will be responsive.</p><h3><strong>final comments</strong></h3><p><a href="https://jooby.io/">Jooby</a> makes Java web <em>development fun again</em>. It is <em>simple, expressive </em>and <em>effective</em>.</p><p>The number of lines required to build something are usually smaller than in any other Java framework.</p><p>At the same time has great performance while keeping you safe by using a worker thread.</p><p>We provide all the tools to make you more productive: <em>hotreload</em>, <em>browser live reload</em>, <em>unit/integrations</em> tests and lot of <a href="http://jooby.org/modules">modules</a>.</p><p><strong>Not convinced yet</strong>?</p><p>Checkout our <a href="http://jooby.org/quickstart">quickstart guide</a> or one of our <a href="https://github.com/search?q=topic%3Astarter+org%3Ajooby-project&amp;type=Repositories">starter projects</a>.</p><p><strong>Do you have questions</strong>?</p><p><strong>Join our channel</strong> and we’ll help you: <a href="https://gitter.im/jooby-project/jooby">https://gitter.im/jooby-project/jooby</a></p><p><strong>Try it! You will really enjoy it! I promise!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59f0b346e819" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>