Posts

Spring Framework and ScheduledExecutorService - Load property files during startup

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In this post we see how to load property files during the application startup in an efficient way using Spring framework and ExecutorService which allows you to reload properties without server restart if any properties were changed. So let's get started. How to load Property files using Spring Every application is loaded using the deployment descriptor file web.xml. So in web.xml we need to declare the DispatcherServlet class with load-on-startup as 1. servlet-name can be anything. In our example it is called as bl (business layer). So during application startup, server tries to find the bl-servlet.xm l file. web.xml <servlet>     <servlet-name>bl</servlet-name>     <servlet-class>org.springframework,web.servle...

GraphQL Vs REST and What is GraphQl?

Image
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In this post we discuss little bit about GraphQl versus REST. My goal here is not to say REST is not good, use GraphQl. It's like more exploration of how we currently fetch data for apps right now and how GraphQl can help and what it does differently. So i want to start with a simple UI component and walk through about how we get data to populate that component. Let's take an example of Shopping cart. See the below picture We need lot of data to render the products in the above picture. So what kind of data exactly we need? If we see the picture we have Cart which hold some Products and each Product have title , descrition , price and bunch of other things and also the Product image which have Url of the image and it's metadata. ...

Install ojdbc driver to Maven local repository

Image
Install ojdbc driver to Maven local repository Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In recent days i have a been building the sample REST api using Spring Boot framework and Gradle. So in no time i jumped to the website Spring Initializer (https://start.spring.io/ ) immediatly and generated the project with required dependencies such as Web, Actuator, JPA and JDBC. I added the jdbc dataSoruce configuration properties to application.yml inorder to connect to Oracle database. See below spring: datasource: url: jdbc:oracle:thin:@[host_name]:[port]/[service_name] username: [user_name] password: [password]       driver-class-name: oracle.jdbc.driver.OracleDriver But once i start the Spring boot application it started complaining 'Can not load OracleDriver' and...

View events fired on an element in google chrome

Image
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies.  Recently i came across the situation where i need to find the event that has been triggered when i try to rotate the street view of google maps which is embedded in an iframe of the application. The real issue is the user could not rotate the street view so i need a way to find out what events are being triggered when i rotate the street view or whether any events are being triggered at all when i do it. So finally did google search and found out the following steps to do in google chrome - Go to More Tools -> Developer Tools or just press F12. - Click on Sources tab - On left hand side (or right side), scroll down to 'Event Listener Breakpoints' and expand tree - You find all the events. See the below picture - Select the ev...

Filter proxy addresses using SubnetUtils (Apache Commons Net 3.6 API)

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. This post illustrate how to filter out internal proxy addresses from the real client IP address whereas internal proxy address is represented in the form of CIDR notation in your application Example of CIDR notation of IP addresses. 10.0.0.0/8 - This represents range of IP addresses from 10.0.0.0 to 10.255.255.255 Try it out at  https://mxtoolbox.com/subnetcalculator.aspx In below example we use SubnetUtils of Apache Common Net 3.6 API to check whether particular IP address is in range of IP addresses which is represented in CIDR notation. We also illsutrate how to use Java 8 stream, Map, Filter along with the Predicate which is passed to Filter. SubnetUtils have a method called isInRange to check whether the particular IP address is in range of IP addresses...

Java 8 Hands-on

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. This post is all about different usecases which use Java 8 features which could be helpful for anyone.Please post your comments below or if you need to address any legacy code using Java 8 features. Java 8 practical examples Scenario 1 The following code excerpt explains the following scenario and also demonstrates the usage of Java 8 Stream, Filter and map. - Split the IP Address with respect to a delimeter (,) and store it into a Collection.  - Filter out proxy addresses from the resulting Collection. - Join the result with delimeter (,). public static String filteredIpAddresses(){  String proxyAddresses = "10.12.12.13, 10.12.12.14";  String ipAdress = "46.150.151.10, 46.150.151.11";  Set<String> ipAdresses =...

Linux command line - Locate Vs find

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In this post we discuss about locate and find commands and understand which one is more effective from one another. Also we discuss few important options available for locate command. It is important to note that both of these search commands works well but locate works in more convenient way as it uses more effective ways to quickly process search queries issued by the users. Locate Vs find locate  is one of the easiest and efficient way of finding the files in the file system. Though both  find  and  locate  will find out the files in the file system,  locate  works in more effective and fastest way in finding the file. locate command relies on mlocate database. It will look through that database which contains bits and parts...