Skip to main content

Posts

Showing posts from August, 2019

How to detect inactivity on web browser

This is something useful for apps which after a period of inactivity time you need to autosave things, clear localStorage, redirect to a logout URL and many other background things, so it does not matter if you are using VueJS or ReactJS you can add this code <!-- Script --> < script type= 'text/javascript' >   var inactivityTime = function () {     var time;     window .onload = resetTimer;     // DOM Events     document .onload = resetTimer;     document .onmousemove = resetTimer;     document .onmousedown = resetTimer; // touchscreen presses     document .ontouchstart = resetTimer;     document .onclick = resetTimer;     // touchpad clicks     document .onscroll = resetTimer;    // scrolling with arrow keys     document .onkeypress = resetTimer;     window .addEventListener( 'scroll' , resetTimer, true );     let count = 0 ;         function logout () {           //localStorage.clear();   //alert("You are now logged out.")         /

SpringBoot Multi Tenancy with JPA and JdbcTemplate - Dynamically reading RoutingDataSource from a data base table

The last 2 posts were about how to do a Multitenant mode with JPA and JdbcTemplate but the dataSources were hardcoded, what we are going to be doing in this post is to be able to read the dataSources from a database instead of being hardcoded. Let's supposed you've got a SaaS  Application and there are more and more customers who want to use your application, and you want to create a customer in an automatically way, with this post you are going to be able to do part of it, so that for doing a process like that you would need a DevOps for sure  when dealing with new DNS and  deploying a database structure to start with and may other things. what this post will cover is doing 2 SpringBoot Applications, the first one,it is a Dynamic Database Manager which is going to get the url , the tenantId , the username and password of the tenants. the second SpringBoot Application the  MultitenantJPA-and-JdbcTemplate  which we did in the previous post, the only difference is that its