Home

Wednesday, November 8, 2023

SpringBoot: Adding custom properties to ApplicationContext dynamically


While building a Spring Boot app, we often get into a situation where we need to dynamically add the properties to the ApplicationContext during application startup. Spring Boot provides an intuitive interface named ApplicationContactInitializer that can be implemented to programatically initialize the ApplicationContext or to add additional property sources to the ApplicationContext.

Below is a sample implementation of this interface to add a application run id to the application context.

    public class CustomApplicationContextInitializer implements ApplicationContextInitializer {
        private static final Logger log = LoggerFactory.getLogger(CustomApplicationContextInitializer.class);

        @Override
        public void initialize(ConfigurableApplicationContext applicationContext) {
            final ConfigurableEnvironment environment = applicationContext.getEnvironment();
            final MutablePropertySources propertySources = environment.getPropertySources();
            var dynamicProperties = new HashMap();
            dynamicProperties.put("run-id", UUID.randomUUID().toString());
            propertySources.addLast(new MapPropertySource("dynamic-properties", dynamicProperties));
        }
    }


Thereafter, we can register the CustomApplicationContextInitializer to the SpringBootApplication before calling it's run method as below:

    @SpringBootApplication
    public class Application implements CommandLineRunner{
        public static void main(String[] args){
            SpringApplication application = new SpringApplication(Application.class);
            application.addInitializers(new CustomApplicationContextInitializer());
            application.run(args);
        }
    }

Now, the run-id added during the ApplicationContext initialization will be available as part of the ApplicationContext.

Saturday, July 18, 2009

Cleaning the Registry

Whenever we talk about registry, REGEDIT.exe is the first thing that comes in our mind. But after entering this database and seeing the type of entries we are deterred to start the cleaning process. So here I will be telling how to go about the cleaning process.

There are basically two methods for cleaning the registry. One is manually cleaning the registry using regedit and second is using a Registry cleaner software. As you install and remove software many software leave their impression on the registry and the registry keeps on growing bigger. As a result your system slows down and you may get unnecessary errors. To get rid of this frustration you got to clean your registry.

Manually cleaning the Registry

Registry is a database that holds the configuration of your computer. It allows you to perform many tweaks your operating system does not allow directly. I have discussed many of them in the earlier posts. A Registry can be edited using a registry editor. Windows has been shipped with a default registry editor named “Regedit”. To open regedit go to Start>Run , then type regedit. You’ll reach a window as shown :










Before you touch any part of the registry remember to backup your registry. For that you can either use System Restore or simply select the key you are about to modify in regedit and click File>export. This will create a backup registry file and double clicking this file will restore the value of the key you were trying to manipulate.

Registry editors depict a logical hierarchy of configurations. Registry is divided into six main parts called hives. Each hive has keys and sub keys that have some value assigned to it. These values can be either a DWORD, string or Binary. DWORD stands for double word, string stores values that are of string type and Binary stores the values in terms of 0’s and 1’s.

The six hives store different configuration as follows :

  • HKEY_CLASSES_ROOT contains information relating to the user interface, file association mappings and OLE(Object linking and embedding) information.
  • HKEY_CURRENT_USER contains information related to the current user of the system.
  • HKEY_LOCAL_MACHINE contains information that is common to all the users of the system
  • HKEY_USERS contains information about individual users, each of which is identified by a Security ID.
  • HKEY_CURRENT_CONFIG contains all the information that is collected when the computer boots up. This information is not stored in secondary storage but is generated every time the computer boots up.
  • HKEY_DYN_DATA contains information related to the plug and play devices. The DYN indicates that this information is dynamic which changes as new device is attached.

So with the above basic information you can go on with editing your registry to solve the specific problems you might be facing. But remember to backup the registry.

Using Registry Cleaner Software

If you do not want to take any risk with your Operating System, you can go safe by using a Registry Cleaner Software. These software scan your registry to search for missing references to files etc. They safely bring your system back to the normal working condition. You can clean your registry here. This method is best suited for a novice who is not willing to spend few of his precious hours reinstalling the Operating System.

Some of the famous Registry Cleaners available online are :

Thursday, October 4, 2007

WiMax Technology

WiMax (Wireless Interoperability for microwave access) is a wireless digital communication system based on IEEE 802.16 standards. It can be used for transmitting data from a fixed station as well as a mobile station. It can provide wireless access upto 50 km for fixed stations and 15 km for the mobile ones.
Among the main uses of WiMax comes the internet connectivity for laptops. In a radius of upto 10 km WiMax can give access rates of upto 40Mbps per channel. In India(a south asian fast developing economy), WiMax network is being setup in Chennai, a city in south of India. This technology if spreads out to the entire country can benefit the 1 billion citizens of India, especially the villages of India where still for many using internet remains a dream.

Associated Links :

Monday, October 1, 2007

CDMA or GSM

In the present day scenario the GSM (Global System for mobile communication) is dominating in most parts of the world, but rapidly the CDMA (Code Division Multiple Access) is taking over it because of the additional advantages it provides.
In CDMA there is no division of frequency band unlike GSM which assigns a specific frequency to each user. Each user in GSM is identified using the SIM(Subscriber Identity module) card which stores the service subscriber key used to identify the user.

On the left is shown a CDMA phone by Tata Indicom.
CDMA employs spread spectrum technology in which the energy generated in a particular bandwidth is spread in the frequency band. This frequency band is used for all the users. It provides better bandwidth for the voice and data transmission over the network and hence increases the number of people that can be connected at any given time. This means using it you will hear less of those irritating("Network is currently busy") messages. Surely CDMA provides high speed services.
But inspite of all these benefits of CDMA we cannot forget the advantage given to SIM card owners to easily change their mobile phones.

Friday, September 28, 2007

Removing the hand icon displayed below shared drives

Whenever we share any of our harddisk drives a hand icon appears below that drive. Surely, a nice way to show that it is shared, but when all your drives are shared, the same hand starts annoying us. In order to get rid of this hand we have to perform a registry tweak.
Open regedit ( Go to start>Run and type in regedit) .
  • Browse to the location HKEY_CLASSES_ROOT>Network>Sharing Handler.
  • Open the default icon by double clicking it.
  • In the value data textbox the default value is ntshrui.dll.
  • Erase this value to leave the space blank.
  • Restart your PC and see the change in the icon of your shared drives.

Thursday, September 20, 2007

Disabling Windows Error Reporting

It's pretty much frustrating when windows prompts you to report the errors to the microsoft website. You can stop this reporting if you like by following some simple steps.
  • Open the control panel
  • Double click on the System icon
  • Click on the Advanced tab
  • Click on the button named "Error Reporting"
  • Now on the window that appears click disable error reporting as shown.

Well now you can fell free of those irritating error reporting messages and enjoy your work on the PC.

Sunday, September 16, 2007

Renaming the Recycle Bin

When it comes to playing with your system settings, there is no better place than regedit to get your hands dirty on. Regedit the short for registry editor allows us to make changes in the windows settings pretty easily. Changes like changing the boot up screen, wallpapers, security related issues can easily be tackled with through the registry.
When you right click on the recycle bin unlike other icons, the rename option is not displayed in the pop-up menu. But this doesn't mean it can;t be changed. Well now it's time to open up regedit. For that go to the Start>run. Then type regedit. You will be presented with a screen as shown below :










Now go to the location "HKEY_CLASSES_ROOT/CLSID/{645FF040-5081-101B-9F08-00AA002F954E/ShellFolder/}" by expanding the '+' signs.
Once you reach there double click the "Attributes" icon.
Then change the value data from "40 01 00 20" to "50 01 00 20".
Now double click "CallForAttributes" icon and change the value data to 0.

Rejoice! Now you can jump back to your desktop and right click the recycle bin to see the rename option. Click it and name the recycle bin to whatever you want.

Some tweaks you can perform (Always remember to create a backup of your registry before performing any of the registry tweaks) :

Wednesday, September 12, 2007

Auto shut down of the computer for firefox download

After working for hours to find the correct matter to download, surely one does get exhausted and does need some rest. But after all this if you have to wait for the download to finish, frustration is an obvious outcome.
For all you guys who work on firefox most of the time, there is a Add-on provided by firefox which allows you to turn off your computer once the list of download items finishes. It adds an icon to the status bar and the download manager, which enables you to automatically shut your computer down once the download has finished. To download this add-on click here.

Sunday, September 9, 2007

Creating a Bootable Pen Drive

All of us must have encountered the situation where our very own PC refuses to boot whatever the problem may be. It is here that a USB drive containing bootable XP comes in handy. You can install a bootable XP on to the pen drive along with the safety tools such as antivirus etc. to fix the problem.
But this cool way might not shine the light equally on everyone. In order to boot from a flash drive your system should be only around two years old. An alternative to this is that you upgrade your BIOS. Also the flash drive you use should be of a minimum of 256 Mb size to hold windows XP. Also a maximum size of 2GB is permissible.
So now you have the pendrive and an approprite BIOS. So get started with creating a bootable pen drive. For that you need to have a USB Disk storage format tool which is available for free. Now you can start formatting your pen drive. Then to make it bootable copy the following files on to the pen drive : Boot.ini, NTLDR, and NTDETECT from root directory of the boot drive.
Now you will be needing a software named BartPE that helps you install windows on a minimal space. After you have downloaded it follow the steps to copy the Windows files.
After you are done with all this you are having your very own flash drive ready to boot your Windows XP2.

Associated links :

Thursday, September 6, 2007

NTFS (New Technology File System)

Whenever you are formatting your harddisk, the option for either a NTFS or a FAT file system pops up. Fine you know NTFS is new and better but how.
A file system is a part of the operating system that determines how files are named, stored and organized on a volume. FAT (File allocation table ) was the standard file system developed by microsoft for the MS-DOS. This was used in all the windows till the Windows ME. Then came the NTFS (New Technology File System) which almost replaced the FAT file allocation.
The NTFS allows greater reliability, security, greater volume size etc. In NTFS all the characteristics of the file (like filename, date of creation) are stored as metadata. NTFS utilizes the power of B+ trees to index file system data. The master file table is used to store the metadata about every file present on the volume. In this system greater security is provided as we can restrict access of files to authorized users.
These features of NTFS sure does give them a reason to be chosen while opting for the type of file system for formatting.

Associated topics :

Monday, September 3, 2007

Rules for Creating a Relational DBMS

So all you programmer's out there think just implementing a database in the form of tables makes your database a relational Database (RDBMS). Well then E.F. Codd challanges this thought of yours. Edgar F. Codd was a british computer scientist who has given a set of 12 rules necessary for creating a relational database. Most of the database management systems like Oracle, SQL server etc. incorporate most of these rules. The rules are :

(1)Information Rule:
All information in a relational database including table names,column names are
represented explicitly by values in tables. Knowledge of only one language is necessary to
access all data such as description of the table and attribute definitions ,integrity
constraints,action to be taken when constraints are voilated,and security information.

(2)Guaranted Access Rule:
Every pieceof data in the relational database,can be accessed by using a
combination of a table name, a primary key value that identifies the row and a column
that identifies the cell.The benefit of this is that user productivity is improved
since there is no need to resort to using physical pointers addresses.Provides
data independence.

(3)Systematic treatment of Nulls Rule:
The RDBMS handles that have unknown on inapplicable values in a predefined fashion.
RDBMS distinguishes between zeros,blanks and nulls in records and handles such values in
a consistent manner that produces correct answers,comparisions and calculations.

(4)Active On-Line Catalog Based on the Relational Model.
THe description of a database and its contents are database tables and therefore
can be queries online via the data language.The DBA's productivity is improved since
changes and additionsto the catalog can be done with the same commands that are
used to access any other table.All queries and reports can be done as with other tables.

(5)Comprehensive Data Sublanguage Rule:
A RDBMS may support several languages,but atleast one of them allows the user to do all
of the following:define tables view,query and update data ,set integrity constraints,
set authorization,and define transactions.

(6)View Updating Rule:
Any view that is theoretically updatable,if changes can be made to the tables that
effect the desired changes in the view.Data consistency is ensured since changes
in the underlying tables are transmittedto the view they support.Logical data
independence reduces maintenance cost.

(7)High Level Inserts,Update and Delete:
THe RDBMS supports insertion,updation and deletion at a table level.With this the
RDBMS can improveperformance by optimizing the path to be taken to execute the action
Ease of use improved since commands act on set of records.

(8)Physical data Independence :
The execution of adhoc requests and application programs is not affected by changes
in the physical data access and storage methods.Database administrators can make
the changes to physical acccess and storage methods ,which improve performance
but do not changes in the application programs or adhoc requests.This reduces
maintenance costs.

(9)Logical data Independence:
Logical changes in tables and view such asadding/deleting columns or changing
field lenghts do not necessitate modifications in application programs or in the
format of adhoc requests.

(10)Integrity Independance:
Like table/view definitions ,integrity constraints are atored in the
on-line catalog and therefore can be changed without necessitating changes
in application programs or in the format of adhoc requests .
The following two integrity constraints must be supported.
(a)Entity Integrity:
No component of primary key is allowed to have anull value.
(b)Referential integrity:
For each distinct non-null foreign key value in a relationaldatabase,
there must exist a matching primary key from the same range of data value.

(11)Distribution Independence:
Application programs and adhoc requests are not affected by changes
in the distribution of the physical data.

(12)Nonsubversion Rule:
If the RDBMS has a language change that accesses the information
of a record at a time,this language cannot be used to by-pass the
integrity constraints.Inoreder to adhere to this rule the RDBMS must have an
active catalog that containsthe constraints must have a logical data independence.

Thursday, August 30, 2007

Minicomputers

Minicomputer is a computer which is having a size in between the mainframe computers and the microcomputers.
These minicomputers behave as a stand-alone computer with a number of terminals attached to it. They were small computers ( compared to the then existing mainframe computers ). This had been achieved with the introduction of transistors and core memory technologies.
The magnetic core memory or the ferrite core memory is a kind of computer memory. It stores information in magnetic ceramic rings which can store a bit(0 or 1) of information.

These rings are arranged in a grid form as shown.
But the minicomputers still had few drawbacks like large size, expensive to buy which gave way to the invention of the microcomputers which is visible in almost every household now a days.

Saturday, August 25, 2007

Placing a seperate hibernate button on the shut down screen

Every time you need to hibernate your OS, you need to put one of your fingers to work in pressing the shift key. Thank god there is an alternative. We can place a hibernate button alongside the standby button by performing certain tweaks in the registry.
Open regedit ( click on start > run. Then type in regedit), create a key as shown below, "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Shutdown". Then under this key create a dword value "ShowHibernateButton" and set it's value to 1 as shown "ShowHibernateButton" = dword:00000001 .
Rejoice now you can just check out your work by jumping on to the shut down screen and notice the change.
Now you will see four buttons appearing on your shut down screen. Now you will not have to bother your finger ever time you put your PC on hibernation.

Wednesday, August 22, 2007

Working Of LED's

LED's or Light Emmitting diodes are semiconductor devices which emit light when electricity is passed through them. An LED consist of a p-n junction in which electricity is passed through it in forward biased mode as shown in the figure. Also a load resistance is applied to it so that the excess current does not harm the LED.
LED's are available in various colors to suit your need like red,blue,yellow,white etc. But the white and blue LED's are particularly costlier compared to the other colored LED's.
These LED's are tiny bulbs which can be used for various purposes like in calculators. Most significant use is the one in seven segment display, the one we see on our watches. These small bulbs are arranged in a particular pattern to create a beautiful display of a number.
There also exist the bi-colored and tri-colored LED's. So just check out the various available LED's and create something innovative out of it.

Associated Links :

Sunday, August 19, 2007

Plasma Display

We all want to have a Flat screen, large size TV hanging in our living room. These flat screen televisions use either the LCD display or the Plasma display technology. I have already talked about the LCD display in my last post. Here I will stress on the Plasma display.
A plasma display consist of two glass panels holding an inert(that is, the gases do not react) mixture of noble gases(neon and xenon). These gases are exited by electricity converting them into plasma(ionized gas). This plasma then excites the phosphors to emit light which in turn lights up the pixels.
The pixel is a point which make up the entire screen. This pixel is in turn divided into a three subpixels. In a Plasma screen each subpixel can produce millions of colors. With the combination of all such pixels we get the so-called perfect picture quality.

Associated Links :

Thursday, August 16, 2007

Technology behind LCD

LCD(Liquid crystal display) is a technology which is now fast being used in the monitors for the desktop PC's and already being used in the laptops. LCD consist of a thin liquid crystal gel sandwiched between two thin polarized materials. This gel is divided into small dots called as pixels. In order to darken a pixel the pixel is polarized 90 degrees to the polarizing screen. For a bright pixel the polarization is 0 degrees.

Related Topics :
Cleaning an LCD TV
Free LCD TV

Monday, August 13, 2007

Scheduling a computer for shut down

The computer is downloading a heavy file, and you are getting late for the work. If this is the situation we certainly have to schedule the computer to shut down after some time. Here, the Task Scheduler( you can find it under Start>Programs>Accessories>SystemTools ) comes in handy.
To shut down the system at a specific time
  • Open Task Scheduler and double click Add Scheduled Tasks





  • A wizard opens, click next. You will be presented with a list of programs you can schedule to run.
  • Click on browse, locate the %SystemRoot%\System32 folder. Then find the file named Shutdown.exe and click open.
  • Specify a name for the task and when do you want the task to run. Click next.
  • Specify the starting date and time and click next.
  • Then you will be prompted to enter the user name and password. Supply the information and click finish.
  • Now you are done with the process of scheduling the computer to shut down and can go to your work without worrying about terminating the download.
You can also visit the Task scheduler log in case you want to see the performance of the task scheduler.

Friday, August 10, 2007

Get your voice on Air ( Internet Radio )

You like listening to radio, so do I. But how many of us have ever tried to broadcast our voice over the internet radio. There are a few websites that allow us to create our own online radio station and broadcast our voice. One such radio broadcaster is Live365.
Live365 is an internet radio provider in which members can create their own radio station and air your voice over it. You can also listen to other such members you have uploaded their voices. To get such access you have to purchase the "Broadcaster's" membership. Different packages are available to choose from depending on your requirements. In the very basic package, one can upload an MP3 file created by him, which will be relayed on the internet. Advanced members can upload the music at their home by getting handy a microphone. Get a quick access to Live365. So, if you think you play an instrument good enough or your voice is worth listening to, just start broadcasting your voice and see fame coming your way.

Tuesday, August 7, 2007

Recovering files deleted from the Recycle bin

Have you lost an important file from your hard drive, then this content is for you. Whenever a delete a file using Shift+delete or deleting the files in the recycle bin, most of us consider to be that file a thing of past. But we can rejoice for it can still be recovered.
Whenever we delete a file using the above said methods, the file is not deleted rather that file is removed from the list of files in the folder and the memory area in which the file is stored is available to windows to write something else. So, longer the period since when you have deleted the file, lesser will be the chance of it being recovered.
Defragmentation frees the space occupied by such deleted files, so if you have defragmented your hard-disk recently, you can forget the idea of recovering your file. There are many tools that help you recover your files, some are paid and some for free. So here is one such free tool named "Restoration". It helps you recover the deleted files with ease. Just give it a try.

Saturday, August 4, 2007

Wireless Monitor for your desktop

So you have a wireless mouse and keyboard combo sitting on your computer table, but do you think that's ample to call your PC a wireless one. Well, give yourself a second thought. Still you have the monitor along with it's wires eating up the space and look of your PC. So here is how to make your desktop PC completely wireless.
For the same you need a wireless monitor connector. Many such gadgets are available like WID101 from Teq Gear, Avocent LV3500W longview wireless extender, and many more.
A pic of the WID101 is shown below :
This device connects the DVI port situated in your PC with the one on your monitor over an encrypted network. It can provide you a resolution of 1366*768.
But in order to have this wireless connectivity you need to have a DVI(Digital Video Interface) port. This port is mostly available in the flat panel LCD monitors and some of the CRD(cathode ray display) monitors.
The DVI port looks similar to the following figure :
Well this technology does come for a price(around $1000), but it is worth a buy if you are wretched by the amount of wires on your table.