We have just had the twentieth edition of JavaOne in San Francisco. This would be my twelfth attendance in unbroken series since 2004. What are the biggest takeaways from the conferene that potentially shed a light on Java’s future?
Arun Gupta for Refactor your Java EE Applications with Microservices and Containers (CON1700)
Using java.util.HashMap from many threads without any synchronization leads to race conditions. So we need some kind of synchronization. The easiest way is to synchronize the complete class. Another way is to use a java.util.concurrent.ConcurrentHashMap. But what does this mean to the performance of the application?
As expected if we run the method “testMethod()” with two threads we see a race condition. Output from vmlens, a tool to detect race conditions:
One day I received a test task on an interview. I had to implement a JSON serialization and deserialization of a Checkout object in the context of e-commerce.
Debating and discussing Go package management has become a popular topic. Most people agree that the out of the box package management is insufficient. But, what should be used to complement the Go toolchain and what changes, if any, should the Go toolchain make?
Package management for programming languages is nothing new. It’s worth learning and discussing how package management is handled by other languages. This can fuel our discussions and decision making. I’ve personally been studying this as part of my work on Glide.
The Idea: What the heck does the term MicroPlode mean and what is this all about?
Microservices! For sure a term you can hardly dodge in the IT world these days. First time I heard about it I thought something along those lines of “nice idea, sounds really interesting”. But pretty quickly daily routine in the project took over again and washed me away from it. Then – quite recently – an idea materialised in my brain while I was reading more and more about it: Instead of only reading about it in theory, let’s do this in practice using a small – but somewhat meaningful – “playground project”. And puh, there are tons of blog posts out there to read on the topic. For example lately I was reading through this more skeptical blog post on DZone including roughly 100 comments discussion. It was really interesting as it was going from technical aspects to social aspects and back again. I really gained some insights from that. In the end this encouraged me in my idea to try the whole thing out in practice. And thanks to our company’s great working model that allows us to spend a decent amount of time exploring new technologies, I have the opportunity to start this little experiment here and now :-).
This is really the beginning of a journey with an open end. I have implemented nothing so far and I only have a few ideas regarding the technologies I would like to use. Furthermore it might turn out it does not make sense at all to implement this game using Microservice architecture, even though I thought a little bit about this in advance. I also discussed it a bit with a colleague who has more experiences in this area. Anyway, as with every project I am also starting optimistic into this one :-).
Architecture, yeah! I always involuntarily cringe a bit when writing the term “Architecture” in a blog post as from my personal observation this term is a bit overused these days. But talking about Microservices and how to model them seems to well deserve that term :-).
Ok, I have read and heard that finding the borderlines between the individual services is one of the hardest parts in a Microservices Architecture. As always with examples it is easier than in real-life projects, but still this is the result of some hard thinking and discussion :-). I see three building blocks for the game that will be implemented as Microservices and communicate via messaging. Let’s sketch them shortly before we go into more details.
Technical aspects aside, those three Microservices need to exchange information of course. Such a game is now of course nothing that has a lot of asynchronous things to do. It is someone’s turn, a move must be calculated and the change in game state that move triggers must be tracked. Nevertheless we will use messaging for communication here. For the sake of learning things and let’s see what it might be good for in the end. Let’s take a look at the the following figure depicting the communication between the services:
As in every project, this is work-in-progress, but for the time being this is hopefully good enough to start implementation. Let’s take a look at the events and what actions they should trigger in the different services.
The GameService has to know which players are available. Therefore we need the registration-event. This also leads to a somewhat open issue that is spooking around in my mind, namely that we will probably not have only one PlayerService, but multiple instances for different computer players and human players. Getting more concrete on that will be done at a later point in time, though.
Then the GameService must also know that the PlayingFieldService is ready to work using the board-ready-event.
If a new game is started, this must be propagated to the PlayerService(s)
The introduction of annotations with J2SE 5 has changed how we write and process Java. Besides Java SE's predefined annotations, frameworks, IDEs, and toolkits have introduced their own custom annotations. The Checker Framework has provided examples of how custom annotations can be used to add greater type safety in Java. In this post, I look at the writing of a simple custom annotation and using it in NetBeans (8.0.2) and IntelliJ IDEA (14.0.3) to help developers identify issues in their code that need further attention.
In the article Making the Most of Java's Metadata, Part 2: Custom Annotations, Jason Hunter demonstrates an @Unfinished annotation as an example of writing a custom Java annotation. I will demonstrate a different implementation of an @Unfinished annotation in this post. That's the beauty of custom annotations: one can write an annotation to best fit one's needs. The code for my @Unfinished annotation is shown in the next code listing.
This year at JavaOne 2015 there was a recurring theme across many of the Cloud and DevOps tech sessions that were promoting self-contained deployable JARs (not EARs or WARs) as a more efficient approach for deploying lightweight Java based services. This approach also plays well for a microservices type architecture and can also easily make use of containers, like Docker, PaaS offerings like CloudFoundry or Heroku, or even Oracle’s new Java SE Cloud Services offering.
Being able to deploy small, self-contained services (compared to large, monolithic EARs) brings a whole range of benefits, like being able to deploy more often, and deploy individual services individually without touching or impacting any of the other deployed services.
Initially, I wanted to call this blog – ‘Flexible timeouts with interceptor driven retry policies‘ – but then I thought it would be too ‘heavy’. This statement, along with the revised title should (hopefully) give you an idea of what this post might talk about ;-)
This post is primarily driven by one of the comment/questions I received on one of my earlier posts which briefly discussed timeout mechanisms and how they can be used to define ‘concurrency policies’ for Stateful and Singleton EJBs.
From time to time it is necessary to just take the little effort to think outside the box. This is a good habit for every developer and even if you just spend 10% of your time, with new and noteworthy technology, you will gain experience and broaden your knowledge. I wanted to look into Scala and Akka since a while. Both well known old acquaintances on many conference agendas. But honestly, I've never felt the need to take a second look. This changed quite a bit when I started to look deeper into microservices and relevant concepts around it. Let's get started and see what's in there.
What Is Akka? And Why Scala?
Remember the times when we had to register dispatchers, viewResolvers, etc. to make our spring application web app? Then there was
These days the only thing you need to do is to add
JDK Enhancement Proposal (JEP) 277 ("Enhanced Deprecation") proposes to "revamp the deprecation annotation and provide tools to strengthen the tail end of the feature life cycle." Some of the limitations of the current @java.lang.Deprecated have bothered me for some time. I particularly would like to be able to provide text with @Deprecated rather than being forced to place explanatory text in a corresponding Javadoc @deprecated comment. In this post, I look at a custom annotation that gives a feel for the type of extra metadata JEP 277 proposes be included in a new and improved @Deprecated annotation.
The code listing that follows contains the definition of
In this post we are going to cover working with the Optional class introduced in Java 8. The introduction of
A container object which may or may not contain a non-null value.
Groovy is a scripting language, so it is possible to run Groovy code without compiling to Java byte code. The necessary condition is that Groovy is installed on your machine. Then, running a Groovy script in a shell looks like the following line:
Now, something is wrong with the script on a special environment. You want to debug your Groovy script from the shell.
The diagram below is the Java Memory Model for the Heap as well as the PermGen for any Java Application running in the Java Virtual Machine (JVM). The ratios are also provided to get a fair understanding of how the distribution of allowed memory is done across each of the generation types. All of the info is completely applicable up to Java 1.7 (inclusive). This diagram is also known as the 'Managed Area' of the memory model.
Java Memory Architecture (Java Memory Model)
A big part of our thesis is that TDD is not really a testing activity, but rather a specifying activity that generates tests as a very useful side effect. For TDD to be a sustainable process, it is important to understand the various implications of this distinction.  Here, we will discuss the way our tests are structured when we seek to use them as Scott Bainhttp://firstname.lastname@example.org
Categories: TDD & BDD
Last week we had Fizz Buzz code golf and the winner was Mark Ogden in Perl with an amazing 63 characters.
There were a couple of answers that were also very close to that as well so well done to them too.
This weeks challenge is a little harder and should really tax your brains. Basically I would like you to find the first instance of an arbitrary length substring within a string without using regular expressions or the find/indexOf/search functions of the String object. So writing it in a low level aproach at a character level.
So in the case of the above example I am looking for the index of the first letter of the word end in the string you see there.
As a Java based CMS, dotCMS handles a lot of different use cases for managing and delivering content. Recently, we were asked if dotCMS can deliver Github flavored markdown content. We thought that this would be a great example of how easy it is to extend dotCMS with OSGi plugins. (As a side note, this blog - as seen on dotcms.com - is actually written using the plugin).
Some background for developers stuck in 2008, Markdown is a text to html parser originally written by John Gruber. It provides a user a simple, small set of markup tags that is parsed and rendered as standard HTML for consumption by browsers or even less capable views or viewports. Github Flavored Markdown, or GFM, offers a few extensions for further formatting, including support for strikethrough, url auto-linking, syntax highlighting and tables, Because of the ubiquity of github as a coding resource, GFM has become a de facto standard for commenting, documentation and other online authoring tools that needs support for formatting, but want to limit, uh, “creativity”.
Hi all. Just published an open source library to the Maven Central Repository. As the author of this project, I am here to shout out the exciting news :)
ParallelGit is a library to help you manipulate your local Git repository. It allows you to access your repository as it were a native file system (via Java 7 nio FileSystem interface).
Today, JetBrains announced a new release of their popular IDE IntelliJ IDEA. The company promised the new release brings a new set of features and tools, UI improvements, and improved coding assistance.
In addition, JetBrains' new in-development JVM language, Kotlin, has gone into Beta. Naturally, the new language is supported in IntelliJ IDEA 15.
Background: What is a Zone Leader?
Recently I've taken charge on what I think is a great opportunity for writers and topic experts in the devsphere—our new Zone Leader Program. In a nutshell, the Zone Leader Program is an effort to put topic experts and practioners in the software industry at the helm of the content we publish on DZone. A sizeable portion of the content you've been reading on DZone recently has actually been written or published by Zone Leaders!
If you're interested in learning more and maybe being a Zone Leader yourself, shoot me an email.