<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/position.css">
<title>Document</title>
</head>
<body>
<div class="a">a</div>
<div class="b">b</div>
<div class="c">c</div>
<div class="d">d</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</body>
</html>
-position: static : 요소들의 자연스러운 흐름에 따라 원래 있을 자리에 배치, 기본값, 지정하지 않으면 그냥 이 상태임
-position: relative : 원래 있을 위치의 좌상단을 기준으로 이동
-position: absolute : 브라우저 화면의 좌상단을 기준으로 이동
-position: fixed : Scroll을 해도 항상 지정된 위치에 고정되어 있음, fixed의 경우, 위치 이동은 absolute처럼 적용됨
-position: sticky : 평소에는 static처럼 있다가 Scroll들의 화면 변화에 따라 지정된 위치에 고정됨
-left, top, bottom, right : 움직일 값 입력
- z-index : 요소들간의 z 축, 요소들끼리 겹치는 경우 위에 있을 요소를 결정함, static이 아닌 요소에 적용 가능
- 기본적으로 static이 아닌 요소가 static요소보다 위에 위치하고, 동등할 경우 나중에 나오는 요소가 위에 위치함
* 외부에서의 호출은 Proxy객체를 통해 Target객체의 JoinPoint메서드를 호출하는 방식임
- 변수 service는 com.jjundol.aop.service.SampleServiceImpl의 객체((Target객체))가 아니라 Proxy의 인스턴스가 됨
- com.sum.proxy.$Proxy24는 dynamic-Proxy기법이 적용된 결과임
@RunWith(SpringJUnit4ClassRunner.class)
@Log4j
@ContextConfiguration({"file:src/main/webapp/WEB-INF/spring/root-context.xml"})
public class SampleServiceTest {
@Autowired
private SampleService service;
@Test
public void testClass() {
log.info(service);
log.info(service.getClass().getName());
}
}
INFO : com.jjundol.aop.service.SampleServiceTest - com.jjundol.aop.service.SampleServiceImpl@432038ec
INFO : com.jjundol.aop.service.SampleServiceTest - com.sun.proxy.$Proxy24
- PointCut : Target에는 여러개의 메서드(JoinPoint)가 있기 때문에 어떤 메서드와 결합할 것인지 결정하는 것, 관심사와 비즈니스 로직이 결합되는 지점을 결정하는 것
- Proxy : Target을 전체적으로 감싸는 존재, 내부적으로 Target을 호출할 때, 중간에 필요한 관심사를 거쳐서 Target을 호출하도록 자동/수동으로 설정됨, 스프링의 AOP기능을 이용하여 자동으로 생성되는 auto-proxy기능을 이용, 관심사와 메서드가 결합된 상태로 메서드를 호출하면 자동으로 관심사가 결합된 상태로 동작
=> 외부에서의 호출은 Proxy객체를 통해 Target객체의 JoinPoint메서드를 호출하는 방식임
Proxy
Advice는 동작 위치에 따라 구분됨
- Before Advice : Target의 JoinPoint실행 전, 코드의 실행 자체에는 관여 못함
- AfterAdvice : 정상or예외발생 후 구분 없이 동작
- After Returning Advice : 모든 실행이 정상완료 후에 동작
- Afte Throwing Advice : 예외 발생 후에 동작
- Around Advice : 메서드 실행 자체를 제어, 직접 대상 메서드를 호출하고 결과나 예외를 처리
- Target에 어떤 Advice를 적용할 것인지 XMl을 이용한 설정 or Annotation으로 설정이 가능
- Target의 JoinPoint는 PointCut에 의해 Advice와 결합하여 원래 자신에게는 없는 기능을 가지게 됨