'Back-End'에 해당되는 글 135건

donaricano-btn

Garbage Collection

- Garbage Collection is process of reclaiming the runtime unused memory automatically

- It is a way to destroy the unused objects

- Java is performed automatically, Java provides better memory management


1. Advantage

- It makes java memory efficient

- It is automatically done by the garbage collector(a part of JVM)


2. How can an object be unreferenced?

- By nulling the reference

- By assigning a reference to another

- By annoymous object etc


1) By nulling a reference


2) By assigning a reference to another

 

3) By annonymous object

 

3. finalize() method

- The finalize() is invoked each time before the object is garbage collected

- It can be used to perform cleanup processing

 

1) point

- The garbage collector collects only those objects that are created by new keyword

- If you have created any object without new, you can use finalize method to perform cleanup processing


4. gc() method

- gc() is used to invoke the garbage collector to perform cleanup processing

- gc() is found in System and Runtime classes

 

1) point

- Garbage collection is performed by a daemon thread called GC

- This thread calls the finalize() before object is garbage collected



'Back-End > Java_1' 카테고리의 다른 글

[Java] JDK 환경변수 설정(configure) - Window10  (0) 2016.11.13
[Java] Shutdown Hook  (0) 2016.10.10
[Java] Thread pool  (0) 2016.10.10
[Java] Daemon Thread  (0) 2016.10.10
[Java] Thread Priority  (0) 2016.10.07
블로그 이미지

리딩리드

,
donaricano-btn

주요 구성


1. 구성

1) MyBatis 설정 파일

- 데이터 베이스 접속 주소, 매핑 파일 경로 설정

2) SqlSessionFactoryBuilder

- Mybatis 설정 파일을 바탕으로 SqlSessionFactory 생성

- 애플리케이션 시작할 때 사용하여 SqlSessionFactory를 생성하면 없어지므로 버려진다

3) SqlSessionFactory

- SqlSession을 생성한다

- 스레드 세이프 하며, 애플리케이션 안의 프로그램은 하나의 오브젝트를 싱클톤 패턴 등으로 공유해야한다

- 스프링 연계시 DI 컨테이너에 관리 시킨다

4) SqlSession

-  SQL 발행이나 트랜잭션 관리 실행

- 스레드 세이프 하지 않으며 스레드 마다 필요에 따라 생성하고 폐기

5) Mapper 인터페이스   

- 매핑 파일에 기재된 SQL을 호출하기 위한 인터페이스

- MyBatis3가 자동 생성

- Mapper 오브젝트는 SqlSession 오브젝트와 관련해서 생성되므로 SqlSession 오브젝트와 함께 생성하고 폐기

6) 매핑 파일

- SQL과 OR 매핑을 설정, XML 파일



블로그 이미지

리딩리드

,
donaricano-btn

 MyBatis3란?


- MyBatis2 후속으로 등장한 ORM

- iBatis라는 이름으로 ASF의 프로젝트로 개발, 이후 3.X의 공개와 동시에 MyBatis라는 이름으로 변경되고 Google Code의 프로젝트가 됨

- 라이선스는 아파치 라이선스 2.0이다


1. 특징

1) XML을 이용하여 SQL과 OR 매핑을 다채롭고 단순하게 기술

2) MyBatis2.x 와 호환성은 없지만 같은 일을 처리

3) Mapper 라는 개념 제공

- 애플리케이션의 소스 코드를 타입에 안전하게 기술

4) 애노테이션 지원

블로그 이미지

리딩리드

,
donaricano-btn

Shutdown Hook

- Shutdown hook can be used to perform cleanup resource or save the state when JVM shuts down normally or abruptly

- clean resource means closing log file, sending some alerts...]

- If you want to execute some code before JVM shuts down, use shutdown hook


1. When does the JVM shut down?

- user presses ctrl+c on the command prompt

- System.exit(int) method is invoked

- user logoff

- user shutdown etc..


2. The addShutdownHook(Thread hook) mehtod

- addShutdownHook() method of Runtime class is used to register the thread with the Virtual Machine


3. Simple Example

 

'Back-End > Java_1' 카테고리의 다른 글

[Java] JDK 환경변수 설정(configure) - Window10  (0) 2016.11.13
[Java] Garbage Collection  (0) 2016.10.11
[Java] Thread pool  (0) 2016.10.10
[Java] Daemon Thread  (0) 2016.10.10
[Java] Thread Priority  (0) 2016.10.07
블로그 이미지

리딩리드

,