{"@attributes":{"version":"2.0"},"channel":{"title":"Clianz","description":"Tech and Stuff","link":"http:\/\/www.clianz.com\/","pubDate":"Sun, 20 Oct 2019 18:20:02 +0000","lastBuildDate":"Sun, 20 Oct 2019 18:20:02 +0000","generator":"Jekyll v3.8.5","item":[{"title":"Deploying Scala\/Spray App on Cloud Foundry","description":"<p>A few months ago I was playing with Scala\/Spray on Bluemix (Cloud Foundry). Deploying it wasn\u2019t as straight forward as I thought, here is what I learnt. \n<!--more--><\/p>\n\n<h2 id=\"building-the-jar\">Building the Jar<\/h2>\n\n<p>Creating a straight jar artefact with Maven shade plugin run perfectly on local machine. However, this artefact doesn\u2019t seem to work on Bluemix when deployed.<\/p>\n\n<p>This is strange because Cloud Foundry\/Bluemix should support all standard JVM executable. A quick look at the <a href=\"https:\/\/github.com\/cloudfoundry\/java-buildpack\">buildpack<\/a> seem to suggest it does support a variety of artefact formats, so let\u2019s go to plan B\u2026<\/p>\n\n<h2 id=\"what-worked\">What worked<\/h2>\n<p>One of the other artefact formats it support is the <a href=\"https:\/\/github.com\/cloudfoundry\/java-buildpack\/blob\/master\/docs\/container-dist_zip.md\">distzip<\/a> format. Once the build script was switched to generate artefact in that format, it worked!<\/p>\n\n<p>Using the distzip format should be straight forward if you are using Gradle build system. If you prefer Maven, then check out <a href=\"https:\/\/github.com\/icha024\/scala-forex\/blob\/master\/pom.xml\">this build file<\/a> in my demo project.<\/p>\n\n<p>Once built, all that is left is to push the zip:<\/p>\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>cf push awesomeServiceName -p awesome-projet-1.0-SNAPSHOT-bin.zip\n<\/code><\/pre><\/div><\/div>\n\n<p>I haven\u2019t looked back at why the basic Jar didn\u2019t work, it\u2019s something still on my ToDo list. Hope this helps if someone else ran into this problem.<\/p>\n","pubDate":"Tue, 13 Sep 2016 08:21:49 +0000","link":"http:\/\/www.clianz.com\/2016\/09\/13\/deploying-scala-app-on-cloud-foundry\/","guid":"http:\/\/www.clianz.com\/2016\/09\/13\/deploying-scala-app-on-cloud-foundry\/","category":["Bluemix","Cloud","Scala"]},{"title":"Reagent - ClojureScript and React made easy","description":"<p>Recently I\u2019ve started reading into Clojure and came across something really interesting.<\/p>\n\n<p>Clojure is a JVM based functional programming language, based on Lisp. React is a recent web frontend framework from Facebook that has been everywhere lately. React a reactive Javascript framework, similar to AngularJS, but takes a different approach in component management to make it much faster and more scalable.<\/p>\n\n<p>Now this is where it gets interesting - Clojure can be compiled to Javascript via the ClojureScript plugin. Combine the two and you get Reagent, a framework that integrated them together nicely.\n<!--more--><\/p>\n\n<h2 id=\"starting-a-reagent-project---in-3-steps\">Starting a Reagent Project - in 3 steps<\/h2>\n\n<p>There are two ways to run ClojureScript + React, the first to build multi page app and build both server and client side in Clojure, the other way is to just build the frontend with it as a single page app. We\u2019re much more interested in the latter.<\/p>\n\n<ul>\n  <li><strong>First download and install <a href=\"http:\/\/leiningen.org\/\">Leiningen<\/a><\/strong> for building Clojure.\nOnce installed, we can <strong>generate the project<\/strong> a new Reagent frontend project with this easily by running:<\/li>\n<\/ul>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>  lein new reagent-frontend myproject\n<\/code><\/pre><\/div><\/div>\n<ul>\n  <li><strong>To run it<\/strong>:<\/li>\n<\/ul>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>cd myproject\nlein cljsbuild auto\n<\/code><\/pre><\/div><\/div>\n<ul>\n  <li><strong>Open the html file<\/strong> with your browser<\/li>\n<\/ul>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>myproject\/public\/index.html\n<\/code><\/pre><\/div><\/div>\n\n<p>You should see the <strong>\u2018Welcome to Reagent\u2019<\/strong> demo page. Simple!<\/p>\n\n<h2 id=\"how-did-it-work\">How did it work?<\/h2>\n\n<p>The Clojure script in<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>myproject\/src\/myproject\/core.cljs\n<\/code><\/pre><\/div><\/div>\n<p>got compiled into a Javascript file at<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>myproject\/public\/js\/app.js\n<\/code><\/pre><\/div><\/div>\n\n<p>The index.html page does nothing more than including that Javascript file, and voila!<\/p>\n\n<h2 id=\"making-things-happen-reactively\">Making things happen reactively<\/h2>\n<p>Now let\u2019s have a look at the reactive part by demoing the obligatory live counter button. Update your core.cljs file to the following:<\/p>\n\n<div class=\"language-clj highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"p\">(<\/span><span class=\"nf\">ns<\/span><span class=\"w\"> <\/span><span class=\"n\">myproject.core<\/span><span class=\"w\">\n    <\/span><span class=\"p\">(<\/span><span class=\"no\">:require<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"n\">reagent.core<\/span><span class=\"w\"> <\/span><span class=\"no\">:as<\/span><span class=\"w\"> <\/span><span class=\"n\">r<\/span><span class=\"w\"> <\/span><span class=\"no\">:refer<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"n\">atom<\/span><span class=\"p\">]]<\/span><span class=\"w\">\n              <\/span><span class=\"p\">[<\/span><span class=\"n\">reagent.session<\/span><span class=\"w\"> <\/span><span class=\"no\">:as<\/span><span class=\"w\"> <\/span><span class=\"n\">session<\/span><span class=\"p\">]<\/span><span class=\"w\">\n              <\/span><span class=\"p\">[<\/span><span class=\"n\">secretary.core<\/span><span class=\"w\"> <\/span><span class=\"no\">:as<\/span><span class=\"w\"> <\/span><span class=\"n\">secretary<\/span><span class=\"w\"> <\/span><span class=\"no\">:include-macros<\/span><span class=\"w\"> <\/span><span class=\"n\">true<\/span><span class=\"p\">]))<\/span><span class=\"w\">\n\n<\/span><span class=\"c1\">;; -------------------------<\/span><span class=\"w\">\n<\/span><span class=\"c1\">;; Views<\/span><span class=\"w\">\n\n<\/span><span class=\"p\">(<\/span><span class=\"nf\">defonce<\/span><span class=\"w\"> <\/span><span class=\"n\">click-count<\/span><span class=\"w\"> <\/span><span class=\"p\">(<\/span><span class=\"nf\">r\/atom<\/span><span class=\"w\"> <\/span><span class=\"mi\">0<\/span><span class=\"p\">))<\/span><span class=\"w\">\n\n<\/span><span class=\"p\">(<\/span><span class=\"k\">defn<\/span><span class=\"w\"> <\/span><span class=\"n\">home-page<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n  <\/span><span class=\"p\">[<\/span><span class=\"no\">:div<\/span><span class=\"w\">\n    <\/span><span class=\"p\">[<\/span><span class=\"no\">:h2<\/span><span class=\"w\"> <\/span><span class=\"s\">\"Welcome to Reagent\"<\/span><span class=\"p\">]<\/span><span class=\"w\">\n    <\/span><span class=\"p\">[<\/span><span class=\"no\">:p<\/span><span class=\"w\"> <\/span><span class=\"s\">\"Just playin around...\"<\/span><span class=\"p\">]<\/span><span class=\"w\">\n    <\/span><span class=\"p\">[<\/span><span class=\"no\">:input<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"no\">:type<\/span><span class=\"w\"> <\/span><span class=\"s\">\"button\"<\/span><span class=\"w\"> <\/span><span class=\"no\">:value<\/span><span class=\"w\"> <\/span><span class=\"s\">\"click this\"<\/span><span class=\"w\"> <\/span><span class=\"no\">:on-click<\/span><span class=\"w\"> <\/span><span class=\"o\">#<\/span><span class=\"p\">(<\/span><span class=\"nf\">swap!<\/span><span class=\"w\"> <\/span><span class=\"n\">click-count<\/span><span class=\"w\"> <\/span><span class=\"nb\">inc<\/span><span class=\"p\">)}]<\/span><span class=\"w\">\n    <\/span><span class=\"p\">[<\/span><span class=\"no\">:p<\/span><span class=\"w\"> <\/span><span class=\"s\">\"i've been clicked for: \"<\/span><span class=\"w\"> <\/span><span class=\"o\">@<\/span><span class=\"n\">click-count<\/span><span class=\"p\">]<\/span><span class=\"w\">\n  <\/span><span class=\"p\">]<\/span><span class=\"w\">\n<\/span><span class=\"p\">)<\/span><span class=\"w\">\n\n<\/span><span class=\"c1\">;; -------------------------<\/span><span class=\"w\">\n<\/span><span class=\"c1\">;; Initialize app<\/span><span class=\"w\">\n\n<\/span><span class=\"p\">(<\/span><span class=\"k\">defn<\/span><span class=\"w\"> <\/span><span class=\"n\">mount-root<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n  <\/span><span class=\"p\">(<\/span><span class=\"nf\">r\/render<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"n\">home-page<\/span><span class=\"p\">]<\/span><span class=\"w\"> <\/span><span class=\"p\">(<\/span><span class=\"nf\">.getElementById<\/span><span class=\"w\"> <\/span><span class=\"n\">js\/document<\/span><span class=\"w\"> <\/span><span class=\"s\">\"app\"<\/span><span class=\"p\">)))<\/span><span class=\"w\">\n\n<\/span><span class=\"p\">(<\/span><span class=\"k\">defn<\/span><span class=\"w\"> <\/span><span class=\"n\">init!<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n  <\/span><span class=\"p\">(<\/span><span class=\"nf\">mount-root<\/span><span class=\"p\">))<\/span><span class=\"w\">\n<\/span><\/code><\/pre><\/div><\/div>\n\n<p>Refresh the <em>index.html<\/em> page and you will see the button, with a counter below that increments count on click.<\/p>\n\n<p>Notice the component is \u2018mounted\u2019 to a HTML tag, and the content of the tag are eventually rendered via Javascript, this is React\u2019s framework in action. ClojureScript works nicely here with it\u2019s tag almost always matching the HTML ones, while not being as clutered as HTML itself - it reminds me of the lovely Jade template in NodeJS.<\/p>\n\n<p><a href=\"https:\/\/github.com\/icha024\/clojurescript-react-playground\/tree\/freeze\">Demo code available on Github<\/a><\/p>\n\n<h2 id=\"more-reading\">More Reading<\/h2>\n<ul>\n  <li>Reactive framework from Facebook: <a href=\"https:\/\/facebook.github.io\/react\/\">https:\/\/facebook.github.io\/react\/<\/a><\/li>\n  <li>Reagent framework: <a href=\"https:\/\/reagent-project.github.io\/\">https:\/\/reagent-project.github.io\/<\/a><\/li>\n<\/ul>\n\n<p>That\u2019s all for now, I got to go hone up my Clojure skills!<\/p>\n","pubDate":"Sun, 29 May 2016 10:55:48 +0000","link":"http:\/\/www.clianz.com\/2016\/05\/29\/clojurescript-react-reagent\/","guid":"http:\/\/www.clianz.com\/2016\/05\/29\/clojurescript-react-reagent\/","category":["Clojure","ClojureScript","React","Reagent","Clojure","ClojureScript","React","Reagent"]},{"title":"Generating Java Spring-MVC code from Swagger Spec","description":"<p><strong>(Edit, July 2017: This Async Spring template in Swagger codegen is deprecated and no longer maintained. Please use the normal Spring template or use a custom template instead. You\u2019ll probably want the newer streaming API oriented convention in Spring 5.x anyway. The plugin and configuration example should still work with other available templates. Keeping this post for reference purposes)<\/strong><\/p>\n\n<p>REST services skeleton code generation is a quick way to get started in implementing the service from popular Swagger spec describing the interface.<\/p>\n\n<p>In this post we\u2019ll look at generating Java Spring MVC code from Swagger spec. There are a few frameworks out there, but at the time I couldn\u2019t find the one that I want - and so I\u2019ve created a new template for my needs. Here is a quick walkthrough on setting up code-gen for Java Spring MVC project.\n<!--more--><\/p>\n\n<h2 id=\"spring-mvc-java-templates\">Spring MVC Java Templates<\/h2>\n<p>There are plenty of projects and templates out there there to generate skeleton server code from Swagger spec, but at the time I haven\u2019t came across one that suit my needs. Ideally it should:<\/p>\n\n<ul>\n  <li>\n    <p>Take advantage of Java <strong>servlet 3.0+ async<\/strong> feature.<\/p>\n  <\/li>\n  <li>\n    <p>Generate code for <strong>Spring MVC<\/strong> (my preferred framework)<\/p>\n  <\/li>\n  <li>\n    <p>Integrate with the rest of my stack and build tools (<strong>Spring Boot + Maven<\/strong>)<\/p>\n  <\/li>\n  <li>\n    <p>Generate <strong>code directly in target\/gen<\/strong>, instead of a new standalone stub that need us to manually copy\/paste the bits we want.\n This will be useful for updating Swagger spec on existing project, otherwise it\u2019s messy trying to manually figure out what is fresh generated code and merge it with existing implementations.<\/p>\n  <\/li>\n<\/ul>\n\n<h2 id=\"the-solution\">The Solution<\/h2>\n\n<h3 id=\"introducing-the-j8-async-template-in-swagger-codegen\">Introducing the j8-async template in Swagger-codegen<\/h3>\n\n<p>The default Spring MVC template from Swagger codegen was a good start. The <strong>j8-async<\/strong> template is a modified version of it with the following changes:<\/p>\n\n<ul>\n  <li>\n    <p>Added <code class=\"highlighter-rouge\">&lt;Callable&gt;<\/code> tag to response to use Spring\u2019s async servlet feature.<\/p>\n  <\/li>\n  <li>\n    <p>Generate code with Java 8\u2019s inteface default instead of a plain class.<\/p>\n  <\/li>\n<\/ul>\n\n<p>This new template was <a href=\"https:\/\/github.com\/swagger-api\/swagger-codegen\/pull\/1742\">merged into swagger-codegen version 2.1.5<\/a>, you may choose to generate code with it by passing in \u2018j8-async\u2019 instead of the \u2018default\u2019<\/p>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"c\">&lt;!-- Swagger codegen --&gt;<\/span>\n<span class=\"nt\">&lt;dependency&gt;<\/span>\n\t<span class=\"nt\">&lt;groupId&gt;<\/span>io.swagger<span class=\"nt\">&lt;\/groupId&gt;<\/span>\n\t<span class=\"nt\">&lt;artifactId&gt;<\/span>swagger-core<span class=\"nt\">&lt;\/artifactId&gt;<\/span>\n\t<span class=\"nt\">&lt;version&gt;<\/span>${swagger.version}<span class=\"nt\">&lt;\/version&gt;<\/span>\n<span class=\"nt\">&lt;\/dependency&gt;<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>We\u2019ll also need Spring-Fox dependency for codegen:<\/p>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nt\">&lt;dependency&gt;<\/span>\n\t<span class=\"nt\">&lt;groupId&gt;<\/span>io.springfox<span class=\"nt\">&lt;\/groupId&gt;<\/span>\n\t<span class=\"nt\">&lt;artifactId&gt;<\/span>springfox-swagger2<span class=\"nt\">&lt;\/artifactId&gt;<\/span>\n\t<span class=\"nt\">&lt;version&gt;<\/span>${springfox.version}<span class=\"nt\">&lt;\/version&gt;<\/span>\n<span class=\"nt\">&lt;\/dependency&gt;<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>And the associated config in swagger-properties for api-docs:<\/p>\n\n<div class=\"language-properties highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"py\">springfox.documentation.swagger.v2.path<\/span><span class=\"p\">=<\/span><span class=\"s\">\/api-docs<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h3 id=\"combining-with-maven-plugin\">Combining with Maven plugin<\/h3>\n<p>Normally the swagger-code gen project just generates stub, this is now what we want. There is a Maven plugin to get around this to generate code into our target\/gen - combine this with the Java 8 interface default feature, and we have a generate stub with default implementation nicely integrated with your project.<\/p>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"c\">&lt;!-- Generate REST default interface from Swagger spec --&gt;<\/span>\n<span class=\"nt\">&lt;plugin&gt;<\/span>\n\t<span class=\"nt\">&lt;groupId&gt;<\/span>io.swagger<span class=\"nt\">&lt;\/groupId&gt;<\/span>\n\t<span class=\"nt\">&lt;artifactId&gt;<\/span>swagger-codegen-maven-plugin<span class=\"nt\">&lt;\/artifactId&gt;<\/span>\n\t<span class=\"nt\">&lt;version&gt;<\/span>${swagger.codegen.version}<span class=\"nt\">&lt;\/version&gt;<\/span>\n\t<span class=\"nt\">&lt;executions&gt;<\/span>\n\t\t<span class=\"nt\">&lt;execution&gt;<\/span>\n\t\t\t<span class=\"nt\">&lt;goals&gt;<\/span>\n\t\t\t\t<span class=\"nt\">&lt;goal&gt;<\/span>generate<span class=\"nt\">&lt;\/goal&gt;<\/span>\n\t\t\t<span class=\"nt\">&lt;\/goals&gt;<\/span>\n\t\t\t<span class=\"nt\">&lt;configuration&gt;<\/span>\n\t\t\t\t<span class=\"nt\">&lt;inputSpec&gt;<\/span>src\/main\/resources\/swagger.yaml<span class=\"nt\">&lt;\/inputSpec&gt;<\/span>\n\t\t\t\t<span class=\"nt\">&lt;language&gt;<\/span>spring-mvc<span class=\"nt\">&lt;\/language&gt;<\/span>\n\t\t\t\t<span class=\"nt\">&lt;configOptions&gt;<\/span>\n\t\t\t\t\t<span class=\"nt\">&lt;sourceFolder&gt;<\/span>src\/gen\/java\/main<span class=\"nt\">&lt;\/sourceFolder&gt;<\/span>\n\t\t\t\t\t<span class=\"nt\">&lt;library&gt;<\/span>j8-async<span class=\"nt\">&lt;\/library&gt;<\/span>\n\t\t\t\t<span class=\"nt\">&lt;\/configOptions&gt;<\/span>\n\t\t\t<span class=\"nt\">&lt;\/configuration&gt;<\/span>\n\t\t<span class=\"nt\">&lt;\/execution&gt;<\/span>\n\t<span class=\"nt\">&lt;\/executions&gt;<\/span>\n<span class=\"nt\">&lt;\/plugin&gt;<\/span>\n<\/code><\/pre><\/div><\/div>\n<p><strong>(Edit, July 2017: This template deprecated, please use the other available ones, or specify a custom template intead)<\/strong><\/p>\n\n<p>Just point it to your swagger spec and pick the \u2018j8-async\u2019 option. Because it uses a default interface, it will already work out of the box with the stub response.<\/p>\n\n<h2 id=\"overriding-the-stub\">Overriding the stub<\/h2>\n<p>To provide a custom implementation on the operation, just implemented the gerated API then override the stub method.<\/p>\n\n<p>For example, here we generate Java stub for the Uber Swagger spec, then override the \u2018\/me\u2019 operation by overriding the generated \u2018MeApi\u2019 interface:<\/p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nd\">@RestController<\/span>\n<span class=\"kd\">public<\/span> <span class=\"kd\">class<\/span> <span class=\"nc\">MeService<\/span> <span class=\"kd\">implements<\/span> <span class=\"nc\">MeApi<\/span> <span class=\"o\">{<\/span>\n\n\t<span class=\"c1\">\/\/ Tip: In Intellj, use alt-insert to select which operation to override.<\/span>\n\t<span class=\"nd\">@Override<\/span>\n\t<span class=\"kd\">public<\/span> <span class=\"nc\">Callable<\/span><span class=\"o\">&lt;<\/span><span class=\"nc\">ResponseEntity<\/span><span class=\"o\">&lt;<\/span><span class=\"nc\">Profile<\/span><span class=\"o\">&gt;&gt;<\/span> <span class=\"nf\">meGet<\/span><span class=\"o\">()<\/span> <span class=\"kd\">throws<\/span> <span class=\"nc\">NotFoundException<\/span> <span class=\"o\">{<\/span>\n\t\t<span class=\"k\">return<\/span> <span class=\"o\">()<\/span> <span class=\"o\">-&gt;<\/span> <span class=\"o\">{<\/span>\n\t\t\t<span class=\"nc\">Profile<\/span> <span class=\"n\">profile<\/span> <span class=\"o\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">Profile<\/span><span class=\"o\">();<\/span>\n\t\t\t<span class=\"n\">profile<\/span><span class=\"o\">.<\/span><span class=\"na\">setFirstName<\/span><span class=\"o\">(<\/span><span class=\"s\">\"Ian\"<\/span><span class=\"o\">);<\/span>\n\t\t\t<span class=\"k\">return<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">ResponseEntity<\/span><span class=\"o\">&lt;&gt;(<\/span><span class=\"n\">profile<\/span><span class=\"o\">,<\/span> <span class=\"nc\">HttpStatus<\/span><span class=\"o\">.<\/span><span class=\"na\">OK<\/span><span class=\"o\">);<\/span>\n\t\t<span class=\"o\">};<\/span>\n\t<span class=\"o\">}<\/span>\n<span class=\"o\">}<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>We can pick which operations to override and customise easily as the swagger spec doc changes, no more manually copy\/pasting from the stub!<\/p>\n\n<h2 id=\"sample-project-on-github\">Sample project on Github<\/h2>\n<p>The sample project can be found at: <a href=\"https:\/\/github.com\/icha024\/java-mvc-swagger-gen-demo\">https:\/\/github.com\/icha024\/java-mvc-swagger-gen-demo<\/a><\/p>\n\n<p>This uses the Uber Swagger spec as mentioned above, and override only the \u2018Me\u2019 API with custom inplementation.<\/p>\n\n<p>Happy Swag Coding!<\/p>\n","pubDate":"Sun, 29 May 2016 10:43:48 +0000","link":"http:\/\/www.clianz.com\/2016\/05\/29\/java-mvc-swagger-gen\/","guid":"http:\/\/www.clianz.com\/2016\/05\/29\/java-mvc-swagger-gen\/","category":["java","swagger","callable","code-gen","Spring MVC","Java","Spring","Swagger"]},{"title":"Things You Should Know Before Choosing Bluemix","description":"<h2 id=\"about-bluemix\">About Bluemix.<\/h2>\n\n<p>Bluemix is a cloud service provider that let will host your web app for you on the cloud. Similar to Amazon\u2019s AWS, Microsoft\u2019s Azure, Google\u2019s Cloud Engine, Saleforce\u2019s Heroku, Redhat\u2019s Openshift, etc.\n<!--more--><\/p>\n\n<ul>\n  <li>\n    <p><strong>Based on Clound Foundry<\/strong> \u2013 Bluemix can provide container hosting (eg. Docker or VM), but the real interesting one is the Cloud Foundry based solution. It allows for rapid development without worrying about managing the server or the container environment. It takes care of all the mundane bits like setting up basic monitoring system, basic log aggregation, and scaling. You get all those automatically on the web dashboard, or from your command-line if you prefer. Literally all you have to do to deploy webapp, coded in most programming languages, is just one command:<\/p>\n\n    <div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>cf push YOUR_APP_NAME\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>\n    <p><strong>Pricing<\/strong> \u2013 This might be more expensive than AWS or Google Compute on paper, but keep in mind this is a PaaS product so that you don\u2019t have to worry about any infrastructure. Bluemix charges for how much memory your app was allocated and for how long. The free tier allows up to 512MB\/Hour <strong>per app<\/strong> \u2013 no matter how many instance you choose to deploy. This means you could have 1 app instance with 512MB allocated, or 2 instance of that same app with 256MB allocated, it\u2019s free. You could also have multiple apps, and as long as each app don\u2019t have more than 512MB allocated \u2013 it\u2019s still free. But you might think \u2013 if I get 8 instance of an app with 64MB allocated each then I\u2019m getting a great deal for 8 instance deployed right? Yes and no, it doesn\u2019t exactly work that way, your CPU allocation is proportional to how much memory you assign to it. So yes you have 8 instance, but each instance has a smaller CPU time slice \u2013 meaning you get 8 slow instances of your app.<\/p>\n  <\/li>\n  <li>\n    <p><strong>Support<\/strong> \u2013 Even on the free tier, you can still get reasonable support and raise tickets. The respond time is not the fastest, but usually they do respond within a couple of days. Responding to tickets within a couple of days is better than not responding, but it\u2019s sometimes not good enough if you are paying for usage above the free tier.<\/p>\n  <\/li>\n  <li>\n    <p><strong>SLA<\/strong> \u2013 No where on their site could I find any SLA promises (as of April 2016). They have been running for over a year now, and there are noticeable outages, usually a couple of times a month. Unless you run a hobby project or small enough business to not care, this might a real problem. I do not think this would affect their large enterprise client though who probably have enough negotiation power to get an SLA in place together with a private\/dedicated instance. Saying that, I still use it for my random pet projects and NodeRed on Bluemix is simply awesome!<\/p>\n  <\/li>\n<\/ul>\n","pubDate":"Sat, 30 Apr 2016 08:21:49 +0000","link":"http:\/\/www.clianz.com\/2016\/04\/30\/things-you-should-know-before-choosing-bluemix-3-pros-and-cons\/","guid":"http:\/\/www.clianz.com\/2016\/04\/30\/things-you-should-know-before-choosing-bluemix-3-pros-and-cons\/","category":["Bluemix","Cloud"]},{"title":"Magnet Pattern in Scala","description":"<p>Continuing from the previous post on Scala\u2019s Cake Pattern, here is a quick explaination of the Magnet pattern.<\/p>\n\n<h2 id=\"magnet-pattern\">Magnet Pattern<\/h2>\n<p>You are probably familiar with method overloading (ie. multiple method with the same name, but different parameter). This is very popular in Java, but is still not available in some modern languages like GoLang because designer to argue it clutters up the language.\n<!--more--><\/p>\n\n<p>What do you do if you want a method that do different things with different parameter without overloading method? Simple answer is to pass in a single \u2018object\u2019 that encapsulate all the parameters and optional stuff you want. This is the Magnet pattern in a nutshell.<\/p>\n\n<h3 id=\"the-implicit-magnet\">The Implicit Magnet<\/h3>\n\n<p>One of the nice features of Scala is \u2018implicit\u2019 method. Here you can define a method with \u2018implicit\u2019 tag, and when you didn\u2019t call a method with the exact signature, the compiler will auto-magically find the best matching method to use to fill in the missing gap (implicitly).<\/p>\n\n<h3 id=\"scala-magnet-pattern-example\">Scala Magnet Pattern Example<\/h3>\n\n<p>(<a href=\"https:\/\/github.com\/icha024\/HelloScala\/blob\/master2\/HelloScala\/src\/main\/scala\/com\/github\/icha024\/MyMagnetChecker.scala\" target=\"_blank\">github<\/a>)<\/p>\n\n<p>Here is a little demo program to show this Magnet pattern.<\/p>\n\n<p>Notice how MyMagnet is declared \u2013 I did not provide any \u2018String\u2019 or \u2018Int\u2019 type constructor. Scala is smart enough to find the matching implicit method for \u2018String\u2019 and \u2018Int\u2019 in my object and still construct it properly.<\/p>\n\n<div class=\"language-scala highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"k\">package<\/span> <span class=\"nn\">com.example<\/span>\n\n<span class=\"k\">object<\/span> <span class=\"nc\">MyMagnetChecker<\/span> <span class=\"k\">extends<\/span> <span class=\"nc\">App<\/span> <span class=\"o\">{<\/span>\n  <span class=\"k\">trait<\/span> <span class=\"nc\">MyMagnet<\/span> <span class=\"o\">{<\/span> <span class=\"c1\">\/\/ should probably be sealed\n<\/span>    <span class=\"k\">type<\/span> <span class=\"kt\">Result<\/span>\n    <span class=\"k\">def<\/span> <span class=\"nf\">getRes<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span>\n    <span class=\"k\">def<\/span> <span class=\"nf\">apply<\/span><span class=\"o\">()<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">object<\/span> <span class=\"nc\">MyMagnet<\/span> <span class=\"o\">{<\/span>\n    <span class=\"k\">implicit<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">convertFromInt<\/span><span class=\"o\">(<\/span><span class=\"n\">myVal<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Int<\/span><span class=\"o\">)<\/span> <span class=\"k\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">MyMagnet<\/span> <span class=\"o\">{<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">type<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"nc\">Int<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">apply<\/span><span class=\"o\">()<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"n\">myVal<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">getRes<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"n\">myVal<\/span>\n    <span class=\"o\">}<\/span>\n\n    <span class=\"k\">implicit<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">convertFromString<\/span><span class=\"o\">(<\/span><span class=\"n\">myVal<\/span><span class=\"k\">:<\/span> <span class=\"kt\">String<\/span><span class=\"o\">)<\/span> <span class=\"k\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">MyMagnet<\/span> <span class=\"o\">{<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">type<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"nc\">String<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">apply<\/span><span class=\"o\">()<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"Type is a String: \"<\/span> <span class=\"o\">+<\/span> <span class=\"n\">myVal<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">getRes<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"String type: \"<\/span> <span class=\"o\">+<\/span> <span class=\"n\">myVal<\/span>\n    <span class=\"o\">}<\/span>\n\n    <span class=\"k\">implicit<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">convertFromTwoString<\/span><span class=\"o\">(<\/span><span class=\"n\">myTuple<\/span><span class=\"k\">:<\/span> <span class=\"o\">(<\/span><span class=\"kt\">String<\/span><span class=\"o\">,<\/span> <span class=\"kt\">String<\/span><span class=\"o\">))<\/span> <span class=\"k\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">MyMagnet<\/span> <span class=\"o\">{<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">type<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"nc\">String<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">apply<\/span><span class=\"o\">()<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"Type is a String type 2: \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">myTuple<\/span><span class=\"o\">.<\/span><span class=\"py\">_1<\/span> <span class=\"o\">+<\/span> <span class=\"s\">\", \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">myTuple<\/span><span class=\"o\">.<\/span><span class=\"py\">_2<\/span>\n      <span class=\"k\">override<\/span> <span class=\"k\">def<\/span> <span class=\"nf\">getRes<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Result<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"String2 type: \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">myTuple<\/span><span class=\"o\">.<\/span><span class=\"py\">_1<\/span> <span class=\"o\">+<\/span> <span class=\"s\">\", \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">myTuple<\/span><span class=\"o\">.<\/span><span class=\"py\">_2<\/span>\n    <span class=\"o\">}<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">def<\/span> <span class=\"nf\">findStickyType<\/span><span class=\"o\">(<\/span><span class=\"n\">mag<\/span><span class=\"k\">:<\/span> <span class=\"kt\">MyMagnet<\/span><span class=\"o\">)<\/span><span class=\"k\">:<\/span> <span class=\"kt\">Unit<\/span> <span class=\"o\">=<\/span> <span class=\"o\">{<\/span>\n    <span class=\"nf\">println<\/span><span class=\"o\">(<\/span><span class=\"s\">\"Finding magnet of some type... \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">mag<\/span><span class=\"o\">.<\/span><span class=\"py\">getRes<\/span><span class=\"o\">)<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"nf\">findStickyType<\/span><span class=\"o\">(<\/span><span class=\"s\">\"abc\"<\/span><span class=\"o\">);<\/span> <span class=\"c1\">\/\/ create 'MyMagnet' with String constructor\n<\/span>  <span class=\"nf\">findStickyType<\/span><span class=\"o\">(<\/span><span class=\"mi\">123<\/span><span class=\"o\">);<\/span>   <span class=\"c1\">\/\/ create 'MyMagnet' with Int constructor\n<\/span>  <span class=\"nf\">findStickyType<\/span><span class=\"o\">(<\/span><span class=\"s\">\"xyz\"<\/span><span class=\"o\">,<\/span><span class=\"s\">\"ijk\"<\/span><span class=\"o\">);<\/span>   <span class=\"c1\">\/\/ create 'MyMagnet' with (String, String) tuple constructor\n<\/span>\n  <span class=\"c1\">\/\/ Magnet pattern = Instead of method overloading, we use one big pojo with variable amount of fields.\n<\/span>  <span class=\"c1\">\/\/ Then instead of messy if\/else checks on each field of the big pojo to run different init, we use 'implicit' method feature of Scala.\n<\/span><span class=\"o\">}<\/span>\n<\/code><\/pre><\/div><\/div>\n","pubDate":"Tue, 26 Apr 2016 08:46:21 +0000","link":"http:\/\/www.clianz.com\/2016\/04\/26\/scala-magnet-pattern\/","guid":"http:\/\/www.clianz.com\/2016\/04\/26\/scala-magnet-pattern\/","category":["Cake pattern","Magnet pattern","Scala","Scala"]},{"title":"Cake Pattern in Scala","description":"<p>Last week I <a href=\"https:\/\/github.com\/icha024\/HelloScala\/tree\/master2\/HelloScala\/src\/main\/scala\/com\/github\/icha024\" target=\"_blank\">started looking into Scala<\/a>, it\u2019s one of those things that has been on my to-do list for a very long time and but never got to it until now. Looking back, I should have bumped it up the list a long time ago.\n<!--more--><\/p>\n\n<p>A couple of interesting patterns I\u2019ve came across was the Cake and the Magnet pattern. I usually find it useful to relate new things to my old understanding in other technology stack, and being primarily a Java developer, here is a my short explanation with Java.<\/p>\n\n<h2 id=\"cake-pattern-explained\">Cake Pattern Explained<\/h2>\n\n<p>This \u2018Cake Pattern\u2019 is a random name (IMO) of what Java developer normally called \u2018best practice dependency injection (DI)\u2019 with Spring. Many of you here have probably been doing this for a very long time already in the Java\/Spring world. Basically it means \u2018one should only inject via interface, not concrete class\u2019.<\/p>\n\n<h3 id=\"dependency-injection\">Dependency injection<\/h3>\n\n<p>Imagine if I have a service that needs to do some data operation, normally we\u2019d create a \u2018Service\u2019 class with a \u2018DAO\u2019 member \u2013 where \u2018DAO\u2019 is an interface. At runtime, we\u2019d inject what DAO implementation we want, eg. SqlDao or CloudantDao for example.<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>MyService \u2013(uses)\u2013&gt; GenericDAO interface**\n<\/code><\/pre><\/div><\/div>\n\n<p>Here in Scala a \u2018trait\u2019 act like a plain old Java interface or contain implementation (like Java 8 \u2018default\u2019 method on interface), so we use it to declare both interface and implementation:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>SqlDao \u2013(implements)\u2013&gt; GenericDAO interface\n\nCloudantDao \u2013(implements)\u2013&gt; GenericDAO interface\n<\/code><\/pre><\/div><\/div>\n\n<p>Then at when you need to run the code, just inject whichever implementation you want into the service<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>MyService \u2013(uses)\u2013&gt; GenericDAO interface (with SqlDao implementation injected) \n<\/code><\/pre><\/div><\/div>\n\n<p><em>or<\/em><\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>MyService \u2013(uses)\u2013&gt; GenericDAO interface (with CloudantDao implementation injected) \n<\/code><\/pre><\/div><\/div>\n\n<h3 id=\"scala-cake-pattern-example\">Scala Cake Pattern Example<\/h3>\n\n<p>(<a href=\"https:\/\/github.com\/icha024\/HelloScala\/blob\/master2\/HelloScala\/src\/main\/scala\/com\/github\/icha024\/MyCake.scala\" target=\"_blank\">github<\/a>)<\/p>\n\n<p>Here is a little demo program to show this DI concept.<\/p>\n\n<div class=\"language-scala highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"k\">package<\/span> <span class=\"nn\">com.example<\/span>\n\n<span class=\"k\">object<\/span> <span class=\"nc\">MyCake<\/span> <span class=\"k\">extends<\/span> <span class=\"nc\">App<\/span> <span class=\"o\">{<\/span>\n\n  <span class=\"c1\">\/\/ This is an 'interface'\n<\/span>  <span class=\"k\">trait<\/span> <span class=\"nc\">GenericDao<\/span> <span class=\"o\">{<\/span>\n    <span class=\"k\">def<\/span> <span class=\"nf\">Imp<\/span><span class=\"k\">:<\/span> <span class=\"kt\">String<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"c1\">\/\/ This is like implementing interface with default in Java8 (An implementation)\n<\/span>  <span class=\"k\">trait<\/span> <span class=\"nc\">SqlDao<\/span> <span class=\"k\">extends<\/span> <span class=\"nc\">GenericDao<\/span> <span class=\"o\">{<\/span> \n    <span class=\"k\">def<\/span> <span class=\"nf\">Imp<\/span><span class=\"k\">:<\/span> <span class=\"kt\">String<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"SQL Implementation\"<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"c1\">\/\/ This is like implementing interface with default in Java8 (An implementation)\n<\/span>  <span class=\"k\">trait<\/span> <span class=\"nc\">CloudantDao<\/span> <span class=\"k\">extends<\/span> <span class=\"nc\">GenericDao<\/span> <span class=\"o\">{<\/span>\n\n    <span class=\"k\">def<\/span> <span class=\"nf\">Imp<\/span><span class=\"k\">:<\/span> <span class=\"kt\">String<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"Cloudant Implementation\"<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">trait<\/span> <span class=\"nc\">MyServiceTrait<\/span> <span class=\"o\">{<\/span>\n    <span class=\"c1\">\/\/ This relies on 'interface' instead of 'implementation' - it just normal Java\/Spring best practice anyway.\n<\/span>    <span class=\"n\">dao<\/span><span class=\"k\">:<\/span> <span class=\"kt\">GenericDao<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"c1\">\/\/ Syntax for trait 'self type annotation', we really should just call it 'extending an interface'\n<\/span>    <span class=\"nf\">println<\/span><span class=\"o\">(<\/span><span class=\"s\">\"My implementation is: \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">dao<\/span><span class=\"o\">.<\/span><span class=\"py\">Imp<\/span><span class=\"o\">)<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">val<\/span> <span class=\"nv\">svc<\/span> <span class=\"k\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">MyServiceTrait<\/span> <span class=\"k\">with<\/span> <span class=\"nc\">CloudantDao<\/span>  <span class=\"c1\">\/\/ DI with Cloudant Impl\n<\/span>  <span class=\"nf\">println<\/span><span class=\"o\">(<\/span><span class=\"s\">\"svc using Cloudant DI returns: \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">svc<\/span><span class=\"o\">.<\/span><span class=\"py\">Imp<\/span><span class=\"o\">)<\/span>\n\n  <span class=\"k\">val<\/span> <span class=\"nv\">svc2<\/span> <span class=\"k\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">MyServiceTrait<\/span> <span class=\"k\">with<\/span> <span class=\"nc\">SqlDao<\/span>  <span class=\"c1\">\/\/ DI with SQL Impl\n<\/span>  <span class=\"nf\">println<\/span><span class=\"o\">(<\/span><span class=\"s\">\"svc2 using SQL DI returns: \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">svc2<\/span><span class=\"o\">.<\/span><span class=\"py\">Imp<\/span><span class=\"o\">)<\/span>\n\n<span class=\"o\">}<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p><strong><em>Update:<\/em> But wait \u2013 self type annotation is more like \u2018inheritance\u2019 than \u2018composition\u2019<\/strong><\/p>\n\n<p>After having a chat with a colleague \u2013 notice in the example above there is:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>dao: GenericDao =&gt; \n<\/code><\/pre><\/div><\/div>\n\n<p>In Java\/Spring, DI is usually composition \u2013 but here we are doing DI via traits and the self type annotation is more like inheriting. Normally, in most example I saw, it\u2019s named \u2018this\u2019 instead of \u2018dao\u2019 \u2013 I guess that make more sense if we are inheriting (injecting) multiple traits. See the updated example below multiple traits:<\/p>\n\n<div class=\"language-scala highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"k\">package<\/span> <span class=\"nn\">com.example<\/span>\n\n<span class=\"k\">object<\/span> <span class=\"nc\">MyCake<\/span> <span class=\"k\">extends<\/span> <span class=\"nc\">App<\/span> <span class=\"o\">{<\/span>\n\n  <span class=\"c1\">\/\/ shared\n<\/span>\n  <span class=\"k\">trait<\/span> <span class=\"nc\">AnotherTrait<\/span> <span class=\"o\">{<\/span>\n    <span class=\"c1\">\/\/ Some method\n<\/span>  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">trait<\/span> <span class=\"nc\">GenericDao<\/span> <span class=\"o\">{<\/span> <span class=\"c1\">\/\/ This is an 'interface'\n<\/span>    <span class=\"k\">def<\/span> <span class=\"nf\">Imp<\/span><span class=\"k\">:<\/span> <span class=\"kt\">String<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">trait<\/span> <span class=\"nc\">SqlDao<\/span> <span class=\"k\">extends<\/span> <span class=\"nc\">GenericDao<\/span> <span class=\"o\">{<\/span> <span class=\"c1\">\/\/ This is like implementing interface with default in Java8 (An implementation)\n<\/span>    <span class=\"k\">def<\/span> <span class=\"nf\">Imp<\/span><span class=\"k\">:<\/span> <span class=\"kt\">String<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"SQL Implementation\"<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">trait<\/span> <span class=\"nc\">CloudantDao<\/span> <span class=\"k\">extends<\/span> <span class=\"nc\">GenericDao<\/span> <span class=\"o\">{<\/span> <span class=\"c1\">\/\/ This is like implementing interface with default in Java8 (An implementation)\n<\/span>    <span class=\"k\">def<\/span> <span class=\"nf\">Imp<\/span><span class=\"k\">:<\/span> <span class=\"kt\">String<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"Cloudant Implementation\"<\/span>\n  <span class=\"o\">}<\/span>\n\n  <span class=\"k\">trait<\/span> <span class=\"nc\">MyServiceTrait<\/span> <span class=\"o\">{<\/span>\n    <span class=\"c1\">\/\/ This relies on 'interface' instead of 'implementation' - it just normal Java\/Spring best practice anyway.\n<\/span>    <span class=\"k\">this:<\/span> <span class=\"kt\">GenericDao<\/span> <span class=\"kt\">with<\/span> <span class=\"kt\">AnotherTrait<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"c1\">\/\/ Syntax for trait 'self type annotation', we really should just call it 'extending an interface'\n<\/span>    <span class=\"nf\">println<\/span><span class=\"o\">(<\/span><span class=\"s\">\"My implementation is: \"<\/span> <span class=\"o\">+<\/span> <span class=\"k\">this<\/span><span class=\"o\">.<\/span><span class=\"py\">Imp<\/span><span class=\"o\">)<\/span>\n  <span class=\"o\">}<\/span>\n\n\n  <span class=\"c1\">\/\/ service customisation (inject stuff here)\n<\/span>\n  <span class=\"k\">val<\/span> <span class=\"nv\">svc<\/span> <span class=\"k\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">MyServiceTrait<\/span> <span class=\"k\">with<\/span> <span class=\"nc\">CloudantDao<\/span> <span class=\"k\">with<\/span> <span class=\"nc\">AnotherTrait<\/span>\n  <span class=\"nf\">println<\/span><span class=\"o\">(<\/span><span class=\"s\">\"svc using Cloudant DI returns: \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">svc<\/span><span class=\"o\">.<\/span><span class=\"py\">Imp<\/span><span class=\"o\">)<\/span>\n\n  <span class=\"k\">val<\/span> <span class=\"nv\">svc2<\/span> <span class=\"k\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">MyServiceTrait<\/span> <span class=\"k\">with<\/span> <span class=\"nc\">SqlDao<\/span> <span class=\"k\">with<\/span> <span class=\"nc\">AnotherTrait<\/span>\n  <span class=\"nf\">println<\/span><span class=\"o\">(<\/span><span class=\"s\">\"svc2 using SQL DI returns: \"<\/span> <span class=\"o\">+<\/span> <span class=\"nv\">svc2<\/span><span class=\"o\">.<\/span><span class=\"py\">Imp<\/span><span class=\"o\">)<\/span>\n\n<span class=\"o\">}<\/span>\n<\/code><\/pre><\/div><\/div>\n","pubDate":"Tue, 26 Apr 2016 08:46:20 +0000","link":"http:\/\/www.clianz.com\/2016\/04\/26\/scala-cake-pattern\/","guid":"http:\/\/www.clianz.com\/2016\/04\/26\/scala-cake-pattern\/","category":["Cake pattern","Magnet pattern","Scala","Scala"]},{"title":"Configuring Spring MVC Async Threads","description":"<h2 id=\"spring-mvc-aync-is-awesome\">Spring MVC Aync is Awesome!<\/h2>\n\n<p>The thing I love most about Spring web framework is the abundance of features and flexibility. The \u2018callable\u2019 async web request handler that came with <a href=\"https:\/\/spring.io\/blog\/2012\/05\/10\/spring-mvc-3-2-preview-making-a-controller-method-asynchronous\/\" target=\"_blank\">Spring MVC 3.2<\/a> is one of them. Basically we can return a \u2018callable\u2019 wrapping the type you\u2019d normally use \u2013 and it\u2019ll auto-magically turn it into an async web call.\n<!--more--><\/p>\n\n<p>Here is an example of it (Spring Boot + Java 8), this just echoes the request in the response:<\/p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nd\">@RequestMapping<\/span><span class=\"o\">(<\/span><span class=\"n\">value<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"\/echo\"<\/span><span class=\"o\">)<\/span>\n<span class=\"kd\">public<\/span> <span class=\"nc\">Callable<\/span><span class=\"o\">&lt;<\/span><span class=\"nc\">ResponseEntity<\/span><span class=\"o\">&lt;<\/span><span class=\"nc\">String<\/span><span class=\"o\">&gt;&gt;<\/span> <span class=\"nf\">echo<\/span><span class=\"o\">(<\/span><span class=\"nd\">@RequestParam<\/span><span class=\"o\">(<\/span><span class=\"n\">value<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"message\"<\/span><span class=\"o\">,<\/span> <span class=\"n\">required<\/span> <span class=\"o\">=<\/span> <span class=\"kc\">true<\/span><span class=\"o\">)<\/span> <span class=\"nc\">String<\/span> <span class=\"n\">message<\/span><span class=\"o\">)<\/span> <span class=\"o\">{<\/span>\n\t<span class=\"k\">return<\/span> <span class=\"o\">()<\/span> <span class=\"o\">-&gt;<\/span> <span class=\"o\">{<\/span>\n\t\t<span class=\"k\">return<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">ResponseEntity<\/span><span class=\"o\">&lt;&gt;(<\/span><span class=\"n\">message<\/span><span class=\"o\">,<\/span> <span class=\"nc\">HttpStatus<\/span><span class=\"o\">.<\/span><span class=\"na\">OK<\/span><span class=\"o\">);<\/span>\n\t<span class=\"o\">};<\/span>\n<span class=\"o\">}<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>Now if you deploy this locally, then <a href=\"http:\/\/localhost:8080\/echo?message=auckland\">http:\/\/localhost:8080\/echo?message=auckland<\/a> will echo your request in the response \u2013 all done asynchronously on the server.<\/p>\n\n<h3 id=\"but-its-not-quite-plug--play\">But it\u2019s not quite plug &amp; play\u2026<\/h3>\n\n<p>One of the things to watch out for is that the default thread executor should be replaced for production. However, I could not find any good example of this easily. After digging around the code for a while, here is an example of how to configure the async task executor.<\/p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"cm\">\/**\n\t* Configs for MVC\/REST services with 'Callable' return types - they spawn background threads, and this configures it.\n\t*\/<\/span>\n<span class=\"nd\">@Configuration<\/span>\n<span class=\"nd\">@ConfigurationProperties<\/span><span class=\"o\">(<\/span><span class=\"n\">prefix<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"web.executor\"<\/span><span class=\"o\">)<\/span>\n<span class=\"kd\">public<\/span> <span class=\"kd\">class<\/span> <span class=\"nc\">CallableConfig<\/span> <span class=\"o\">{<\/span>\n\n\t<span class=\"kd\">public<\/span> <span class=\"kd\">static<\/span> <span class=\"kd\">final<\/span> <span class=\"kt\">int<\/span> <span class=\"no\">DEFAULT_POOL_SIZE<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">2<\/span><span class=\"o\">;<\/span>\n\t<span class=\"kd\">public<\/span> <span class=\"kd\">static<\/span> <span class=\"kd\">final<\/span> <span class=\"kt\">int<\/span> <span class=\"no\">DEFAULT_QUEUE_SIZE<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">2<\/span><span class=\"o\">;<\/span>\n\n\t<span class=\"kd\">private<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">minPoolSize<\/span> <span class=\"o\">=<\/span> <span class=\"no\">DEFAULT_POOL_SIZE<\/span><span class=\"o\">;<\/span>\n\t<span class=\"kd\">private<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">maxPoolSize<\/span> <span class=\"o\">=<\/span> <span class=\"no\">DEFAULT_POOL_SIZE<\/span><span class=\"o\">;<\/span>\n\t<span class=\"kd\">private<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">maxQueueSize<\/span> <span class=\"o\">=<\/span> <span class=\"no\">DEFAULT_QUEUE_SIZE<\/span><span class=\"o\">;<\/span>\n\n\t<span class=\"nd\">@Bean<\/span>\n\t<span class=\"kd\">public<\/span> <span class=\"nc\">AsyncTaskExecutor<\/span> <span class=\"nf\">asyncTaskExecutor<\/span><span class=\"o\">()<\/span> <span class=\"o\">{<\/span>\n\t\t<span class=\"kd\">final<\/span> <span class=\"nc\">ThreadPoolTaskExecutor<\/span> <span class=\"n\">executor<\/span> <span class=\"o\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">ThreadPoolTaskExecutor<\/span><span class=\"o\">();<\/span>\n\t\t<span class=\"n\">executor<\/span><span class=\"o\">.<\/span><span class=\"na\">setCorePoolSize<\/span><span class=\"o\">(<\/span><span class=\"no\">DEFAULT_POOL_SIZE<\/span><span class=\"o\">);<\/span>\n\t\t<span class=\"n\">executor<\/span><span class=\"o\">.<\/span><span class=\"na\">setMaxPoolSize<\/span><span class=\"o\">(<\/span><span class=\"no\">DEFAULT_POOL_SIZE<\/span><span class=\"o\">);<\/span>\n\t\t<span class=\"n\">executor<\/span><span class=\"o\">.<\/span><span class=\"na\">setQueueCapacity<\/span><span class=\"o\">(<\/span><span class=\"no\">DEFAULT_QUEUE_SIZE<\/span><span class=\"o\">);<\/span>\n\t\t<span class=\"n\">executor<\/span><span class=\"o\">.<\/span><span class=\"na\">setRejectedExecutionHandler<\/span><span class=\"o\">(<\/span><span class=\"k\">new<\/span> <span class=\"nc\">ThreadPoolExecutor<\/span><span class=\"o\">.<\/span><span class=\"na\">AbortPolicy<\/span><span class=\"o\">());<\/span>\n\t\t<span class=\"n\">executor<\/span><span class=\"o\">.<\/span><span class=\"na\">setWaitForTasksToCompleteOnShutdown<\/span><span class=\"o\">(<\/span><span class=\"kc\">true<\/span><span class=\"o\">);<\/span>\n\t\t<span class=\"k\">return<\/span> <span class=\"n\">executor<\/span><span class=\"o\">;<\/span>\n\t<span class=\"o\">}<\/span>\n\n\t<span class=\"nd\">@Bean<\/span>\n\t<span class=\"kd\">public<\/span> <span class=\"nc\">WebMvcConfigurerAdapter<\/span> <span class=\"nf\">webMvcConfigurerAdapter<\/span><span class=\"o\">(<\/span><span class=\"nc\">AsyncTaskExecutor<\/span> <span class=\"n\">asyncTaskExecutor<\/span><span class=\"o\">)<\/span> <span class=\"o\">{<\/span>\n\t\t<span class=\"k\">return<\/span> <span class=\"k\">new<\/span> <span class=\"nf\">WebMvcConfigurerAdapter<\/span><span class=\"o\">()<\/span> <span class=\"o\">{<\/span>\n\t\t\t<span class=\"nd\">@Override<\/span>\n\t\t\t<span class=\"kd\">public<\/span> <span class=\"kt\">void<\/span> <span class=\"nf\">configureAsyncSupport<\/span><span class=\"o\">(<\/span><span class=\"nc\">AsyncSupportConfigurer<\/span> <span class=\"n\">configurer<\/span><span class=\"o\">)<\/span> <span class=\"o\">{<\/span>\n\t\t\t\t<span class=\"n\">configurer<\/span><span class=\"o\">.<\/span><span class=\"na\">setTaskExecutor<\/span><span class=\"o\">(<\/span><span class=\"n\">asyncTaskExecutor<\/span><span class=\"o\">);<\/span>\n\t\t\t\t<span class=\"kd\">super<\/span><span class=\"o\">.<\/span><span class=\"na\">configureAsyncSupport<\/span><span class=\"o\">(<\/span><span class=\"n\">configurer<\/span><span class=\"o\">);<\/span>\n\t\t\t<span class=\"o\">}<\/span>\n\t\t<span class=\"o\">};<\/span>\n\t<span class=\"o\">}<\/span>\n<span class=\"o\">}<\/span>    \n<\/code><\/pre><\/div><\/div>\n\n<h3 id=\"exposing-configurations\">Exposing Configurations<\/h3>\n\n<p>The @ConfigurationProperties tag exposes the configuration if you are using Spring Boot. This handy option let you configure it in your application.properties to override the defaults, for example:<\/p>\n\n<div class=\"language-properties highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"py\">web.executor.minPoolSize<\/span><span class=\"p\">=<\/span><span class=\"s\">10<\/span>\n<span class=\"py\">web.executor.maxPoolSize<\/span><span class=\"p\">=<\/span><span class=\"s\">10<\/span>\n<span class=\"py\">web.executor.maxQueueSize<\/span><span class=\"p\">=<\/span><span class=\"s\">20<\/span>\n<\/code><\/pre><\/div><\/div>\n","pubDate":"Wed, 24 Feb 2016 14:20:52 +0000","link":"http:\/\/www.clianz.com\/2016\/02\/24\/configuring-spring-mvc-async-threads\/","guid":"http:\/\/www.clianz.com\/2016\/02\/24\/configuring-spring-mvc-async-threads\/","category":["async","AsyncTaskExecutor","callable","configuration","Spring MVC","thread","Java","Spring","Spring-boot"]},{"title":"Cloudant Spring Boot Auto-Configuration","description":"<p>With this starter for SpringBoot, using Cloudant and CouchDB couldn\u2019t be easier!<\/p>\n\n<p>The Github project for Spring Boot auto-configuration binding for Cloudant is available at\n<a href=\"https:\/\/github.com\/icha024\/cloudant-spring-boot-starter\">https:\/\/github.com\/icha024\/cloudant-spring-boot-starter<\/a>\n<!--more--><\/p>\n\n<h2 id=\"injecting-cloudant\">Injecting Cloudant<\/h2>\n<p>Just inject the cloudant DB into your code:<\/p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nd\">@Bean<\/span>\n<span class=\"kd\">public<\/span> <span class=\"nc\">Database<\/span> <span class=\"nf\">mydb<\/span><span class=\"o\">(<\/span><span class=\"nc\">CloudantClient<\/span> <span class=\"n\">cloudant<\/span><span class=\"o\">)<\/span> <span class=\"o\">{<\/span>\n  <span class=\"k\">return<\/span> <span class=\"n\">cloudant<\/span><span class=\"o\">.<\/span><span class=\"na\">database<\/span><span class=\"o\">(<\/span><span class=\"s\">\"mydb\"<\/span><span class=\"o\">,<\/span> <span class=\"kc\">true<\/span><span class=\"o\">);<\/span>\n<span class=\"o\">}<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>Then start using it:<\/p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nd\">@Autowired<\/span>\n<span class=\"nc\">Database<\/span> <span class=\"n\">mydb<\/span>\n\n<span class=\"n\">mydb<\/span><span class=\"o\">.<\/span><span class=\"na\">save<\/span><span class=\"o\">(<\/span><span class=\"n\">data<\/span><span class=\"o\">);<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h1 id=\"installing-with-maven\">Installing with Maven<\/h1>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nt\">&lt;dependency&gt;<\/span>\n  <span class=\"nt\">&lt;groupId&gt;<\/span>com.clianz<span class=\"nt\">&lt;\/groupId&gt;<\/span>\n  <span class=\"nt\">&lt;artifactId&gt;<\/span>cloudant-spring-boot-starter<span class=\"nt\">&lt;\/artifactId&gt;<\/span>\n  <span class=\"nt\">&lt;version&gt;<\/span>0.9.0<span class=\"nt\">&lt;\/version&gt;<\/span>\n<span class=\"nt\">&lt;\/dependency&gt;<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h2 id=\"spring-boot-configuration\">Spring Boot Configuration<\/h2>\n\n<p>Configurations can be placed in the application.properties (or yml, or json) as usual. The username and password is mandatory.<\/p>\n\n<div class=\"language-properties highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"c\">##### Mandatory configs #####\n<\/span><span class=\"py\">cloudant.username<\/span><span class=\"p\">=<\/span><span class=\"s\">myUserName     #Username as assigned by Cloudant.<\/span>\n<span class=\"py\">cloudant.password<\/span><span class=\"p\">=<\/span><span class=\"s\">myPasswd       #Password as assigned by Cloudant.<\/span>\n\n<span class=\"c\">##### Optional configs #####\n<\/span><span class=\"py\">cloudant.account<\/span><span class=\"p\">=<\/span><span class=\"s\">myAccountName   #Defaults to username if left blank.<\/span>\n<span class=\"py\">cloudant.url<\/span><span class=\"p\">=<\/span><span class=\"s\">...                 #Defaults to official server.<\/span>\n<span class=\"py\">cloudant.proxyURL<\/span><span class=\"p\">=<\/span><span class=\"s\">...            #URL to proxy server<\/span>\n<span class=\"py\">cloudant.proxyUser<\/span><span class=\"p\">=<\/span><span class=\"s\">myUserName    #Proxy username<\/span>\n<span class=\"py\">cloudant.proxyPassword<\/span><span class=\"p\">=<\/span><span class=\"s\">myPasswd  #Proxy password.<\/span>\n<span class=\"py\">cloudant.connectTimeout<\/span><span class=\"p\">=<\/span><span class=\"s\">300      #Connect timeout in seconds. Default to 300 seconds (5 minutes).<\/span>\n<span class=\"py\">cloudant.readTimeout<\/span><span class=\"p\">=<\/span><span class=\"s\">300         #Read timeout in seconds. Default to 300 seconds (5 minutes).<\/span>\n<span class=\"py\">cloudant.maxConnections<\/span><span class=\"p\">=<\/span><span class=\"s\">6        #Default to 6.<\/span>\n<span class=\"py\">cloudant.disableSSLAuthentication<\/span><span class=\"p\">=<\/span><span class=\"s\">false   #Defaults to false.<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h2 id=\"bluemix-cloudfoundry-configuration\">Bluemix (CloudFoundry) Configuration<\/h2>\n\n<p>When using Bluemix (CloudFoundry), the client will <strong>automatically<\/strong> use the Cloudant service binded to the app instead of the Spring configuration.<\/p>\n\n<p>Bluemix\u2019s VCAP_SERVICES environment variable containing a Cloudant service will always take precedence over any Spring configuration. This is useful \u2013 Local development will use the Spring configuration properties, and promoting it to Bluemix will automatically use the environment configured instance. If Spring\u2019s configuration is desired, just remove the Cloudant service binding from your Bluemix app.<\/p>\n","pubDate":"Mon, 25 Jan 2016 12:50:20 +0000","link":"http:\/\/www.clianz.com\/2016\/01\/25\/cloudant-config\/","guid":"http:\/\/www.clianz.com\/2016\/01\/25\/cloudant-config\/","category":["auto-configuration","bigdata","Bluemix","cloudant","configuration","java","open-source","parser","spring-boot","spring-boot-starter","springboot","Bluemix","Cloud","Cloudant","Java","Spring","Spring-boot"]},{"title":"Bluemix Config Parser (Java)","description":"<p>When using Bluemix (CloudFoundry), services configuration are read by parsing the JSON from VCAP_SERVICES environment variable. This is a handy util library for parsing Bluemix VCAP_SERVICES configurations JSON. Common configs classess are provided so it\u2019ll even work with auto-completion on your favorite IDE. No more messy JSON config parsing!\n<!--more--><\/p>\n\n<h2 id=\"usage-example\">Usage example<\/h2>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nc\">BluemixConfigStore<\/span><span class=\"o\">.<\/span><span class=\"na\">getConfig<\/span><span class=\"o\">().<\/span><span class=\"na\">getCloudantNoSQLDB<\/span><span class=\"o\">().<\/span><span class=\"na\">getCredentials<\/span><span class=\"o\">().<\/span><span class=\"na\">getPassword<\/span><span class=\"o\">();<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h2 id=\"installing-with-maven\">Installing with Maven<\/h2>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nt\">&lt;dependency&gt;<\/span>\n  <span class=\"nt\">&lt;groupId&gt;<\/span>com.clianz<span class=\"nt\">&lt;\/groupId&gt;<\/span>\n  <span class=\"nt\">&lt;artifactId&gt;<\/span>bluemix-config-parser<span class=\"nt\">&lt;\/artifactId&gt;<\/span>\n  <span class=\"nt\">&lt;version&gt;<\/span>0.0.5<span class=\"nt\">&lt;\/version&gt;<\/span>\n<span class=\"nt\">&lt;\/dependency&gt;<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h2 id=\"configurations-supported\">Configurations supported<\/h2>\n\n<p>Most of the common services on Bluemix are currently supported:<\/p>\n\n<ul>\n  <li>Business rules<\/li>\n  <li>Clear DB<\/li>\n  <li>Cloud AMQP (RabbitMQ)<\/li>\n  <li>Cloudant<\/li>\n  <li>Concept Expansion<\/li>\n  <li>Concept Insight<\/li>\n  <li>Dash DB<\/li>\n  <li>Data Cache<\/li>\n  <li>Document Conversion<\/li>\n  <li>Geospartial Analytics<\/li>\n  <li>IMF Push<\/li>\n  <li>Monitoring and Analytics<\/li>\n  <li>MQ Light<\/li>\n  <li>Relationship Extraction<\/li>\n  <li>Rank and Retrieve<\/li>\n  <li>Sesson Cache<\/li>\n  <li>SQL DB (DB2)<\/li>\n  <li>Trade-off Analytics<\/li>\n  <li>Twitter Insights<\/li>\n  <li>Weather Insights<\/li>\n  <li>Workflow<\/li>\n  <li>Workload Scheduler<\/li>\n  <li>Twilio<\/li>\n  <li>Elastic Search by Compose<\/li>\n  <li>Mongo DB by Compose<\/li>\n  <li>PostgreSQL by Compose<\/li>\n  <li>Redis by Compose<\/li>\n<\/ul>\n\n<p>Add more bindings to other services if you need, let\u2019s do this once and for all for everyone.<\/p>\n\n<h2 id=\"local-development-deployment\">Local development deployment<\/h2>\n\n<p>For local development, there are two common ways to setup environment:<\/p>\n\n<ul>\n  <li>\n    <p>Set VCAP_SERVICES JSON config for your dev space as an environment variable.<\/p>\n  <\/li>\n  <li>\n    <p>Or, start your app with a JVM variable pointing to a file containing your dev config, eg.<\/p>\n  <\/li>\n<\/ul>\n\n<div class=\"language-properties highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"py\">-DVCAP_SERVICES_FILENAME<\/span><span class=\"p\">=<\/span><span class=\"s\">myDevConfig.json<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h2 id=\"contributing\">Contributing<\/h2>\n\n<p>Pull requests are welcome.<\/p>\n\n<p>Project page: <a href=\"https:\/\/github.com\/icha024\/bluemix-config-parser\/\">https:\/\/github.com\/icha024\/bluemix-config-parser\/<\/a><\/p>\n\n<p>Just fork this project, follow the pattern to add bindings\/tests, then raise a pull request.<\/p>\n","pubDate":"Fri, 15 Jan 2016 22:55:48 +0000","link":"http:\/\/www.clianz.com\/2016\/01\/15\/bluemix-config-parser-2\/","guid":"http:\/\/www.clianz.com\/2016\/01\/15\/bluemix-config-parser-2\/","category":["Bluemix","cloud","cloudfoundry","configuration","java","json","liberty","paas","parser","Bluemix","Cloud","Java"]}]}}