Iterator Design Pattern
Posted by Bharat Sharma in behavioural design patterns, Core Java on March 8, 2020
Iterator Pattern is a Behavioural Design Pattern. The intent of Interator pattern is to provide a way to sequentially taverse over a data structure without exposing underlying data structure. Java’s Iterator is a good implementation of this pattern and allows us to traverse over underlying collection in a sequential way. A collection creates an Iterator […]
Builder Design Pattern
Posted by Bharat Sharma in Creational Design Patterns, Design Patterns on February 16, 2020
Builder Design pattern is a creational pattern. It is used to build a complex object step-by-step and final step would return complete constructed object. Builder pattern gives us more control over construction of object and makes client code more readable. It helps us eleminate problems like Telescoping Constructors and setter methods. You may also create […]
ArrayBlockingQueue
Posted by Bharat Sharma in concurrency, Core Java on May 6, 2018
ArrayBlockingQueue implements BlockingQueue interface. ArrayBlockingQueue is a bounded blocking queue that stores it’s elements in an array internally. Queue orders elements in FIFO (first-in-first-out) order. The head of the array contains element that has been in the queue for the longest time and tail of the queue contains elements that have been in the queue […]
BlockingQueue
Posted by Bharat Sharma in concurrency, Core Java on May 5, 2018
A BlockingQueue is a concurrent data structure that extends Queue interface and supports additional operations with following characteristics: Wait for space to be available when an insert is attempted and queue is full Wait for element to be available when the queue is empty. Usage Scenario BlockingQueue is useful in producer-consumer type of scenarios. One […]
Reading InputStream Into String With Java 8
Posted by Bharat Sharma in Core Java on December 18, 2017
Example below shows use of streaming with java 8.
VI Editor Command Reference
Posted by Bharat Sharma in UNIX on November 6, 2017
Note: Commands below are case sensitive and may not work on all versions of VI editor. General Commands To use VI vi filename to open file ZZ or :wq To exit vi and save changes :q! To exit vi without saving changes [esc] To enter vi command mode Cursor Movement Commands h move left (backspace) […]
Exchanger
Posted by Bharat Sharma in concurrency, Core Java, Threads on April 26, 2017
Java concurrency API provides a synchronization utility java.util.concurrent.Exchanger that allows two threads to exchange data. Exchanger provides a common point where two threads arrive and exchange data between them such that data of first thread goes to the second thread and data of second thread goes to first. Exchanger basically creates a barrier at which […]
Raspberry pi : Installing Tomcat
Posted by Bharat Sharma in Raspberry pi on May 11, 2016
Well I think raspberry pi 3 (Model B) is a very capable machine and can very well be used as a server for hosting some lightweight web application. I would certainly not want to run an expensive desktop server 24 X 7 and pay huge electric bills just for running a web application for limited […]
Raspberry pi : Installing Citrix Receiver
Posted by Bharat Sharma in Raspberry pi on May 8, 2016
I have been using raspberry pi 3, Model B as my primary computer for a few days now. I have installed Raspbian Jessie on it. Through this series of posts i plan to share details of how i set it up for my everyday use. First requirement for using it as my personal computer was […]
Using local thread variables
Posted by Bharat Sharma in concurrency, Core Java on March 4, 2015
Shared data is one of the most critical aspect of concurrent programming. When you create an instance of a class that implements Runnable interface or extends Thread class and use same object to create multiple Threads then all the threads share same attributes. This means if you change any attribute in one thread, all threads […]
Removing border from primefaces <p:layout>
Posted by Bharat Sharma in JSF on January 4, 2015
Primefaces provides an excellent component <p:layout> to lay structure your website, but it has an annoying border which makes everything look cluttered. Here is how you can get rid of that (at least for now) I know it is bad, but i am no CSS guru! Just figured out that this works!
Get source JARs and Javadoc from Maven repository
Posted by Bharat Sharma in Maven on February 17, 2014
Sometimes you may want to use Javadoc feature of your eclipse IDE so that you may be able to refer the source code and javadoc while using some API. Option 1 Following maven commands come in handy for these purposes: First command attempts to download *-source.jar files for the dependencies listed in your pom.xml and […]
Find running processes in Oracle
Posted by Bharat Sharma in SQL on September 23, 2013
Use following query to find running processing in Oracle. The output shows Process id of the running process, Status whether it is ACTIVE or INACTIVE, username, Schema Name and the SQL query that is running under current process. Running following query gives a handful of useful information.
SQL Index
Posted by Bharat Sharma in SQL on August 13, 2013
Index in SQL is created on existing tables and is a way to boost up the data retrieval performance of table. Index should be created on the columns that are frequently used for searching data. An Index is an ordered list of contents of a column ( or a group of columns) of a table. […]