Java Lobby Announcements

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

What the Singleton Pattern Costs You

Sat, 2017-08-19 08:02

Do you use the singleton pattern? If not, I’m assuming that you either don’t know what it is or that you deliberately avoid it. If you do use it, you’re probably sick of people judging you for it. The pattern is something of a lightning rod in the world of object-oriented programming.

You can always use Stack Overflow as a litmus test for programming controversy. Someone asked “what was so bad” about singletons, and voting, responding, and commenting went off the charts. Most of those responses fell into the negative category. Outside of Stack Overflow, people call singletons evil, pathological liars, and anti-patterns. People really seem to hate this design pattern — at least some of them do, anyway.

Categories: Java

Oracle Opening Up Java EE

Fri, 2017-08-18 22:16

There's exciting news in the Java EE world! This morning, Oracle announced that Java EE will begin a transition to open sourcing. In case you didn't see it, here was the announcement from David Delabassee on The Aquarium:

We continue to make great progress on Java EE 8. Specifications are nearly complete, and we expect to deliver the reference implementation this summer. As we approach the delivery of Java EE 8 and the JavaOne 2017 conference, we believe there is an opportunity to rethink how Java EE is developed in order to make it more agile and responsive to changing industry and technology demands.

Categories: Java

From Nonsense Mathematics to Awesome Visualization

Fri, 2017-08-18 17:06

Visualization is always a good way to learn things faster and make sense of conceptual things such as algorithms, mathematical formulas, or physical phenomena. You may have seen a lot of visualizations created by JavaScript and some other tools other than Java. Surely, they were more beautiful in comparison with Applets or Swing-based applications. That was true in the era before JavaFX!

Nowadays, you can create fancier UIs with JavaFX more easily. In this post, I am going to show you how to convert an abstract mathematical formula to an awesome JavaFX 3D visualization.

Categories: Java

Integrating Unmanaged Services in Lagom With Scala

Fri, 2017-08-18 13:01

So, you want to integrate an unmanaged service in Lagom using Scala.

Let’s first understand what an unmanaged service is first, and then we will see how we can integrate an unmanaged service with our Lagom service.

Categories: Java

Java EE: Past, Present, and Future

Fri, 2017-08-18 10:01

In this article, you will find out about the history of the Java EE ecosystem: Where it came from and how it has changed over the last few decades. You will discover the major milestones in its development from J2EE 1.2 to its current incarnation Java EE 7 and we will peek into the future at what Java EE 8 has in store.

You will discover how to get involved with the development of the platform itself and how to join the JCP.org to make an even greater contribution. Find out about the Java EE Guardians and how you can support the development and growth of the platform.

Categories: Java

Code Smells: Deeply Nested Code

Fri, 2017-08-18 07:01

Or: I wants all your data, give it to me… my precious….

Continuing the series of code smells and what do about them, in this post, I examine some fairly innocent looking code that defies the obvious refactoring.  Although the code example itself is fairly trivial, it’s actually a symptom of a problem found again and again in this particular project: deep nesting of code. This can be for loops, if statements, even lambda expressions or inner classes, or combinations of all of the above.

Categories: Java

Akka Message Delivery: At-Most, At-Least, and Exactly-Once

Fri, 2017-08-18 07:01

This article is the first in a series of three articles that dive into the some of the interesting aspects of messaging within distributed systems environments. While the particular focus of these articles covers messaging within an Akka distributed actor systems, the concepts covered here also apply to messaging within other distributed systems, such as messaging within microservice systems.

Object and Actor Messaging Basics

In object-oriented programming languages, objects respond to method calls. Object method calls are a form of sending messages to an object. The object philosophy is that “everything” is an object. In Akka, with its implementation of the actor model, the philosophy is that “everything” is an actor. (The term “everything” is used loosely here. Of course, not everything is an object or an actor; the idea is that these are the dominant players in these software systems.) Both objects and actors react to messages. However, things quickly diverge from there.

Categories: Java

Concourse Caching for Java Maven and Gradle Builds

Thu, 2017-08-17 23:01

Concourse CI 3.3.x has introduced the ability to cache paths between task runs. This feature helps speed up tasks which cache content in specific folders — here I will demonstrate how this feature can be used for speeding up Maven- and Gradle-based Java builds.

The code and the pipeline that I am using for this post is available at my GitHub repo here.

Categories: Java

New RegEx Features in Java 9

Thu, 2017-08-17 19:01

I recently received my complimentary copy of the book “Java 9 Regular Expressions” from Anubhava Srivastava published by Packt. The book is a good tutorial and introduction to anyone who wants to learn what regular expressions are and start from scratch. For those who know how to use RegEx, the book may still be interesting to reiterate the knowledge and to deepen into more complex features like zero length assertions, back references, and the like.

In this article, I will focus on the few regular expression features that are specific to Java 9 and were not available in earlier version of the JDK.

Categories: Java

What Is javax.ws.rs.core.context? (Part 1)

Thu, 2017-08-17 13:01

The JAX-RS API provides a very handy mechanism to inject a range of useful resources, such as HTTP Headers, into your endpoint. The @Context annotation is an all-purpose annotation that injects instances of the following objects:

  • HttpHeaders -> HTTP header parameters and values
  • UriInfo -> Captures path variables and query parameters
  • SecurityContext -> Provides access to security related information for a request
  • ResourceContext -> Provides access to instances of resource classes
  • Request -> Precondition request processing
  • Application, Configuration, and Providers -> Provide information about the JAX-RS application environment
  • HttpServletRequest -> Provides access to the HttpServletRequest instance
  • HttpServletResponse -> Provides access to the HttpServletResponse instance
  • ServletConfig -> Provides access to the ServletConfig
  • ServletContext -> Provides access to the ServletContext

Let’s examine each in turn with working code examples.

Categories: Java

jOOQ Tuesdays: Let's Talk About Spring Data

Thu, 2017-08-17 10:01

Welcome to the jOOQ Tuesdays series. In this series, we’ll publish an article on the third Tuesday every other month where we interview someone we find exciting in our industry from a jOOQ perspective. This includes people who work with SQL, Java, open source, and a variety of other related topics.

I’m very excited to feature today Oliver Gierke, the Spring Data Project Lead at Pivotal with strong opinions on DDD and REST.

Categories: Java

9 Best Practices to Handle Exceptions in Java

Thu, 2017-08-17 07:01

Exception handling in Java isn’t an easy topic. Beginners find it hard to understand and even experienced developers can spend hours discussing how and which exceptions should be thrown or handled.

That’s why most development teams have their own set of rules on how to use them. And if you’re new to a team, you might be surprised how different these rules can be to the ones you’ve used before.

Categories: Java

The Best Java IDEs and What to Expect From Them [Infographic]

Wed, 2017-08-16 20:01

As you know, Java IDEs allow developers to write and debug Java programs with ease. A good IDE will have a number of features that help developers to write code easily. The features include debugging, easy editing, toggling of views, and so on.

Your choice of an IDE will depend on a number of factors — nature of the project, your team/organization’s preference, and so on. But there are some basic, non-negotiable requirements that every good IDE has to meet.

Categories: Java

Handling Custom Objects With JAX-RS SSE API

Wed, 2017-08-16 16:01

Information sent using JAX-RS 2.1 SSE support (in Java EE 8) does not only have to be of String type – it supports Java primitives (Integer , Long etc.), JSON-B and JAX-B annotated types as well as custom objects whose encoding process (Java object to on-wire format) is defined using a MessageBodyWriter implementation

Here is a simple example you can try out – no need to setup anything except Docker !

Categories: Java

This Week in Spring - August 15th, 2017

Wed, 2017-08-16 08:02

Hi Spring fans and welcome to another installment of This Week in Spring! It’s been a busy week! I started last week talking to a group of developers in North Carolina, then gave a VJUG presentation with Matt Raible in San Francisco, then spoke to developers in Saint Louis, then flew to New York City to shoot a video on continuous delivery for three days in a hot studio (over the weekend no less!) and now as I wing back to San Francisco I look forward to spending a blissful 14 hours on the ground before I’m off to Asia (Hangzhou, Shanghai, Beijing, Shenzhen, Hong Kong, and Singapore) for about four weeks! I’m not the only one who’s been busy, though! As usual, we’ve got a lot to cover this week so let’s get to it!

  • My friend and Spring Framework lead Juergen Hoeller gave a talk introducing reactive programming with Spring at Devoxx PL 2017. I hope you’ll watch this one if you watch anything.
  • My buddy Matt Raible and I did a presentation last week that looked at building progressive web applications and robust backend services with Angular and Spring Boot. Matt and I have given this talk a few times and it’s always fun. We do the talk live. I write the backend services and he writes the front-end client. I write the backend service using Apache Groovy, Kotlin, and Java. He uses TypeScript in the front-end. I think Matt’s the real hero here, of course, because even though I wrote 3 services, Matt ended up writing reams more TypeScript to get a client working! This video was crazy fun. I hope you’ll check it out.
  • Cloud Native Java is finally done and shipping! My friend Kenny Bastani and I wrote a little book for O’Reilly - Cloud Native Java - on how to build cloud native Java applications in terms of Spring Boot, Spring Cloud, and Cloud Foundry. The book took us two years, has been reviewed a zillion different ways by folks on the Spring team, has forwards by Spring creator Rod Johnson and Cloud Foundry legend James Watters. It’s not the worst book that you could buy, and I hope you’ll consider it. Thanks so much for your patience, Spring fans!
  • SpringOne Platform 2017, held in the Moscone center in beautiful San Francisco, CA, is in four short months! I’m going and I hope you will too. If you need more convincing, read this. If you’re already convinced then click that link for the ridiculous animated .gif that the marketing team put together!
  • I am absolutely loving the Spring Framework 5 reference documentation
  • I liked this pull-request. It’s by no means a definitive look at what will be supported or not supported, but the comments are interesting. It looks at what Spring Boot 2 might support HTTP 2 by default. Perhaps it’s a Java 9-only feature? Maybe there’s an appetite to explore some of the truly wretched options required to make it work on Java 8? If you have ideas or want to learn more, check out this issue!
  • Have you seen the new Spring Getting Started guide on messaging with Google Cloud Pub/Sub?
  • This Codecentric post looks at how to parse Java 8 LocalDate query parameters with a given date format.
  • Matthew Casperson looks at adding Spring Security to a Spring Boot-based project. Short and sweet - just the way it should be! Nice job Matthew!
  • This DZone RefCard is a pretty good introduction to using Google Cloud. I have really grown to like Google Cloud - it provides a lot of business-differentiating functionality all while being an amazing place to run Cloud Foundry.
  • My friend John Willis looks at different models - PDCA and OODA - for organizational orientation; how to figure out what to do next based on what’s happened. This has nothing to do with Spring, per se, and everything with building the right thing (with Spring).
  • This week I spent a few days in studio shooting more content - this time looking at continuous delivery in terms of the Spring and Pivotal ecosystems - with my friend (and Pivotal’s resident continuous delivery mad-scientist) Marcin Grzejszczak. All this to say we spend a non-negative number of minutes dissecting JSON Path in the video and it seemed a propos to remind folks of the JSON Path project itself and this post introducing JSON Path from the Baeldung blog.
  • The Okta blog is on fire since the Stormpath team-meld! So much great content, seemingly every day! Here’s a nice post on securing Spring Boot applications with Apache Shiro, for those that do that sort of thing.
  • Also from the Okta blog this last week, Matt Raible’s epic post that looks at how to secure Spring Boot and Spring Cloud microservices using JWTs, Juiser, and Okta. Nice job Matt!
  • Congratulations to the Reactive Streams teams who just last week announced that Reactive Streams 1.0.1 is here!
  • Auth0’s security with Spring Boot game is pretty on point, too! This week they released a useful look at securing Spring Boot applications with JSON Web Tokens (JWTs). Nice job!
  • Atomist co-founder Russ Miles looks at their collaboration tool’s ability to smoothly support a pull-request workflow. They do so in the context of an application (which happens to be written in Spring Boot) and while referencing Spring Boot in a post isn’t in of itself normally enough to be worthy of inclusion in these humble paragraphs, Atomist is generally so cool I’ll make an exception!
  • Congratulations to the Kotlin team at JetBrains on the new Kotlin 1.2.M2 release, looks terrific. It includes new APIs supporting mathematics that work in a uniform way across the JVM and JavaScript runtimes for Kotlin. Now’s a good time to kick the tires and try the new features, perhaps using the Spring Boot Initializr?
  • Redmonk has a great post on Spring Boot users New Relic and the Tesla - in the field who’ve recently published their use.
  • The YouTube playlist for the Seoul, Korea-based Spring Camp event and all of its wonderful Pivotal and Spring-centric content (in Korean!) is now available. This is a wonderful resource for Korean speakers!
  • This Portuguese-language book on Spring Boot - Spring Boot: Acelere o desenvolvimento de microsserviços looks like it could be a good read.
  • Bernd Rücker from the Camunda BPM team has put out a very cool example of integrating Camunda BPM with Spring Boot in a distributed application. The README is almost as interesting as the code itself, too. I love the discussion of testing which is something that’s typically missing from higher-level tools like workflow engines.

Categories: Java

Default and Private Methods in Interfaces

Tue, 2017-08-15 19:01

In this tutorial, we will look at default and private methods within interfaces. Default methods were added in Java 8, allowing methods to be added to an interface that comes with a default implementation that could be used, overridden, or ignored without causing issues to existing classes that have implemented an interface.

Private methods were missing when default methods were added, preventing code from being split out into smaller methods within an interface. This is something that was a bit off-putting to me, as if you had a default method that became a bit long, there was no way to tidy it up. So now that both default and private methods can exist within an interface, we can write methods like we are used to, although if you haven’t used default methods yet, then you will first need to get past the fact that there is now actual code living in an interface.

Categories: Java

How Memory Leaks Happen in Java Apps

Tue, 2017-08-15 13:01

One of the core benefits of Java is the JVM, which is an out-of-the-box memory management. Essentially, we can create objects and the Java Garbage Collector will take care of allocating and freeing up memory for us.

Nevertheless, memory leaks can still occur in Java applications.

Categories: Java

7 Reasons Converting COBOL to Java to Save Cash Is a Red Herring

Tue, 2017-08-15 10:01

Companies are having discussions about reducing CPU costs through the wholesale conversion of COBOL applications to Java. Inviting as it seems at first glance, this option of reducing costs may be short-lived and is a red herring because of unrealized issues and problems that occur when converting entire applications to Java.

This first of a series of blogs starts with an overview of what’s involved in converting COBOL to Java, with emphasis on pitfalls that may not be obvious. Some information about major conversion issues is presented and discussed at a high level with references to pertinent literature.

Categories: Java

An Intro to Spring Boot With Spring Data Mongo

Tue, 2017-08-15 07:01

Dark times are ahead for the Justice League with the formidable Darkseid coming over to conquer human kind. Batman, with the help of Wonder Woman, is on a quest to get the league together with one critical aspect missing — a proper Justice League member management system.

As time is not on their side, they do not want to go through the cumbersome process of setting up a project from scratch with all the things they need. Batman hands over this daunting task of building a rapid system to his beloved trusted Alfred (as Robin is so unpredictable), who tells Batman that he recalls coming across something called Spring Boot, which helps set up everything you need so you can get to writing code for your application rather than being bogged down with the minor nuances of setting up the configuration for your project.

Categories: Java

Understanding the Use Cases of Java Generics

Mon, 2017-08-14 23:01

Understanding general use cases of generics solves half of the problem. First things first, we should know what they are, why to consider them, and where they apply.

What Is It?

Consider a simple add method, seen below. You cannot pass long, float, or double types as inputs to this method, right?

Categories: Java

Pages