imsavva.com

Folder icon

Tags / Java

My plans for the future

Update 06.02.2021: still getting there and changing my plans according to the situation :)
Posted on
2017-08-16

Logging in ATG: how to send error reports to Elasticsearch and display them with Kibana

In this article, I'm going to share my experience with Oracle ATG logging system and such great tools like Elasticsearch and Kibana. Imagine that we have a big ATG-based project and our task is to store and list all the users who met (explicitly or not) errors. To solve this task we will add a new event listener to…
Posted on
2017-07-13

Using one DateFormat instance per thread with ThreadLocal

Here is a quick tip how to use DateFormat inside a ThreadLocal field. Why do we need that? The reason is the DateFormat class is not thread-safe but creating its instances is an expensive operation. So, this is kind of a workaround that creates only one instance of DateFormat per thread.
Posted on
2017-07-12

UnhandledExceptionHandler in Java: how to catch uncaught exceptions

In this short tutorial, I'm going to describe how to handle uncaught exceptions in threads. This can be done by: Using threadInstance.setUncaughtExceptionHandler() ─ for a specific thread Overriding ThreadGroup's uncaughtException() method ─ for a thread group Using Thread.setDefaultUncaughtExceptionHandler() ─ for all…
Posted on
2017-07-05

How to lookup a user profile from a global-scoped ATG component

This article describes how to look up a session-scoped user profile component from a global scope component that has no access to a DynamoHttpServletRequest object. To achieve this functionality, we will use a ThreadLocal field an ATG feature called Insertable Servlet . When a request object is created, it goes…
Posted on
2017-06-30

How to run a Groovy script from Java

showPostImage(984496268)

Uncaught exception: the image was stolen by a UFO

One of the ways of running a Groovy script from Java is using GroovieShell. First, add the groovy-all Maven dependency (consider using a fresher version): Next, create a class containing the main method. The Binding instance helps us to bind variables to the shell. These variables will be available for our script. We…
Posted on
2017-03-01

Parsing a date string to ISO8601 with Joda Time

showPostImage(637278502)

Uncaught exception: the image was stolen by a UFO

Recently, I faced a date conversion task: convert a string date "yyyy-MM-ddZ" (i.e. "1983-09-15+03:00") to the ISO8601 standard "yyyy-MM-dd'T'HH:mm:ss.SSSZ" (i.e. "1983-09-15T03:00:00.000+03:00"). I used Apache Joda time to convert date. First, add a Maven dependency in pom.xml To format a string containing date, I…
Posted on
2017-02-26