tag:blogger.com,1999:blog-31190384113752525592024-02-19T16:45:31.704-08:00Tom's BlogJava stuff, web technologies, patterns, pitfalls, exciting features and moreTomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.comBlogger59125tag:blogger.com,1999:blog-3119038411375252559.post-67027894188593330002015-04-29T14:06:00.004-07:002015-04-29T14:31:11.733-07:00JEE Series: Struts 2 Tags and Client-Side Validation<span style="font-family: Arial, Helvetica, sans-serif;">This post concludes the example from the <a href="http://zezutom.blogspot.se/2015/04/jee-series-struts-2-actions-and-input.html" target="_blank">previous article</a>. Today, we take a closer look at the client-side, namely the use of tags and how to perform an efficient input validation.</span><br>
<br>
<a href="http://zezutom.blogspot.com/2015/04/jee-series-struts-2-tags.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-89151076322735186862015-04-18T15:15:00.003-07:002015-04-18T15:46:24.399-07:00My Experience with JHipster<span style="font-family: Arial, Helvetica, sans-serif;">When I saw <a href="http://www.drissamri.be/blog/technology/starting-modern-java-project-with-jhipster/" target="_blank">this informative post</a> about <a href="https://jhipster.github.io/" target="_blank">JHipster</a> I couldn't wait to try it out. Features like security, persistence, responsive UI, efficient monitoring, ability to change log level at runtime and much more - all granted for free, no effort whatsoever. Amazing stuff, and it worked... almost. I ended up spending a day trying to brew my perfect app. Well, let me tell you there have been a lot of waiting time and errors. Even though I am not sure if I am ready to use the tool for real I wanted to share my experience. Never mind the time and effort, some of the problems were, as usual, my own fault and made me fix my environment.</span><br>
<a href="http://zezutom.blogspot.com/2015/04/my-experience-with-jhipster.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com2tag:blogger.com,1999:blog-3119038411375252559.post-52432710174888021592015-04-15T13:44:00.000-07:002015-04-29T14:24:58.912-07:00JEE Series: Struts 2 - Actions and Input Validation<span style="font-family: Arial, Helvetica, sans-serif;">In this post we take a closer look at the basics of a popular MVC framework <a href="http://struts.apache.org/" target="_blank">Apache Struts</a>. Today, we explore the server-side and discuss the concept of actions and validation. As usual, <a href="https://github.com/zezutom/JEE-Series/tree/master/SimpleWebStruts" target="_blank">an example app</a> is provided and you are more than welcome to code along. </span><br>
<a href="http://zezutom.blogspot.com/2015/04/jee-series-struts-2-actions-and-input.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-34959657605130702462015-04-11T01:30:00.001-07:002015-04-11T01:30:24.913-07:00JEE Series: JSP and Integration Tests via HtmlUnit<span style="font-family: Arial, Helvetica, sans-serif;">In the previous post we experimented with JavaServer Pages and created a simple web app. Lazy coders as we are can't help, but automate as much as possible in order to avoid tedious manual steps. <a href="http://htmlunit.sourceforge.net/" target="_blank">HtmlUnit</a> is very well suited to work in tandem with JSP technology. I value the framework for its ease of use and succinct API.</span><br>
<br>
<a href="http://zezutom.blogspot.com/2015/04/jee-series-jsp-and-integration-tests.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-74409713374972875492015-04-08T15:33:00.002-07:002015-04-08T15:33:56.259-07:00JEE Series: JavaServer Pages + JavaBeans and no web.xml<span style="font-family: Arial, Helvetica, sans-serif;">In this very first post of the <a href="http://zezutom.blogspot.se/2015/04/starting-new-series-about-jee.html" target="_blank">JEE Series</a> we create a simple web app based on JSP and JavaBeans. Bring an IDE of your choice and give it a swing.</span><br>
<a href="http://zezutom.blogspot.com/2015/04/jee-series-javaserver-pages-javabeans.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-64301030320299039812015-04-04T15:41:00.000-07:002015-04-04T15:48:37.451-07:00Starting a New Series about JEE<span style="font-family: Arial, Helvetica, sans-serif;">I am starting a new series discussing various JEE technologies. Feel free to <a href="https://github.com/zezutom/JEE-Series" target="_blank">fork me on GitHub</a>, blog posts are to follow.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2015/04/starting-new-series-about-jee.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-86113273518361260602015-02-14T07:39:00.005-08:002015-02-14T07:39:59.576-08:00Travis CI and Multi-Language Projects<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://travis-ci.org/" target="_blank">Travis CI</a> is an awesome free-of-charge continuous integration service. Go and check it, if you haven't tried it yet. What I appreciate in particular is a broad range of supported programming languages. Should you happen to have a project based on more than a single language though, then you might wonder if and how the builds would work.</span><br>
<br>
<a href="http://zezutom.blogspot.com/2015/02/travis-ci-and-multi-language-projects.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com1tag:blogger.com,1999:blog-3119038411375252559.post-68971592858449908872015-02-07T15:18:00.000-08:002015-02-07T15:34:02.266-08:00Step-by-Step: Fabric and Android Studio<span style="font-family: Arial, Helvetica, sans-serif;">I've just added <a href="https://get.fabric.io/" target="_blank">Fabric SDKs</a> to </span><span style="font-family: Arial, Helvetica, sans-serif;">my Android project </span><span style="font-family: Arial, Helvetica, sans-serif;">and the initial impression is overly positive. However, during the setup, I ran into a few time consuming issues. Enhanced with a better understanding of how it all fits together, I have to admit that most of the troubles were totally avoidable. In this post, I would like to walk you through </span><a href="https://dev.twitter.com/twitter-kit/android/integrate" style="font-family: Arial, Helvetica, sans-serif;" target="_blank">the official tutorial</a><span style="font-family: Arial, Helvetica, sans-serif;"> and highlight the important steps.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2015/02/step-by-step-fabric-and-android-studio.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com1tag:blogger.com,1999:blog-3119038411375252559.post-50328614336373242682015-01-31T08:34:00.000-08:002015-01-31T08:53:16.309-08:00Bytecode Manipulation via Reflection API and Javassist<span style="font-family: Arial, Helvetica, sans-serif;">I've recently come across an interesting puzzle, it went like "Guess the next value of Math.random()". How could you possibly do it? Well, since the output is unpredictable by definition, the only option left for many of us is cheating. Once I successfully "solved" the puzzle by crippling the poor Math class to a worrying extent, I was thinking what else could I do. And most importantly, how far would I get before I had to reach for advanced frameworks like <a href="http://mockito.org/" target="_blank">Mockito</a>, <a href="https://code.google.com/p/powermock" target="_blank">PowerMock</a> or <a href="http://www.jmock.org/" target="_blank">jMock</a>.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2015/01/bytecode-manipulation-via-reflection.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-33457011749838099402015-01-11T12:13:00.001-08:002015-01-11T12:19:13.972-08:00Fluency of Java 8 Date-Time API<span style="font-family: Arial, Helvetica, sans-serif;">Here are a few quick examples of how API calls can be chained to answer advanced queries, such as "Which day is the last Friday of the next month". Or imagine you need match a weekly or monthly schedule. These and similar queries can be resolved without much of an effort.</span><br>
<a href="http://zezutom.blogspot.com/2015/01/fluency-of-java-8-date-time-api.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-35901442831088769532015-01-10T12:24:00.001-08:002015-01-10T12:24:56.910-08:00String Interpolation in Java<span style="font-family: Arial, Helvetica, sans-serif;">Languages like Scala, Ruby or even PHP allow to build dynamic textual content in an elegant and concise way. Is <a href="http://en.wikipedia.org/wiki/String_interpolation" target="_blank">string interpolation</a> available in Java?</span><br>
<br>
<a href="http://zezutom.blogspot.com/2015/01/string-interpolation-in-java.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-63042192520337097822015-01-06T07:58:00.000-08:002015-01-06T07:58:40.147-08:00API Mock Server Powered by Node.js<span style="font-family: Arial, Helvetica, sans-serif;">There we go again. I couldn't help but to (re)<a href="https://github.com/zezutom/scrapit" target="_blank">write my own</a>. Unlike my <a href="https://github.com/zezutom/apimock" target="_blank">previous attempt</a>, I managed to keep implementation neat and tidy with <a href="https://travis-ci.org/zezutom/scrapit" target="_blank">a solid test coverage</a>. Since all the details are on the <a href="https://github.com/zezutom/scrapit" target="_blank">project page</a>, I will only focus on a few quick highlights.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2015/01/api-mock-server-powered-by-nodejs.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com1tag:blogger.com,1999:blog-3119038411375252559.post-35501553201543373872014-12-28T08:34:00.002-08:002014-12-28T08:42:06.878-08:00Preloading of an Android WebView<span style="font-family: Arial, Helvetica, sans-serif;">Coding for Android can be tough at times. Especially when things one would take for granted aren't supported at all. Such as an option for a fully justified text in a <a href="http://developer.android.com/reference/android/widget/TextView.html" target="_blank">TextView</a>. After having tried a number of different solutions I eventually gave up on using a TextView and resorted to a <a href="http://developer.android.com/reference/android/webkit/WebView.html" target="_blank">WebView</a> instead. Of course, the first problem I hit was bad performance. While the text started to show in a way it was meant to, it took about a second to load despite the fact there was no network traffic involved at all. Having to show a spinner for a tiny piece of text loaded from local resources felt like a snap in the face. I started to dig into the issue with the TextView once again. I even ended up <a href="https://github.com/zezutom/textjustifier" target="_blank">implementing full justification on my own</a>, but when trying to apply it to Android I quickly discovered there was much more to worry about. Scrap that, back to the sluggish WebView, trying to preload it this time. That finally worked. So here is my take on how to preload a simple dialog containing a WebView.</span><br>
<div>
</div><a href="http://zezutom.blogspot.com/2014/12/preloading-of-webview-in-android.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-80787088431829792192014-12-22T10:51:00.001-08:002014-12-22T10:53:23.866-08:00Google Cloud Endpoints - Design Considerations<span style="font-family: Arial, Helvetica, sans-serif;">While designing of the Endpoints API is fairly straightforward, there are gotchas one might stumble upon. Especially when task at hand is slightly more involved than the proverbial "hello world" example. It took several iterations in my tiny little project to adjust the API according to my needs.</span><br>
<div>
</div><a href="http://zezutom.blogspot.com/2014/12/google-cloud-endpoints-design.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-45258577148564774332014-12-22T05:26:00.001-08:002014-12-22T05:37:01.897-08:00Google Cloud Endpoints - GET vs POST<span style="font-family: Arial, Helvetica, sans-serif;">Conscious about <a href="http://en.wikipedia.org/wiki/Representational_state_transfer" target="_blank">REST</a>? Then you want to have control over HTTP methods associated with your API calls. Should you choose not to use <a href="https://cloud.google.com/appengine/docs/java/endpoints/annotations?hl=en#apimethod_method-scoped_annotations" target="_blank">@ApiMethod</a>, Endpoints falls back to an educated guess approach based on the API method name, <a href="https://cloud.google.com/developers/articles/google-cloud-endpoints-for-android" target="_blank">as stated in the docs</a>. I couldn't find much details about how the resolution works, but common sense worked for me. This post presents my findings when experimenting with automatic HTTP method resolution.</span><br>
<br>
<a href="http://zezutom.blogspot.com/2014/12/google-cloud-endpoints-get-vs-post.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-27331731776190728092014-12-21T11:21:00.002-08:002014-12-21T11:31:15.938-08:00Google Cloud Endpoints - Overloaded Methods not Supported<span style="font-family: Arial, Helvetica, sans-serif;">The title says it all, one cannot make use of method overloading when working with Endpoints. Not a big deal one might think. Well, as usual, it depends. To me, method overloading is a feature I appreciate, since it allows for a great naming consistency and promotes polymorphism, one of the major deals with OOP. I have yet to find out what the underlying limitation is. In Spring MVC for instance, as long as the associated URL mapping is unique, method overloading isn't much of a trouble. Nevertheless, this post adds a quick example proving the feature remains unsupported.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/12/google-cloud-endpoints-overloaded.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-37855020186149838612014-12-21T08:50:00.001-08:002014-12-21T11:31:49.255-08:00Google Cloud Endpoints - Watch for Missing Annotations<span style="font-family: Arial, Helvetica, sans-serif;">One of the early frustrations I had with Endpoints were run-time exceptions. Turns out, regardless of what the culprit is, the dev server (jetty 6) wouldn't reveal much details of what exactly went wrong. Whatever the problem bet the server fails with <i>java.io.IOException: Failed to retrieve API configs with status: 500</i>. If you are a newbie like I was, there is a good chance your code lacks a mandatory annotation. There is a little trick to it which helps you nail the issue down fairly quickly.</span><br>
<a href="http://zezutom.blogspot.com/2014/12/google-cloud-endpoints-watch-for.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-47258235005705491352014-12-21T07:03:00.001-08:002014-12-28T08:43:04.265-08:00Google App Engine and Android - Pros and Cons, Challenges<span style="font-family: Arial, Helvetica, sans-serif;">I spent almost three months working on <a href="https://github.com/zezutom/quizzer-android" target="_blank">my first "bigger" Android project</a>. My goal was to build a simple gaming app backed by a cloud platform from ground up. It has mostly been an enjoyable experience, but as usual there were times I found myself clueless. The overall effort was also way higher then initially planned for. This post starts a new series where I will reflect on technologies I worked with, challenges I came across and mistakes I made. First write-ups will focus on pitfalls I encountered when starting with <a href="https://cloud.google.com/appengine/docs/java/endpoints" target="_blank">Google Cloud Endpoints</a>. Stay tuned.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/12/google-app-engine-and-android-pros-and.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-7528153637686328592014-09-14T08:22:00.000-07:002014-09-14T08:27:39.821-07:00Haversine formula application in Python<span style="font-family: Arial, Helvetica, sans-serif;">I have recently enrolled to <a href="https://class.coursera.org/datasci-002" target="_blank">Introduction to Data Science</a>. One of the very first assignments was Twitter sentinent analysis performed in Python. Leaving a whole lot aside, what captured my attention was a requirement to resolve tweets' geocoded locations without relying on 3rd party services.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/09/haversine-formula-application-in-python.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com1tag:blogger.com,1999:blog-3119038411375252559.post-50463230300742248362014-08-31T08:29:00.000-07:002014-08-31T08:29:11.586-07:00Concurrency patterns - Half-Sync / Half-Async<span style="font-family: Arial, Helvetica, sans-serif;">The pattern separates asynchronous I/O from the synchronous one. Main thread doesn't block on incoming client requests and long-running operations are offloaded to a dedicated synchronous layer. Processing results are delivered by the means of callbacks.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/08/concurrency-patterns-half-sync-half.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-11889639109165797432014-08-30T09:21:00.004-07:002014-08-31T04:59:51.280-07:00Concurrency Patterns - Monitor Object<span style="font-family: Arial, Helvetica, sans-serif;">The pattern revolves around synchronization. In short, concurrent threads (clients) can only use the object via a set of synchronized methods. Only one method can run at a time. Typically a synchronized method watches for a certain condition. However, there is no polling involved. Instead, the methods are being notified. That's an important difference in comparison to the <a href="http://zezutom.blogspot.se/2014/08/concurrency-patterns-active-object.html" target="_blank">Active Object</a>.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/08/concurrency-patterns-monitor-object.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-90102633312473768962014-08-30T08:29:00.000-07:002015-09-13T11:58:08.672-07:00Concurrency patterns - Active Object<span style="font-family: Arial, Helvetica, sans-serif;">Active Object pattern decouples method execution from its invocation. Think asynchronous method invocation, callbacks etc. To avoid race conditions, incoming client requests are queued and handled by a scheduler. The scheduler picks a queued object and makes it run its logic. It is object's responsibility to know what to do when it gets invoked, hence the Active Object.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/08/concurrency-patterns-active-object.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com2tag:blogger.com,1999:blog-3119038411375252559.post-65450404013425986942014-08-30T05:31:00.001-07:002014-08-31T04:27:10.682-07:00How to force quit of a detached screen session<span style="font-family: Arial, Helvetica, sans-serif;">Here is how to terminate a stuck <a href="http://aperiodic.net/screen/quick_reference" target="_blank">screen</a> command using a script. As part of my job I deal with a legacy Linux setup comprising a range of screens. Every now and then some of them freeze due to memory issues and attaching a session doesn't work anymore. I was wrapping my head around how to avoid tedious manual resets of the dead screens. Turns out all can be easily automated.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/08/how-to-force-quit-of-detached-screen.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-40145379830453416432014-04-03T13:55:00.005-07:002014-08-31T04:37:30.770-07:00Spring series, part 6: Spring 4 and Generics-based Injection Matching<span style="font-family: Arial, Helvetica, sans-serif;">Up until Spring 4 generics played no major role when it came to resolving injected bean dependencies. Suppose there are multiple beans of the same type implementing a generic interface. In a pre-Spring 4 world, any attempt to resolve such a bean by type would inevitably lead to a NonUniqueBeanDefinition exception, unless additional hints were provided (such as @Qualifier). Spring 4 removes this limitation by making generics a distinguishing part of a bean definition. Here is a short example.</span><br>
<br>
<a href="http://zezutom.blogspot.com/2014/04/spring-series-part-6-spring-4-and.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com0tag:blogger.com,1999:blog-3119038411375252559.post-50153648779025032912014-03-23T02:43:00.000-07:002014-08-31T04:40:06.164-07:00Tomcat - java.lang.InternalError: name is too long to represent<span style="font-family: Arial, Helvetica, sans-serif;">I've got the aforementioned exception </span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">when I was trying to load a jsp page</span><span style="font-family: Arial, Helvetica, sans-serif;"> on Tomcat 6 running in a debug mode. Turns out the problem occurs when a jsp page grows big. It's a known JVM issue described by bugs </span><a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=39089" style="font-family: Arial, Helvetica, sans-serif;" target="_blank">39089</a><span style="font-family: Arial, Helvetica, sans-serif;"> and </span><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6294277" style="font-family: Arial, Helvetica, sans-serif;" target="_blank">6294277</a><span style="font-family: Arial, Helvetica, sans-serif;">. Here is how to solve it without touching the jsp.</span><br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br>
<a href="http://zezutom.blogspot.com/2014/03/tomcat-javalanginternalerror-name-is.html#more">Read more »</a>Tomas Zezulahttp://www.blogger.com/profile/04085366869035210911noreply@blogger.com2