Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on DZone.com
Updated: 3 hours 37 min ago

Infinispan’s Java 8 Streams Capabilities

Fri, 2017-04-28 19:01

Let’s be honest: It’s pretty exciting that Infinispan now supports Java 8 for many reasons, but perhaps one of the most anticipated reasons is because of the new stream classes. The main reason for this is the fact that it completely transforms the way we process data. Instead of having to iterate upon the data yourself, the underlying stream does this for you, and all you have to do is provide the operations to perform on it. This is perfect for distributed processing because the implementation handles the iteration entirely.

However, another important reason why these kinds of advancements are so important is they make development accessible to younger generations. By creating easier methods, we are actually opening up opportunities for young people to get involved in the tech sector, and creating career paths for people who have earned an information technology degree that feel as though this work may be too hard for them.

Categories: Java

What Devs Should Keep in Mind About Java

Fri, 2017-04-28 13:01

To gather insights on the state of the Java ecosystem today, we spoke to nine executives who are familiar with the ecosystem. 

We asked these experienced Java professionals "What do developers need to keep in mind when working with Java?" Here's what they told us:

Categories: Java

Advanced Git Log

Fri, 2017-04-28 10:01

The purpose of any version control system is to record changes to your code. This gives you the power to go back into your project history to see who contributed what, figure out where bugs were introduced, and revert problematic changes. But, having all of this history available is useless if you don’t know how to navigate it. That’s where the git log command comes in.

By now, you should already know the basic git log command for displaying commits. But, you can alter this output by passing many different parameters to git log.

Categories: Java

Method Length and Extract 'Til You Drop

Fri, 2017-04-28 07:01

As a typical nerd (and a DZone Zone Leader), I tend to read a lot of blog posts and comments about programming. One thing that keeps amazing me is how long people’s functions tend to be and how many people are convinced this is the right way to code. In reality, a readable function should rarely exceed five lines of code.

Take a short look at this function:

Categories: Java

Using the Timer Class to Schedule Tasks

Thu, 2017-04-27 22:01

Scheduling tasks to run is a need that sometimes arises in a Java program. Maybe you want to run a periodic cleanup of some resource, or check on the status of some job, or maybe fetch a URL which might not be available the first time.

The Timer class provides a very simple implementation of such a scheduler. Let us learn how to use it.

Categories: Java

Inject Kubernetes ConfigMap Values With Java EE and WildFly

Thu, 2017-04-27 18:01

The Kubernetes ConfigMap concept is used to configure applications from an orchestration environment. The configured values can be made accessible within the Java EE container.

Kubernetes can inject configured values to the running POD, e.g. as properties files. By defining custom modules in WildFly, these files — which are not shipped with the deployment artifact — can be made accessible from the classpath.

Categories: Java

Programmatic Registration of Java Configuration Beans

Thu, 2017-04-27 12:01

I have been working on refactoring the Spring Security Calendar application from an XML configuration to a Java configuration.

In the migration, the is a DefaultService.java file that is using UserDetailsManager, which extends UserDetailsService:

Categories: Java

First Look at HTTP/2 Server Push in Java Servlet 4.0 Specification

Thu, 2017-04-27 09:01

Servlet is one of the most important specifications in the Java EE ecosystem. It is used on millions of applications and hundreds of web frameworks. Because the Java Servlet specification is highly tied to the HTTP protocol, it is updated following HTTP protocol changes.

HTTP 2 comes after the widely used HTTP 1.1 protocol, and its new features bring much better performance to the web. For example, the HTTP/2 Server Push feature gives a way to push web resources from server to client. In that way, server applications are able to send content(s) at the beginning of the initial requests, instead of waiting for clients' requests. It brings an efficient way to transfer resources in HTTP 2-enabled web applications.

Categories: Java

Toss Out the Inheritance Forest

Thu, 2017-04-27 06:01

While doing code review, I have seen many times that there is a potential danger of creating a lot of inherited classes, and a simple change in business requirements would make it unmanageable. So, surely, this is a serious code smell, and we have to take action.

Business Case

If two criteria are interlinked, the outcome product can be any combination of those two criteria. To put it simply, say the requirement is, "We have to create a ball, and the ball can be made of any material and be of any color."

Categories: Java

Thoughts on Vaadin: The Value of Data Binding

Wed, 2017-04-26 22:01

I had the pleasure of talking with Roland Krüger, a software engineer who works at a consulting company (Orientation in Objects) in Mannheim, Germany. His job includes working in Java-related customer projects, consulting (sometimes Vaadin-related), and trainings in different technical areas. 

Hello, Roland! Thanks for accepting the invitation. So, how long have you been using Vaadin?

Categories: Java

This Week in Spring: Metrics, Caching, and MVC

Wed, 2017-04-26 18:01

Welcome to another installment of This Week in Spring! This week I’m in beautiful Bangalore, India, at the 10th edition of the great, Great Indian Developer Summit! Then, I’m off to Perth, Australia, for YOW! West. If you’re around, say hi! We’ve got a lot to cover, so let’s get to it!

Categories: Java

Java 8: Methods in Interfaces

Wed, 2017-04-26 15:01

My previous post on streams demonstrates how useful this feature is to Java 8. However, it created a problem for the API designers. The problem was how to we extend the existing Collection’s API without breaking existing Collections implementations (Guava, Apache, etc.).

The solution was to allow methods in interfaces, meaning that any implementations already carry an implementation of the extension.

Categories: Java

Creating a CD Pipeline With Jenkins and Java

Wed, 2017-04-26 12:01

Lately, I’ve been working a lot with Jenkins for continuous deployment of one of my applications. In case you haven’t seen it, the keynote demonstration given at Couchbase Connect 2016 used Jenkins to build and redeploy the Java backend and Angular frontend every time a change was detected on GitHub. This is the application I helped build.

So how did I leverage Jenkins to make this possible? We’re going to see how to create a continuous deployment pipeline for a Java application which includes building and deploying to a server.

Categories: Java

Java-Based Microservices Architecture and Abixen

Wed, 2017-04-26 09:01

Microservices are getting constantly more and more popular. Every month, there are more libraries and solutions supporting a development process, testing, and further support. Many Java developers have heard about the microservices approach, but a significant number of companies have not taken the challenge of implementing a microservices-based architecture. Does this sound familiar?

"I know, microservices are awesome, microservices bring easier maintenance and further development, but we have no resources to build a good microservices-based architecture."

Categories: Java

Web MVC With Spring and Business Objects

Wed, 2017-04-26 06:01

In my previous posts, we explored the MVC Pattern Language by Trygve Reenskaug and made an attempt to implement MVC in the console, while focusing on MVC’s overarching idea – supporting users’ mental models. In this post, we’ll take a quick look on how to move the (poor) console example to the web.

A Short Reminder

For those of you who haven’t read the previous post or don’t (want to) remember, we were creating a simple “Pet Clinic” application. We visited an old vet lady who does not own a computer to gather requirements and get a basic idea of what her work is about. For the most part, she’s using two interesting items at work: a visit calendar and pet files. These are perfect candidates to become business objects in our system. Since the lady is so used to them in the physical world, we assume she’ll have no problems using their computerized versions. So far, we created a console representation of the visit calendar. Now, we want to move it to the web so that it’s usable for non-nerd human beings.

Categories: Java

Guide to Separate JRE Versions From NetBeans Platform Installer

Tue, 2017-04-25 22:01

In an enterprise set up where updating Java on a client machine is not allowed due to software restriction policy, it becomes challenging to develop and ship applications which require the latest version of Java to be installed on client machines. One way to circumvent this policy-based restriction is to bundle the JREs for 32-bit and 64-bit Windows OS in a separate NetBeans platform installer. This ensures that the JRE remains isolated from the system and conflict with any older version of Java is avoided. This method is detailed in an excellent article written by  Ernest Lotter.

However, the bundling of JRE with the application forces you to maintain separate copies of the installer for 32-bit and 64-bit versions of Java. It also ties the application with the version of Java which was available at that point in time. In a scenario where development and improvement is a continuous process, one would love to have the flexibility of using the latest Java features in the application being developed and at the same time be able to deliver the latest version of Java to client machines.

Categories: Java

Java 9 (Part 4): Trying Try-with-Resources: First Look

Tue, 2017-04-25 18:01

This is part 4 of the java 9 series. While in part 3 we covered interfaces and the private methods that were added to them, in part 4 we see that try-with-resoures was enhanced, or we might say even fixed. Try-with-resources, which was introduced back in java 7, is a concept which helps developer close resources which are not using anymore, such as database connection, file streams, etc. Let’s see how try-with-resources behaved in java 7 and now in java 9.

Step 1: Pre-Java 7 Try-with-Resources

Try-with-Resources, prior to Java 9, meant that instead of just calling a piece of code which opens up a resource like:

Categories: Java

Spring Transaction Management Over Multiple Threads

Tue, 2017-04-25 12:01

The Spring framework provides a comprehensive API for database transaction management. Spring takes care of all underlying transaction management considerations and provides a consistent programming model for different transaction APIs such as Java Transaction API (JTA), JDBC, Hibernate, Java Persistence API (JPA), and Java Data Objects (JDO). There are two main types of transaction management in Spring: declarative transaction management, which is a high level one, and programmatic transaction management, which is more advanced but flexible.

The Spring API works very well with almost all of the transaction management requirements as long as the transaction is on a single thread. The problem arises when we want to manage a transaction across multiple threads. Spring doesn't support transactions over multiple threads out of the box. Spring doesn't explicitly mention that in the documentation, but you will end up with runtime errors or unexpected results if you try to do so.

Why Do Spring Transactions Over Multiple Threads Fail?

Spring stores a set of thread locals inside the  org.springframework.transaction.support.TransactionSynchronizationManager class. These thread locals are specific for an ongoing transaction on a single thread (Thread locals values are specific for a single thread. Thread local value set by one thread cannot be accessed by another thread).

Categories: Java

Fixing My Own Spring Boot Starter Demo

Tue, 2017-04-25 09:01

For one year or so, I've been trying to show the developer community that there’s no magic involved in Spring Boot, just straightforward software engineering. This is achieved with blog posts and conference talks. At jDays, Stéphane Nicoll was nice enough to attend my talk and pointed out an issue in the code. I didn’t fix it then, and it came back to bite me last week during a Pivotal webinar. Since a lesson learned is only as useful as its audience, I’d like to share my mistake with the world, or at least with you, dear readers.

The context is that of a Spring Boot starter for the XStream library: XStream is a simple library to serialize objects to XML and back again.

Categories: Java

Servlet 4 Public Review Starts Now!

Tue, 2017-04-25 06:01

Servlet 4 has just posted a public review (this is the last step before the proposed final specification). Servlet 4 is easily one of the most critical components of Java EE 8. The primary aim of Servlet 4 is to bring first-class, core standards based HTTP/2 support to the server-side Java ecosystem. Most of the changes in Servlet 4 (with the exception of things like the server push API) should be transparent to developers and are enforced in terms of requirements for Servlet 4 implementations to fully support HTTP/2. A decent resource to learn more about Servlet 4 and HTTP/2 should be my slide deck:

HTTP/2 and What it Means for the Java EE Ecosystem from Reza Rahman.

You can download and take a look at the draft specification itself from the JCP site. While this is essentially the final stretch for Servlet 4, below are some ways you can still engage; most of it comes directly from the Adopt-a-JSR page I drafted while still at Oracle. The Servlet 4 specification lead Ed Burns has also asked for specific help in testing out the server-push feature. His write-up is also a great introduction to the feature.

Categories: Java

Pages