Monday, March 31, 2025

Configure and use VSCode for Java web development

Embarking on Java web development often starts with choosing the right tools that streamline the coding process while enhancing productivity. Visual Studio Code (VSCode) has emerged as a powerful contender in this arena, offering a lightweight yet robust environment that Java developers can tailor to their needs. This guide aims to demystify the setup process and highlight essential extensions and configurations that make VSCode a potent ally in your Java web development journey.

Download

As an initial step, let's download VSCode from here:

https://code.visualstudio.com/download

Select a version based on your OS.


Collect the plugins

You can find a bunch of official plugins on the VSCode's website:

What do you find there?

  • Fundamental plugins
  • Spring Boot development
  • Gradle
  • Application Servers
  • Quarkus / Microprofile
  • Container management
You can install these extensions depending on your needs.

Tuesday, October 29, 2024

Simple Angular pipe for translation

Angular is a robust, front-end framework widely used for building dynamic web applications. Developed and maintained by Google, Angular provides a comprehensive suite of tools and features, from dependency injection to modular components, making it easier to create well-structured, scalable applications. One powerful feature of Angular is its ability to transform data directly within templates, thanks to pipes. Pipes are lightweight functions that can transform data, like formatting dates, currency, or other text content, in an efficient and reusable way.

Tuesday, September 17, 2024

Release and publish Maven artifacts on Github (2024)

In 2024 the mechanism of publishing Maven artifacts has changed, in this short article we'll discuss how we can release and publish a new Maven package from GitHub.

Thursday, September 12, 2024

Upload files to Firebase Hosting with Java

Sometimes you might need a Java based solution to upload files to Firebase Hosting to publish your recently generated static files. 

For instance, I use Firebase Hosting to store JSON data files generated by AWS Lambda functions (written in Java+Spring Cloud Function), and these files will be loaded into a mobile app.

This is when "firebase-hosting-api-java" open source library comes into the picture.

Wednesday, September 11, 2024

Spring Boot Testing tips: Check integration test existence for REST Controllers

Code quality and unit/integration testing is extremely important in software development, especially when a software gets larger and larger and it can be challenging to maintain which service has tests.

In this short article I'd like to present a way how you can validate that all of your application's endpoint has an integration test, but of course the method can be applied to other layers(e.g.: service) of the system as well.

Tuesday, September 10, 2024

Spring Boot request and response logging with sensitive data masking

 Enterprise Java (or any other) applications ofter requires logging of request and response bodies to investigate any upcoming issue. Logging these payloads are easy-peasy, but what should we do with any sensitive data inside those payloads? In this short article I'd like to share a solution with Spring Boot that is used in most large enterprise companies to log their incoming and outgoing messages in a secure and regulated way.

Wednesday, September 4, 2024

PostgreSQL instance on Windows with Docker Desktop

Running a database instance on your development environment is crucial, when you need a stable RDBMS for software development. Now we'll discuss how to install and configure a PostgreSQL instance with Docker Desktop on Windows.

Friday, January 1, 2021

How I automated my tasks with AWS

In this article I want to describe how Amazon Web Services helped me to automate my tasks.

I have an Android application which provides parking information for the users. A scheduled Android job checks for updates every 4 hours. Updates can be found in a static Json file hosted on Firebase Hosting. This Json file has a specific structure, but it differs from the source, where all data comes from. There is another file called config.json which contains the version number of the data. Although it's a cost-effective way to store minimum amount of data, but it was a pain in the ass to maintain it.

Tuesday, December 29, 2020

Create deployment to Firebase Hosting with Java

In this article I'd like to introduce "firebase-hosting-api-java", which is an API library for Firebase Hosting REST API written in Java 8. It supports all available V1Beta1 services, such as query the releases, delete deployment versions and so on. From version 0.4, theres a common service called createDeploy(), which is a combination of all deployment related function, and this is the recommended function for deployment.

Saturday, November 7, 2020

Useful Enterprise Java resources

 I've collected a huge list of useful URL's related to Java EE development. The collection is not complete :)

https://github.com/szrnka-peter/JavaEEResources

Monday, August 12, 2019

Proxy connection manager service for Spring Boot

In some special cases, like company security policies, our services are blocked by firewalls, the only chance to use the internet connection for our software is to setup an HTTP/HTTPS/FTP/etc. proxy connection. In this article I'll introduce my idea to solve this problem, when our webservices based on Spring Boot.

With this, we don't have to deal with system properties: (https://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html).

Wednesday, March 13, 2019

WorkManager in practice Part II: Periodical Workers and Constraints

In the previous article we discussed the One Time Workers, and the basics of WorkManager. In this tutorial we'll see how to create PeriodicWorkerRequest. We'll use the same project which is used in the previous part of this tutorial.

Android WorkManager in practice Part I: One Time Workers

WorkManager is an API to schedule deferrable, asyncronous jobs. This is one of the JetPack's best component and it's released only one week ago. Now I want to introduce it in a nutshell. To be honest, I've been waiting for a library like this FOR YEARS.

Sunday, February 10, 2019

Checking your Android application code with Lint

In Android application development it's a standard to check and improve the code and it's quality of your app. You can easily do it with the Android Studio's built-in function, Lint.

Monday, February 4, 2019

The "inconsistent layout" issue generated by Android Studio :D

I think this is funny, because the upcoming Lint issue is generated by the Android Studio, so now the question is, why the Android Studio generates a wrong code?


Monday, November 19, 2018

Spring Boot Slack integration

In this tutorial we'll discuss the integration of Slack into a Spring Boot 2 based web application.

Friday, April 20, 2018

HTTP based backend mock for Angular JS

AngularJS based frontend applications consume their data mostly from a backend system. But in some cases a working backend is not available for a frontend developer. Fortunately the Angular JS dev team provides a package for this situations: the ngMock. This package is generally used for test purposes, but it's easily to use for mocking as well. The corresponding documentation can be found here: https://docs.angularjs.org/api/ngMock This guide not covers how to install it, you can find it in the documentation of ngMock.

Ok, now I assume you installed ngMocks, and you want to start work with it. First, let's create a basic application, which'll consumes and displays recipes from a currently not existing backend. Create an empty, AngularJS compatible HTML file, name it "index.html".

<!doctype html>
<html lang="en" ng-controller="RecipeController as vm">
      <head>
        <meta charset="UTF-8" />
        <title>My recipes</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular-mocks.js"></script>
        <script>
            var Config = {
                mockEnabled : false
            };
        </script>
        <script src="js/app.js"></script>
        <base href="{{vm.contextPath}}">
      </head>
      <body>
        My recipes:
            <ul>
                <li ng-repeat="item in vm.recipeList">{{item.id}}. {{item.name}}</li>
            </ul>
      </body>
</html>


You can notice there is a highlighted part. This variable'll manage our mocks to be turned on or off. Now we turned off. Create an app.js in a folder called "js".

var app = angular.module("app", [])

  .constant("BACKEND_URL", "http://localhost:8080/")
  .constant("CONTEXT_PATH", "/")
 .service("BackEndService", function($http, $q, BACKEND_URL) {
        var vm = this;

         vm.getAll = function() {
            return $http.post(BACKEND_URL + "get_all");
        };

})

.controller('RecipeController', function(BackEndService, CONTEXT_PATH) {

   var vm = this;
   vm.recipeList = [];
   vm.contextPath = CONTEXT_PATH;

  BackEndService.getAll().then(function(response) {
      vm.recipeList = response.data;
  }, function(response) {
      console.error("error", response);
  });

});

var runMock = function($httpBackend, BACKEND_URL) {
    var allData = [{id:1, "name":"Onion soup"}, {id:2, "name":"Hungarian goulash soup"}];

    $httpBackend.whenGET(/home.html$/).passThrough();
    $httpBackend.whenPOST(BACKEND_URL + 'get_all').respond(function(method, url, data) {
        return [200, allData];
    });

};

app.run(function($httpBackend, BACKEND_URL) {
    console.debug("Application run", "mock = " + Config.mockEnabled);
    if(Config.mockEnabled === true) {
    }
});

angular.element(document).ready(function() {
    if(Config.mockEnabled === true) {
        angular.module('app').requires.push('ngMockE2E');
    }
    angular.bootstrap(document, ['app']);
});

Ok, try this code, how it works!


As you can see in the developer console, there's no response from the backend, which is correct, because we don't have a backend for our frontend. Now, we'll extend our code with some mocks. Open the app.js again, and write the following lines after the "app":

var runMock = function($httpBackend, BACKEND_URL) {
         var allData = [{id:1, "name":"Onion soup"}];
        // Templates
        $httpBackend.whenGET(/home.html$/).passThrough();

      $httpBackend.whenPOST(BACKEND_URL + 'getAll').respond(function(method, url, data) {
            return [200, allData];
        });
};

Modify the Config.mockEnabled variable in the index.html:

<!doctype html>
<html lang="en" ng-controller="RecipeController as vm">
      <head>
        <meta charset="UTF-8" />
        <title>My recipes</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular-mocks.js"></script>
        <script>
            var Config = {
                mockEnabled : true
            };

        </script>
        <script src="js/app.js"></script>
        <base href="{{vm.contextPath}}">
      </head>
      <body>
        My recipes:
            <ul>
                <li ng-repeat="item in vm.recipeList">{{item.id}}. {{item.name}}</li>
            </ul>
      </body>
</html>


Try to open again the webapp in your browser:


This error happened, because there's no incoming http post request.

Finally, extend the app.run with the recently added function:
app.run(function($httpBackend) {
    console.debug("Application run", "mock = " + Config.mockEnabled);
    if(Config.mockEnabled === true) {
        runMock($httpBackend, BACKEND_URL);
    }
});


Now let's try again. You'll see the list in the screen.Thats all! :)


Tuesday, January 2, 2018

Angular JS + Progressive Web App Service Worker

Nowadays AngularJS come less popular due the release of Angular 2+. But it's still a good choice for those developers, who don't want to work with TypeScript and NodeJS. In this tutorial I want to show you how to create an app, which is fully PWA friendly.

Thursday, December 7, 2017

Configure and use VSCode for Java web development

Embarking on Java web development often starts with choosing the right tools that streamline the coding process while enhancing productivity...