Marc Nuri


Java 10
Introduction As you probably already know, Java 10 was released the past 20th of March following the new tight six-month release schedule. This version comes just after the Java 9 release on September 2017 and marks this past release obsolete. Same will happen to Java 10 on September this year, when the release of Java 11 will mark this one obsolete. Java 11 will be released as a long term support (LTS) version and will have a much longer lifespan, but until then, let’s take a look at some of the new features in Java 10. Time-Based Release Versioning Java […]

Java 10: Testing the new release


Java 8 Streams
Introduction In this post we’ll see how to use Java Streams introduced in Java 8 to obtain a Map from a List. Maps are data structures composed of a collection of key-value elements such that a key is unique within the collection. This allows us to perform searches to find an element with a given key really quickly, without the need to iterate through the full collection. It’s a really common situation that when we have to solve a problem where the start point is a list of elements, we need to convert this list to a map so that […]

Java 8 Streams: Convert List into Map


Spring-Data + MongoDB
Introduction Spring Data makes really quick and easy the process of working with data entities, offering a specific implementation for MongoDB. You can merely define queries by creating interfaces with methods following a naming convention or annotating them with @Query and Spring will automagically generate an implementation for you. Most of the times this is enough for simple CRUD and query operations and there is no need to define additional methods. This will allow you to get up and running really quickly avoiding to type boilerplate code. However, there are many times where this is not enough and the repository […]

Spring Data MongoDB: Custom repository implementation



Introduction When running a static code analysis tool or inspecting/analyzing your code from your IDE, you may have encountered the following warning regarding your @Autowired fields: Field injection is not recommended This post shows the different types of injections available in Spring and what are the recommended patterns to use each of them. Injection types Although current documentation for spring framework (5.0.3) only defines two major types of injection, in reality there are three; Constructor-based dependency injection Setter-based dependency injection Field-based dependency injection The latter is the one which the static code analysis tool complains about, but is regularly and […]

Field injection is not recommended – Spring IOC


docker as a linux systemd service
Introduction There are many different ways to orchestrate docker container management, initialization, deployment, etc. Even Docker brings its own vanilla tool and mode. There are also many other third party container orchestration tools such as Kubernetes, Rancher, Apache Mesos, etc. Docker daemon offers simple means to start, stop, manage and query status of deployed containers. In this post we’ll cover how to use a docker + systemd only approach to deploy containers as Linux services without the need for third party tools or complex deployment descriptors. In this tutorial we will show how to deploy Portainer as a Linux systemd […]

Docker container as a Linux system service


build.gradle script 4
Introduction In this post I’ll show you how to serve an Angular (>2) frontend application using a Java Spring Boot application as the backend and static page web server, and a Gradle script to perform automated build and deploy tasks both for Spring and Angular. Requirements The technology stack required for this tutorial is: Node.js Angular CLI Gradle The main goal is to achieve a npm install + build that integrates with Java’s gradle build and deploys the distribution files into Spring’s static resources directory. You could replace Angular CLI for any other Frontend build tool / framework such as React. […]

Angular + Spring Boot integration using Gradle



Spring + EclipseLink JPA 3
Spring Data JPA By default Spring uses Hibernate as the default JPA vendor. Although Hibernate is a good choice, some of us may prefer to use EclipseLink as it was supposed to be the reference implementation for the Java Persistence JSR. In this tutorial we will setup a Spring-Boot application to use EclipseLink with a PostgreSQL database, although it can be used with any other database. Fixing dependencies In order to use EclipseLink, we must remove Hibernate’s entity manager from the classpath in order to avoid problems. This is a matter of adding an exclusion to your application’s Gradle script or […]

Spring Data JPA + EclipseLink: Configuring Spring-Boot to use EclipseLink ...


Yet another IMAP syncing tool Two years ago when I first released mnIMAPSync, there were several mail syncing tools available. The problem with most of them was that when performing incremental E-Mail backups or migrations, some of the e-mails, mostly the ones that didn’t conform the RFC, were being duplicated in the mirror server. This was due to invalid headers and invalid or non-existent message-id. With no tool available in hand, I had to code one myself that did the job correctly. The main differences with mnIMAPSync and the other tools available is that mnIMAPSync checks several headers for each message and […]

Incremental E-Mail backup and migration using mnIMAPSync


Apache Tomcat - Apache HTTPd - mod_proxy front-end
Apache Tomcat and the World Wide Web Usually when running an application server, such as Apache Tomcat, you bind a connector directly on port 80. This way users visiting your web application will be able to navigate through your server just by calling your domain instead of calling your domain and special port (http://yourdomain.com:8080). If there is no option to bind a Tomcat connector on port 80 (some systems ban this functionality for security purposes), there are other ways to achieve this behavior such as setting a redirect on port 80 to port 8080 (Tomcat’s default, or any other) using IPTables or any other port […]

Running Apache Tomcat and Apache HTTPD on port 80 simultaneously



5
Since the release of NetBeans 6.0, BeansBinding (JSR 295) framework popularity has increased. Personally I’m using it now in all my projects. Ease of development and the increase of productivity are worth it. The counterpart is that this project looks dead and hasn’t been updated for more than a year now. Even more, recent news about Swing core is not very encouraging. In my opinion I believe that Sun’s budget is very limited and their recent javaFx has consumed all their resources in the past year. Bearing in mind that BeansBinding is now included in netbeans and that javaFx is […]

BeansBinding Performance (Issue 37)


2
Reading the contents of a file in Java is a very straightforward operation. The java tutorial explains completely how you can find your way to read different types of streams. However when you read an UTF-8 encoded file your fight will start. Most of the UTF-8 and UTF-16 encoded files contain a character at the beginning called BOM (byte-order mark). The BOM consists of a character  (U+FEFF) at the beginning of the stream used to define the byte order and the encoding of the stream. UTF encoded files may or may not contain the BOM. The problem with Java comes when […]

Reading UTF-8 encoded documents in java


Linksys WVC200 11
So you bought an IP camera and would like to store/see images from the camera using java. Recently I bought a couple of IP Cameras for testing purposes. I noticed that each IP camera has different surveillance tools and web interfaces. But most of them have in common that you can access the actual picture by entering an url in your browser. In this post I’ll show you how to see that image and store it using a very simple jav application. The camera I’ll use for the test is a LinkSys WVC200 “Wireless PTZ Internet Camera with Audio”. This […]

Viewing and storing images from an IP Camera