Posts

Spring Boot

  D ifferent options of creating Spring Boot projects with Maven and Eclipse 1.  Spring Initializr  https://start.spring.io 2. STS (Spring Tool Suite) Eclipse Plugin                https://www.eclipse.org/community/eclipse_newsletter/2018/february/springboot.php 3. Manually Create a Maven Spring Boot Project     - Create Maven Project  -  Provide Group id, Artifact Id, and version - Add in the appropriate Spring Boot starters into the pom.xml  <dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-devtools</artifactId>     <scope>runtime</scope> </dependency> <dependency>     <groupId>o...

Multi Threading , concurency

 Threadpool Example Worker thread: package com.vasanth.java.concurrent; public class Workerthread implements Runnable { private String message; public Workerthread(String message) { super(); this.message = message; } @Override public void run() { System.out.println(Thread.currentThread().getName()+" : Start -> Message="+message); process(); System.out.println(Thread.currentThread().getName()+": End"); } private void process() { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } } Thread pool: package com.vasanth.java.concurrent; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class TestThreadPool { public static void main(String args[]) { ExecutorService executor = Executors.newFixedThreadPool(5); for(int i=1;i<10;i++) { Workerthread workerthread = new Workerthread(""+i); executor.execute(workert...

Curl commands

curl  is a command-line utility for transferring data from or to a server designed to work without user interaction. With  curl , you can download or upload data using one of the supported protocols including HTTP, HTTPS,  SCP  ,  SFTP  , and  FTP  .  curl  provides a number of options allowing you to resume transfers, limit the bandwidth, proxy support, user authentication, and much more.   To Print the header: Use the  -I  option to fetch only the HTTP headers of the specified resource.      curl -Is http://linux.com/      curl -I --http2 https://www.ubuntu.com/ With Proxy: curl  supports different types of proxies, including HTTP, HTTPS and SOCKS. To transfer data through a proxy server, use the  -x  ( --proxy ) option, followed by the proxy URL.      curl -x 192.168.44.1:8888 http://linux.com/ With Proxy & Username/Password: If the proxy server requires au...

Java Design Patterns

Image
D esign patterns are programming language independent strategies for solving the common object-oriented design problems. That means a design pattern represents an idea, not a particular implementation. By using the design patterns you can make your code more flexible, reusable, and maintainable. It is the most important part because java internally follows design patterns. Categorization of design patterns: Basically, design patterns are categorized into two parts: Core Java (or JSE) Design Patterns. JEE Design Patterns. Core Java Design Patterns In core java, there are mainly three types of design patterns, which are further divided into their sub-parts: 1.Creational Design Pattern Factory Pattern Abstract Factory Pattern Singleton Pattern Prototype Pattern Builder Pattern. 2. Structural Design Pattern Adapter Pattern Bridge Pattern Composite Pattern Decorator Pattern Facade Pattern Flyweight Pattern Proxy Pattern 3. Behavioral Design Pattern Chain Of Responsibility Pattern Command Pa...

Java 8 Concepts with Examples

Java 8 new features  1. Lambda Expressions A lambda expression is an anonymous function. A function that doesn’t have a name and doesn’t belong to any class.   so compiler does not create .class file. Used to provide the implementation of an interface which has functional interface      //Syntax of lambda expression ( parameter_list ) -> { function_body }      Example: Creating Thread with Lambda  package com.vasanth.java8; public class ThreadWithLambda { public static void main (String args[]){ //Traditional approach Runnable r1= new Runnable() { @Override public void run() { System. out .println( "Thread 1 started" ); } }; Thread t1= new Thread(r1); t1.start();                                        //With Lambda Runnabl...