내가 보려고 정리하는/Spring

웹 : Performance Check : 0321(2)

보동이용용 2023. 3. 21. 14:58
반응형

▶\14\performanceCheck.jsp

1. 공간적 개념

가비지 컬렉션의 대상이 되는 저장공간을 사용해야 메모리 공간이 무거워지지 않는다.

String txt = "TEXT";
txt += "append";

여기서 사용하는 메모리는 ? method area(constant pool)의 저장소 "TEXT", "append", "TEXTappend"

StringBuffer txt = new StringBuffer("TEXT");
txt.append("append");

여기서 사용하는 메모리는? heap area

method area는 지워지지 않는 상수공간이므로 후자쪽을 쓰도록 한다.

2. 시간적 개념

B + C ( processing time + latency time )  

내가 감당할 클라이언트 대충 계산해두고 미리 만들어둔 커넥션 담아두는 것 : 커넥션 풀링

C:\Windows\System32>lsnrctl status

 

▷oneConnOneProcess.jsp,  100Conn100Process.jsp,  oneConn100Process.jsp

▶ConnectionFactory

The commons-dbcp2 artifact relies on code in the commons-pool2 artifact to provide the underlying object pool mechanisms.

웹어플리케이션 만들때 커넥션 풀링 필수...!

 

 

 

 


미션

https://commons.apache.org/proper/commons-pool/examples.html

 

Pool – Examples

A Simple Pool Client Suppose you're writing a set of java.io.Reader utilities, and would like to provide a method for dumping the contents of a Reader to a String. Here's the code for the ReaderUtil, implemented without an ObjectPool: import java.io.Reader

commons.apache.org

여기 코드 해보기.


🚩Reflection 보강

Reflection : 반사

나를 혼자서 찾을 수는 없으니까 나를 반사시켜서 알려주는 거울을 보는 것.

붕어빵 분석잡업 : 리플렉션 ㅇㄴ

리플렉션이란? (java.lang.reflect)

 객체로부터 그 객체의 타입(유형) - Class.class, 속성 Field.class, 행동Method.class에 관한 정보를 역으로 추적하는 과정.

 

불확실성을 기본으로하는 리플렉션..

▶ 파일 : ReflectionDesc

public class ReflectionDesc {
	public static void main(String[] args) {
		Object instance = ReflectionTest.getObject();
		System.out.println(instance);
		
		Class<?> instanceType = instance.getClass();
		System.out.printf("클래스 정보 : %s\n", instanceType.getName());
		Field[] fields = instanceType.getDeclaredFields();
		for(Field fld : fields) {
			Class<?> fldType = fld.getType();
			String fldName = fld.getName();
			System.out.printf("%s %s;\n", fldType.getName(), fldName);
		}
		Method[] methods = instanceType.getMethods();
		for(Method mtd : methods) {
			// signature reflection
			Parameter[] parameters = mtd.getParameters();
			String mtdName = mtd.getName();
			Class<?> returnType = mtd.getReturnType();
			System.out.printf("%s %s(%s);\n", returnType.getName(), mtdName, Arrays.toString(parameters));
		}
	}
}

instance 하나로 객체 정보 가져오기 !! 

 

 

리플렉션으로 가져오면 private을 강제로 public으로 바꿀 수 있다. 

 

스프링이 private으로 묶여있는 객체에 값을 넣을 때 사용하는 방식 리플렉션.

디펜던시 인젝션

 

 

1. 겟터에 관한 메서드를 찾아내고 2. 실행하고 3. 찾아내면 해결.

자바빈 규약이 있기 때문에 가능

 자바 빈 규약을 이용할 수 있는 api를 찾아보자.

 

미션3

sql mapper, data mapper 검색해보고

 

 

 

 

 

반응형