This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--------- Executor Framework -----------*/ | |
java.util.concurrent.Executors | |
Executor API de-couples execution of tasks from actual task to be executed via Executors | |
Executor framework to schedule and execute the submitted tasks and return the result from thread pool. | |
1. Overhead of thread creation & tear-down | |
2. For each process creating new thread occupy more memory & waste of resources. | |
ExecutorService executorService = Executors.newSingleThreadExecutor(); | |
ExecutorService executorService = Executors.newFixedThreadPool(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Transaction Isolation levels: | |
Voilations: | |
Dirty Reads - A updates,B reads, A rollbacks | |
Non-Repeatable Reads - A reads, B Updates, A reads found 2 records for same. | |
Phantom Reads - A reads with where critaria, B insert new record which falls in that where critaria, A reads records with same. | |
TRANSACTION_READ_UNCOMMITTED | |
TRANSACTION_READ_COMMITTED | |
TRANSACTION_REPEATABLE_READ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-----------------Beanfactory vs Application Context | |
Beanfactory: | |
Bean instantiating/autowiring | |
Application Context: | |
Bean instantiating/autowiring | |
Automatic BeanPostProcessor registraion | |
Automatic BeanFactoryPostProcessor registraion | |
Convenient MessageSource access (i18) | |
ApplicationEvent publication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Singleton class double checking */ | |
public class Technology { | |
private static final Technology instance; | |
private Technology() {} | |
public static synchronized Technology getInstatnce() { | |
if (instance == null) { | |
synchronized (Technology.class) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Immutable Class */ | |
public final class Box { | |
private final String key; | |
private final String value; | |
private final HashMap<String, String> hm; | |
public Box(String key, String value, HashMap<String, String> hm) { | |
this.key = key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User { | |
private int id; | |
private String name; | |
//setters & getters | |
@Override | |
public int hashcode() { | |
final int prime = 31; | |
int result = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.beans.factory.annotation.Lookup; | |
import org.springframework.stereotype.Component; | |
@Component | |
public class RequestManager{ | |
private RequestHandler requestHandler; | |
public void handleRequest(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class RequestManager{ | |
@Autowired | |
private RequestHandler requestHandler; | |
public void handleRequest(){ | |
requestHandler.handleRequest(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetUser`() | |
BEGIN | |
SELECT * FROM USER ORDER BY FIRST_NAME; | |
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetTotalUser`() | |
BEGIN | |
DECLARE totalUser INT DEFAULT 0; | |
SELECT COUNT(*) INTO totalUser FROM USER; | |
SELECT totalUser; | |
END |
OlderNewer