Subscribe: Javalobby - The heart of the Java developer community
http://www.javalobby.org/forumRSS/17.xml
Added By: Feedage Forager Feedage Grade A rated
Language: English
Tags:
boot  code  features  java  jdk  method  new  reactive  repeat string  repeat  spring boot  spring cloud  spring  string 
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 DZone.com



 



Introducing the Maven git commit id Plugin

Fri, 23 Feb 2018 14:02:02 GMT

Have you ever had the problem of not knowing which version of your application was deployed on, for example, a test environment? Or have you had to manually adapt version information for each release in order to make it available in an About-dialog? Then the Maven git commit id plugin has come to the rescue! In this post, we will build a Spring Boot application with a RESTful web service for retrieving versioning information. The only thing we will have to do is to configure the Maven git commit id plugin and create the web service. After this, versioning information is automatically updated during each build!

Create a Spring Boot Application

First, we create a basic Spring Boot application with a RESTful web service for retrieving manually entered version information. JDK9 and modules are used, so we will encounter some 'problems' along the way. But these will be tackled also!




Understanding Java Logging Hell: The Basics [Video]

Fri, 23 Feb 2018 11:01:01 GMT

When it comes down to logging in Java land, there's a ton of different logging libraries available: Log4j V1, Log4j V2, Commons Logging, Java Util Logging, Logback, Slf4j, and many more.

This episode will give you a quick intro on how to get started with logging in the Java world and what happens if you combine all of them in a single project and will also introduce the "Simple Logging Facade" for Java, SLF4j.




Java Code Style: Operators and New Lines [Snippet]

Fri, 23 Feb 2018 08:01:01 GMT

Last week, I discovered what helped me decide on what I have struggled with for a long time: whether to place operators such as &&||, or + on the same or next line.

When constructing boolean expressions or concatenating Strings, we might need to break long lines. According to the Google Java Style Guide, the break should come “before the symbol”, therefore:




JDK 10: FutureTask Gets a toString()

Fri, 23 Feb 2018 08:01:01 GMT

I've felt for a long time that, for most Java classes that have distinguishing attributes, developers should take the time to override Object.toString(), even if it's just with an IDE-generated implementation or using a library class such as Apache Commons Lang's ToStringBuilder. The overloaded Objects.toString() methods also make this easier than ever if one wants to implement toString by hand. The JDK class FutureTask, introduced with J2SE 5, finally gets its own toString() implementation in JDK 10.

Richard Nichols's 2012 post "How to get the running tasks for a Java Executor..." highlights the omission of a toString() method on the FutureTask class. He wrote:




Reproducible Builds in Java

Fri, 23 Feb 2018 05:01:01 GMT

When it comes to software, we look at source code to learn what an application will do when executed. However, the source code we read is not what will actually be executed by our computers. In the Java world, it is the Java bytecode that is produced by our compilers that eventually gets executed, normally after having been packaged into an archive. So when we are given code that has already been compiled and packaged, how can we verify that it is indeed the product of the source code we think produced it?

The answer to this is reproducible builds! A reproducible build is a deterministic function that, given our source code as input, will produce an executable artifact that is the same, byte for byte, every time it is run on the same input.




Selenium With Java: Google Search

Thu, 22 Feb 2018 21:01:02 GMT

In this tutorial, we will be exploring the basics of how to use Selenium with Java. We will use Selenium to open Google, search, and click a URL.

The code is available on GitHub.




The State of Java in 2018: Faster Updates and New Features

Thu, 22 Feb 2018 17:01:01 GMT

2017 was a turbulent year in the Java world. The long-awaited release of Java 9 brought a lot of changes and interesting new features, and Oracle announced a new release schedule for the JDK.




Rust for Java Devs – Creating Functions

Thu, 22 Feb 2018 14:02:12 GMT

In this post of Rust for Java Devs, we will look at creating functions in Rust. Functions in Rust do not differ that much from Java methods, but there are a few little differences. There is also the topic of Rust’s lifetimes compared to Java’s garbage collection that one could argue separates the two from each other a bit more, but for this post, I will focus on the structure of writing a function in Rust. Due to the similarities between the two, I believe most Java developers will have no problem in figuring out what arguments a Rust function takes, what it outputs, and where the output is returned from.

Let's start with a simple method in Java to get us warmed up.




JDK 10: Accessing a Java App's Process ID From Java

Thu, 22 Feb 2018 11:01:02 GMT

A popular question on StackOverflow.com is, "How can a Java program get its own process ID?" There are several answers associated with that question that include parsing the String returned by ManagementFactory.getRuntimeMXBean().getName() [but that can provide an "arbitrary string"], using ProcessHandle.getPid() [JEP 102], using Java Native Access (JNA), using System Information Gatherer And Reporter (SIGAR), using JavaSysMon, using Java Native Runtime — POSIX, parsing the results of jps (or jcmd) via invocation of Runtime.getRuntime().exec(String), and other approaches. JDK 10 introduces perhaps the easiest approach of all for obtaining a JVM process's PID via a new method on the RuntimeMXBean.

JDK-8189091 ("MBean access to the PID") introduces the RuntimeMXBean method getPid() as a default interface method with JDK 10. That issue states the "Problem" as: "The platform MBean does not provide any API to get the process ID of a running JVM. Some JMX tools rely on the hotspot implementation of RuntimeMXBean::getName which returns < pid >@< hostname >." The issue also provides the "Solution": "Introduced new API java.lang.management.RuntimeMXBean.getPid, so that JMX tools can directly get process ID instead of relying on the implementation detail, RuntimeMXBean#getName().split("@")[0]."




5 Things You Need to Know About Java 9

Thu, 22 Feb 2018 08:01:01 GMT

In the month of September 2017, Java announced the latest version of Java. It was released after more than 3 years after the release of Java 8, putting a major Java finally in the hands of developers.

Java 9 is a turning point in the release cycle for Java. Here in this post, we will discuss new developer features in Java 9. From an operational point of view, there are changes and enhancements to performance and security. Here, we will talk about five of the most exciting features in Java 9 to encourage you in adopting it.




Yet 4 More Techniques for Writing Better Java

Thu, 22 Feb 2018 05:01:01 GMT

Programming skills are like many other skills in life and require constant improvement: If we are not going forward, we are going backward. Standing still is not an option. In this third installation of the 4 Techniques for Writing Better Java series, we cover four important topics: (1) Validating arguments using methods provided by the standard Java library, (2) understanding the important Object class, (3) experimenting and learning by playing with jshell, and (4) finding and reading the most well-written code we can, in both books and in the source code of Java itself.

Some of these techniques are purely programming techniques that can help in a specific pinch while others focus on the tools and environment surrounding the Java ecosystem. Regardless of the individual nature of each technique, when applied with diligence and sound judgment, each can help improve the Java code written by developers, both novice and expert.




This Week in Spring: Spring Framework Updates and Dockerizing

Wed, 21 Feb 2018 17:01:05 GMT

Hi, Spring fans! Welcome to another installment of This Week in Spring! This week, I’m speaking at the San Diego JUG with Mario Gray on testing with Spring. Then, I’m off to the IBM Index conference here in San Francisco where I’ll be talking about building reactive microservices, and then it’s off to Devnexus in Atlanta, GA, where I’ll be talking about Kotlin and testing. I hope you’ll join me and say hi if you’re nearby. Stéphane Nicoll has just announced Spring Framework 5.0.4. Check out this whitepaper on building flexible Spring Cloud Data Flow data pipelines It’s now even easier to use Spring Cloud Stream from the Spring Initializr: now you need only choose a binder implementation (Kafka, or RabbitMQ) and then choose whether you want the implementation to be reactive or not, and you’re off to the races! Spring Cloud Task lead Michael Minella just announced Spring Cloud Task 2.0.0.M3. The new release includes smarter default behavior when an application closes, the ability to restrict tasks from running concurrently, and smarter integrations with Spring Batch I love this nice post by Abhishek Gupta from the Oracle developer blog on distributed tracing with Zipkin Check out the recording of the talk that Mark Heckler and I gave at last year’s SpringOne Platform 2017 to learn about building reactive Spring applications Apache Tomcat 9.0.5 has just been released I liked this post on the community SpringUni blog that looks at some of the new features in Spring Boot 2.0 The biggest problem with the various Docker build plugins is that they assume a stable API — a big mistake! The approach outlined in this post uses the docker commands themselves. This is a nice post that introduces HATEOAS, the pattern, and Spring HATEOAS (the technology) This post looks at how to pre-process requests created with Spring Cloud Feign. This is a short and sweet post that looks at creating a simple Spring Boot API from scratch. Friend of the community Aboullaite Mohammed has put together a Spring Boot starter that autoconfigure a Minio client. Minio is a high performance distributed object storage server, designed for large-scale private cloud infrastructure. Happy tenth anniversary to the Grails Framework! This blog looks at how to setup multiple MongoDB connections in a Spring Boot application. Société Générale have put together a Spring Boot starter that supports some of their more nuanced uses of RabbitMQ — maybe there’s something here for you? Spring and Cloud Foundry member Brian McClain put together a quick video showing how to install Pivotal’s function-as-a-service offering, Project Riff, on GKE. Baeldung have a nice post on using Dubbo, the Spring Framework-based RPC framework from Alibaba that’s served as the foundation for a large number of services at Alibaba (and other companies) for many, many years. We’re hiring! We’re looking for a product marketing manager. Want a front-seat tour on implementing reactive APIs with project Reactor? Check out this talk from two who’ve made the journey before, project Reactor luminaries Ben Hale and Paul Harris. Here’s another post on Dockerizing a Spring Boot application. I guess there are a lot of ways to approach this. Spring and Kotlin ninja Sébastien Deleuze has updated the stellar Spring Petclinic application with Kotlin. Good news everybody! MongoDB has support for transactions. Spring Data lead Oliver Gierke tweets, “I can smell a MongoDbTransactionManager… #SpringData”  InfoQ’s Richard Seroter hosts a discussion on event-sourcing and talks to, among others, Axon project lead Allard Buijze. Allard is a framework for building event-driven, CQRS-centric, event-sourcing aware [...]



What Can Reactive Streams Offer EE4J?

Wed, 21 Feb 2018 14:01:59 GMT

In my current role at Lightbend, I’m investigating and pursuing opportunities where Reactive Streams can make the lives of EE4J (the new Java EE) developers better. In this blog post, I’m going to share some of the ideas that we’ve had for Reactive Streams in EE4J, and how these ideas will benefit developers.

Reactive Streams was adopted by the JDK in the form of the java.util.concurrent.Flow API. It allows two different libraries that support asynchronous streaming to connect to each other, with well-specified semantics about how each should behave, so that backpressure, completion, cancellation and error handling is predictably propagated between the two libraries. There is a rich ecosystem of open source libraries that support Reactive Streams, and since its inclusion in JDK9, there are a few in development implementations that are targetting the JDK, including the incubating JDK9 HTTP Client, and the Asynchronous Database Adapter (ADBA) effort that have also adopted it.




JDK 10's Summary Javadoc Tag

Wed, 21 Feb 2018 11:01:01 GMT

JDK 10 introduces a Javadoc tag {@summary} via issue JDK-8173425 ("Javadoc needs a new tag to specify the summary."). This new tag allows the developer to explicitly specify what portion of the Javadoc comment appears in the "summary" rather than relying on Javadoc's default treatment looking for a period and space to demarcate the end of the summary portion of the comment. JDK-8173425 states, "Currently in javadoc the summary (firstsentence) of an element is deciphered by a dot-space rule, or if required using BreakIterator." It adds that it can be confusing to know what that implicitly selected summary sentence will be.

The easiest way to see {@summary} in action may be through Javadoc examples. The next code listing shows four methods with similar Javadoc comments, two using explicit {@summary} tags and two relying on implicit Javadoc summary construction.




Spring DI Patterns: The Good, The Bad, and The Ugly

Wed, 21 Feb 2018 08:01:01 GMT

Spring developers will be familiar with its powerful Dependency Injection API. It allows you to declare @Beans that Spring then instantiates and manages. Any dependencies between these beans are then resolved by Spring and injected automagically.

Three Annotation-Based Injection Patterns

There are three ways Spring lets you declare the dependencies of your class using annotations:




5 Hidden Secrets in Java

Wed, 21 Feb 2018 05:01:01 GMT

As programming languages grow, it is inevitable that hidden features begin to appear and constructs that were never intended by the founders begin to creep into common usage. Some of these features rear their head as idioms and become accepted parlance in the language, while others become anti-patterns and are relegated to the dark corners of the language community. In this article, we will take a look at five Java secrets that are often overlooked by the large population of Java developers (some for good reason). With each description, we will look at the use cases and rationale that brought each feature into the existence and look at some examples when it may be appropriate to use these features.

The reader should note that not all these features are not truly hidden in the language, but are often unused in daily programming. While some may be very useful at appropriate times, others are almost always a poor idea and are shown in this article to peek the interest of the reader (and possibly give him or her a good laugh). The reader should use his or her judgment when deciding when to use the features described in this article: Just because it can be done does not mean it should.




Kotlin’s java.util.Optional API Equivalents

Tue, 20 Feb 2018 21:01:02 GMT

Kotlin truly shines when it comes to avoiding excessive bureaucracy of classical Type-Driven approaches to optionality.

Let’s see how its native approach to null-safety compares to java.util.Optional.




Is String#repeat Coming to Java?

Tue, 20 Feb 2018 17:01:59 GMT

JDK-8197594 ("String#repeat") includes the following it its "Description": "A String method for repeating sequences of characters has been long requested with no follow through." Evidence of this interest in a method on the String class for repeating sequences of characters can be found in JDK-8197594's "Issue Links" that include JDK-8055862 ["Provide a String repeat method"] and JDK-6984084 ["(str) n times repetition of character constructor for java.lang.String"]. Both of these linked issues describe motivations for having such a method in the String class. Further evidence includes online questions such as Simple way to repeat a String in Java, How to repeat string “n” times in Java?, What is the simple way to repeat a string in Java?, and How do you repeat a string n number of times in Java programming?

Guava provides this desired behavior via its Strings.repeat(String, int) method and Apache Commons Lang provides this functionality via its StringUtils.repeat(String, int). It's also likely that this functionality has been implemented hundreds of times or more in individual projects. The availability of a standard java.lang.String.repeat(String, int) method could replace all of these.




An Intro to Spring 5's Webflux Framework [Video]

Tue, 20 Feb 2018 11:01:01 GMT

For those who aren't aware, Spring 5 got a new reactive web framework called Spring Webflux. But what is reactive programming? What are non-blocking applications? How can you get started with it?

In this practical screencast, you will learn how to get started with Spring 5 Webflux, which means you'll learn the perfect project setup, what libraries you need, and then get to write a simple REST Controller that serves as a base for more advanced reactive concepts.




Using the Composite Pattern to Turn the Lights on

Tue, 20 Feb 2018 08:01:01 GMT

Design patterns are probably one of the most popular topics in the Java blogosphere. Yet many times, the examples used to illustrate the different design patterns are not very engaging. To remedy that, this post explains the Composite pattern in a fun way.

Since there are already many descriptions of this pattern out there, we will not repeat it again. The only thing to remember is that the Composite pattern is used to apply a recursive action on a tree structure.