# 5.5.4 인트로덕션 by sh

### **5.5.4. 인트로덕션**

**인트로덕션(AspectJ에서 inter-type 선언으로 알려짐)은 권고 된 객체가 주어진 인터페이스를 구현하고 해당 객체를 대신하여 해당 인터페이스의 구현을 제공한다는 것을 선언하는 aspect를 선언하게합니다.**&#x20;

**`aop:aspect`내부에 `aop:declare-parents`요소를 사용하여 인드로덕션을를 할 수 있습니다. `aop:declare-parents` 요소를 사용하여 일치하는 유형에 새로운 부모 (따라서 이름)가 있음을 선언 할 수 있습니다.** 예를 들어, `UsageTracked`라는 인터페이스와 `DefaultUsageTracked`라는 인터페이스의 구현이 주어졌을 때, **다음 aspect는 서비스 인터페이스의 모든 구현자가 또한 `UsageTracked`인터페이스를 구현한다고 선언합니다.** (예를 들어 JMX를 통해 통계를 노출하기 위해)&#x20;

```markup
<aop:aspect id="usageTrackerAspect" ref="usageTracking">

    <aop:declare-parents
        types-matching="com.xzy.myapp.service.*+"
        implement-interface="com.xyz.myapp.service.tracking.UsageTracked"
        default-impl="com.xyz.myapp.service.tracking.DefaultUsageTracked"/>

    <aop:before
        pointcut="com.xyz.myapp.SystemArchitecture.businessService()
            and this(usageTracked)"
            method="recordUsage"/>

</aop:aspect>
```

**`usageTracking`빈을 뒷받침하는 클래스는 다음 메소드를 포함합니다.**&#x20;

```java
public void recordUsage(UsageTracked usageTracked) {
    usageTracked.incrementUseCount();
}
```

**구현할 인터페이스는 `implement-interface`속성에 의해 결정됩니다. `types-matching` 속성의 값은 AspectJ 유형 패턴이다.** 일치하는 유형의 Bean은 `UsageTracked`인터페이스를 구현합니다. 이전 예제의 before advice에서 Service Bean은 `UsageTracked`인터페이스의 구현으로 직접 사용될 수 있습니다. 프로그램 적으로 Bean에 액세스하려면 다음처럼 작성할 수 있습니다.&#x20;

```java
UsageTracked usageTracked = (UsageTracked) context.getBean("myService");
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wannaqueen.gitbook.io/spring5/spring-5.0/5-spring-aspect/5.5/5.5.4-by-sh.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
