Subscribe: Javalobby - The heart of the Java developer community
Added By: Feedage Forager Feedage Grade A rated
Language: English
announced spring  announced  code  data  framework  java  layer  method  service  spring boot  spring  web service  web 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Javalobby - The heart of the Java developer community

DZone Java Zone

Recent posts in Java on


Java Microservice Communication: Avoiding Problems

Mon, 25 Sep 2017 04:01:01 GMT

In a previous post, I showed you how to build a microservice with Java EE and JBoss Forge. But building one microservice is obviously not enough. The overall idea of this architectural style is to implement an application as a system of services. In the beginning, that seems like an easy task. As long as each service solves only one problem and doesn’t need to call other services, you can keep its complexity low, and it will be easy to understand.

But if you think back to all the applications you’ve built during your career as a software developer, were there any applications that required the implementation of several independent tasks which didn’t interact with each other?

Creating a REST Web Service With Java and Spring (Part 4)

Sun, 24 Sep 2017 09:01:01 GMT

Running and Consuming the Web Service

Since we are using Maven to manage the dependencies and build the lifecycle of our application, and Spring Boot to configure our application, we can build our project and start the HTTP server using the following command (once Maven has been installed):

mvn spring-boot:run

This will host the REST web service on http://localhost:8080. If we look closely at the output, we can see the following statements:

A Guide to Spring Framework Annotations

Sun, 24 Sep 2017 05:01:31 GMT

The Java programming language provided support for annotations from Java 5.0 onward. Leading Java frameworks were quick to adopt annotations, and the Spring Framework started using annotations from the 2.5 release. Due to the way they are defined, annotations provide a lot of context in their declaration.

Prior to annotations, the behavior of the Spring Framework was largely controlled through XML configuration. Today, the use of annotations provide us tremendous capabilities in how we configure the behaviors of the Spring Framework.

Creating a REST Web Service With Java and Spring (Part 3)

Sat, 23 Sep 2017 10:01:00 GMT

Implementing the Presentation Layer

Without the aid of a web application framework, creating a presentation layer would be a daunting task, but after many years, the patterns and conventional designs of RESTful web services have been captured in the Spring Model-View-Controller (MVC) framework. This framework allows us to create RESTful endpoints with much the same ease as we saw during the development of our data source layer, using annotations and helper classes to do most of the heavy lifting for us.

Starting with the class that is the most depended on and requires the least dependencies, we will create the OrderResource first:

Getting the Most Out of the Java Thread Pool

Sat, 23 Sep 2017 05:01:49 GMT

The thread pool is a core concept in multithreaded programming that, simply put, represents a collection of idle threads that can be used to execute tasks.

First, let’s outline a frame of reference for multithreading and why we may need to use a thread pool.

Using Atomic Methods to Write Thread-Safe Classes

Fri, 22 Sep 2017 20:01:01 GMT

The classes in the package java.util.concurrent use atomic methods to update their internal state in a thread-safe way. In this article, you will see how to write and use such atomic methods to create thread-safe classes.

Atomic Methods

A method is atomic if it is "all or nothing." If a thread reads the data, the thread can only see the state before or after the execution of the atomic method — no intermediate state. After the atomic method was executed successfully, the changes are visible to all threads. The atomic method only modifies data of its own object without side effects. Here are some examples of atomic methods.

Java 9: It's Heeeere

Fri, 22 Sep 2017 17:16:54 GMT

After months of delays, waiting, and rework, JDK 9 arrived yesterday!

Whether you're in it for the JPMS, JShell, convenience factory methods, and/or any of the myriad other features introduced, chances are that you're over the moon. So, instead of rehashing the long, storied journey of Project Jigsaw or touching on what REPL means for Java, let's cut to the chase and get the tools you want into your hands, then take a look around the web to see what's going on.

Java 9 and IntelliJ IDEA

Fri, 22 Sep 2017 16:01:01 GMT

Java 9 was just released, so let’s do a quick recap of the Java 9 support in IntelliJ IDEA and have a peek at some of the upcoming features in IntelliJ IDEA 2017.3 for Java 9.

Jigsaw and the JPMS

The big feature for Java 9 is, of course, the Java Platform Module System (JPMS), which comes under the umbrella Project Jigsaw. Jigsaw itself is a much bigger undertaking and includes things like the modularisation of the JDK itself, what’s interesting to us as developers is the JPMS.

Supporting Kojo

Fri, 22 Sep 2017 10:01:01 GMT

Back in May 2017, we launched our annual charity survey that looked into the rapidly evolving Fast Data, Streaming, and IoT ecosystem. We're thrilled that we received over 2400 responses, reaching our $5,000 donation goal for the Kogics Foundation, a public charitable trust in India run by Lalit Pant that provides free education to underprivileged children (including programming in Scala via Kojo), financial and in-kind help to the poor, and even medical assistance to those in need.

To learn more about Kojo and the Kogics Foundation plans for the future, we prepared this interview with Lalit. Enjoy!

A Clarified String Formatting Cheatsheet

Fri, 22 Sep 2017 07:01:03 GMT

The Java documentation of String formatting is not the easiest to read and understand if you are not familiar with String formatting or just want a quick solution. Although it is complete, it is not very user-friendly, so I thought I would try and write a clearer version. This article is as much for you as it is an aide memoir for myself.

The Format Methods

There are two methods that provide String formatting behavior: format() and printf(). The format() method is a static method of the String.class, and the printf() method is a method of the static System.out.class. They both behave exactly the same way and have the same signature.

Creating a REST Web Service With Java and Spring (Part 2)

Fri, 22 Sep 2017 05:01:30 GMT

Implementing the Web Service

Finding where to start can be difficult, but we will take a systematic approach to creating our web service. Start with the layer that depends on the fewest other layers and is depended on by the greatest number of layers. Thus, we will first implement the domain layer, which does not depend on the other two layers but is depended on by both. Then we will implement the data source layer, which depends on the domain layer and is likewise depended on by the presentation layer. Lastly, we will implement the presentation layer, which is not depended on by any other layer but depends on both the data source and domain layers.

Implementing the Domain Layer

The first step in creating our RESTful web service is creating the domain layer. While our domain layer is very simple, we will soon see that it requires some very specific details to be accounted for in order to be properly used by the rest of our system. The first of these details is identity.

Three Productive Go Patterns to Put on Your Radar

Fri, 22 Sep 2017 04:01:00 GMT

By most definitions, with just 26 keywords, a terse spec, and a commitment to orthogonal features, Go is a simple language. Go programmers are expected to use the basic building blocks offered by the language to compose more complex abstractions. Over time, best-in-class solutions to frequently encountered problems tend to be discovered, shared, and replicated. These design patterns draw heritage from other languages, but often look and feel distinct in Go. I'd like to cast a spotlight on three patterns I use over and over again.

The Dependency Injection Pattern


Dependency injection (DI) is actually an umbrella term that can mean vastly different things depending on context. The core idea is this: Give or inject dependencies to a component, rather than have the component take dependencies from the environment. Beyond that, things can get a little complicated. Some people use DI to refer to dependency injection frameworks, typically a package or object into which you register dependencies and later inject them into components that use them, usually by some key schema. But this style of DI isn't a good match for Go, primarily because Go lacks the dynamic typing required to serve a literate API. Most DI frameworks in Go resort to stringly typed keys (meaning variables are often typed as strings), and rely on reflection to reify the dependencies to concrete types or interfaces, which is always a red flag.

Enum: Using the Name() and toString() Methods Correctly

Thu, 21 Sep 2017 20:01:01 GMT

The Java Enum has two methods that retrieve that value of an enum constant, name() and toString(). The toString() method calls the name() method, which returns the string representation of the enum constant. In listing 1, the value returned by calling the name() and toString() on an Animal.DOG constant method is DOG.

Listing 1: Animal Enum:

Java Command-Line Interfaces (Part 14): google-options

Thu, 21 Sep 2017 16:01:02 GMT

The GitHub page for google-options states that google-options is a "command line argument parsing library from the folks at Google (Java)." The page goes on to say, "This is the command-line arguments parser from the Bazel Project. The package has been split out into a separate jar for general utility." This blog post demonstrates applying google-options to processing command line options from Java code.

The example used in this post to demonstrate google-options is similar to the examples used in the earlier thirteen posts in this series on processing command line options in Java. This example supports two options: a required file path/name option expecting a String argument with that path and name and a verbosity option with no argument (its existence enables verbosity). Only the most relevant portions of the code will be shown in this post, but the full code is available on GitHub.

Testing Time-Based Reactor Core Streams With Virtual Time

Thu, 21 Sep 2017 10:01:01 GMT

Reactor Core implements the Reactive Streams specification and deals with handling a (potentially unlimited) stream of data. If it interests you, do check out the excellent documentation it offers. Here I am assuming some basic familiarity with the Reactor Core libraries Flux and Mono types and will cover how Reactor Core provides an abstraction to time itself to enable the testing of functions that depend on passage of time.

For certain operators of Reactor Core, time is an important consideration — for example, a variation of an "interval" function that emits an increasing number every 5 seconds after an initial "delay" of 10 seconds:

Creating a REST Web Service With Java and Spring (Part 1)

Thu, 21 Sep 2017 09:01:38 GMT

In the modern world of interconnected software, web applications have become an indispensable asset. Foremost among these web applications is the Representational State Transfer (REST) web service, with Java becoming one of the most popular implementation languages. Within the Java REST ecosystem, there are two popular contenders: Java Enterprise Edition (JavaEE) and Spring. While both have their strengths and weaknesses, this article will focus on Spring and create a simple order management RESTful web application using Spring 4. Although this management system will be simple compared to the large-scale RESTful services found today, it will nonetheless demonstrate the basic thought process, design decisions, and implementation tests required to create a Level 3 (hypermedia-driven) Spring REST web service.

By the end of this article, we will have created a fully functional Spring REST order management system. While the source code illustrated in this article covers the essential aspects of the order management system, there are other components and code (such as test cases) that support the main service that are not shown. All of the source code, including these supporting aspects, can be found in the following GitHub repository:

Project Comprehension: Understanding Java Projects Efficiently

Thu, 21 Sep 2017 07:01:01 GMT

Let's start with a bit of theory.

A modern Java application is a complex system that frequently operates as a node in a larger enterprise network. By the time a new developer joins the team, the project will likely have been in development for a couple of years and contain code contributions from dozens of developers, most of whom left the project long ago. Documentation is not always up-to-date and accurate, and only a few team members may have a comprehensive picture of the project (whom you'll have to catch for short Q&As in between meetings, code reviews, and emergency deployments). Actors Done Right

Thu, 21 Sep 2017 04:01:00 GMT

In our previous blog, we tried to explore the upcoming features of Java 9. So this time, we will focus on Scala. In this article, we will be looking into a new Reactive programming framework for Scala applications — fuses the best parts of functional Reactive programming and the Actor Model.
Reactors allow you to create concurrent and distributed applications more easily by providing correct, robust, and composable programming abstractions. Primarily targeting the JVM, the Reactors framework has bindings for both Scala and Java. 

Smoothing Out the Rocky Road to Personalization (Part 3)

Wed, 20 Sep 2017 20:01:01 GMT

dotCMS is an open source, enterprise Java CMS built from the ground up both to use open-source Java standards and to allow you to easily use your own Java code to override or extend dotCMS functionality. Although dotCMS was explicitly designed to make it easy to extend the functionality with your own Java code, dotCMS supports key personalization features natively, which minimizes the work needed to implement personalization on your site so you can focus your own coding efforts on truly sophisticated and custom needs. As we'll discuss shortly, some fairly demanding personalization features are available out-of-the-box, and you can start implementing fairly sophisticated personalization in dotCMS with as little work as changing the name of a single method in your server-side script.

Built-in Personalization Features

dotCMS ships with several very powerful personalization features that address the most common (and most difficult to implement) personalization tasks without having to write your own code:

This Week in Spring: Microservices, Reactive, and Kotlin

Wed, 20 Sep 2017 16:01:01 GMT

Hi, Spring fans! Welcome to another installment of This Week in Spring! This week, I've been visiting the Spring and Cloud Foundry teams at Microsoft (this time, in Redmond, WA), and then it's off to San Francisco, CA and San Antonio, TX to visit some customers. So, with that, let's get to it! I loved this Pivotal Engineering post on how we transitioned Pivotal Web Services, our hosted, multitenant installation of Cloud Foundry, to CredHub. CredHub is designed to store passwords, keys, certificates, and other sensitive information for a BOSH-managed environment. Spring Boot ninja Brian Clozel just announced Spring Boot 1.5.7 which includes scores of fixes, dependency updates, and improvements. Spring Integration lead and messaging ninja Gary Russell just announced Spring AMQP 2.0 RC1. The RC1 adds some minor improvements since the last milestone. Gary also announced that maintenance releases 1.7.4 and 1.6.11 are also available now. Not one to sit on his laurels, Gary also announced Spring for Apache Kafka 2.0 and 1.3 release candidates. Both releases support the Kafka 0.11.x.x client, while still supporting Spring Framework 4.3. The new release includes support for Spring Framework's transaction synchronization, a KafkaAdmin object, and correct handling of AckMode.RECORD. Also, these releases include several bug fixes. Spring Integration contributor Artem Bilan just announced Spring Integration 5. M7 and 4.3.12. The new release extracts out the reactive Spring Webflux adapter into a separate module, spring-integration-webflux. It also supports encoding message headers in the payload of a message for protocols — like AWS Kinesis, early versions of Apache Kafka, and TCP/IP — that don't support the notion of headers natively. Spring Integration lead Gary Russell just announced Spring Cloud Stream Ditmars/1.3 RC1. The new supports working with Kafka Streams KStream references as inputs and outputs to @StreamListener methods. Put another way: you can use Spring Cloud Stream to connect your application, declare all the bindings and so on, just as normal, and then write messaging code that taps Kafka Streams for interactive queries. Spring Boot committer Stéphane Nicoll just announced Spring Boot 2.0.0.M4. This release is the first to include the new web-runtime agnostic Actuator endpoints as well a raft of changes to simplify security configuration. Spring Session lead Rob Winch just announced Spring Session 2.0.0.M4. This release eases configuration for Spring WebFlux-based applications. It also supports a strategy for session ID resolution. Spring ninja Greg Turnquist just announced Spring Session MongoDB 2.0.0.M3. The new release builds on Spring Session 2.0.0.M4, Spring Data Kay RC3, Reactor Bismuth-M4, and Spring Framework 5.0.0.RC4. If you're using Spring Boot 2.0's spring-boot-starter-data-mongodb-reactive, then all you'll need is @EnableMongoWebSession! Spring Security lead Rob Winch just announced Spring Security 5.0.0.M4. This release is full of great new features including OAUth 2 / OpenID Connect support and a reactive integration for Spring WebFlux. Spring web guru Rossen Stoyanchev just announced Spring Web Flow 2.4.6. The release includes a security fix that affects default bindings. Spring Cloud Data Flow contributor Eric Bottard just announced Spring Shell 2.0.M1! The Spring Shell project surfaces a command component model to support developing custom shells. Spring Shell is the project that underpins, for example, the Spring Cloud Data Flow shell. This new release has a lot to[...]