Skip to content

Commit 5fd3643

Browse files
committed
Update
1 parent 5344018 commit 5fd3643

File tree

2 files changed

+80
-6
lines changed

2 files changed

+80
-6
lines changed

_pages/en/docs/guides/aspectran-xml-configuration.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public class MyService {
298298
}
299299
```
300300

301-
### 3.5. Exception Handling in Aspects (`<exception>`)
301+
### 3.4. Exception Handling in Aspects (`<exception>`)
302302

303303
In addition to the main advice logic, an `<aspect>` can contain an `<exception>` block to define dedicated exception handling advice. This provides a clean way to manage cross-cutting error handling, such as logging or transforming exceptions, without cluttering the main advice bean.
304304

@@ -328,7 +328,7 @@ In this example:
328328
- If a service method throws a `DataAccessLayerException`, the request is forwarded to the `/error/databaseError` translet.
329329
- If any other exception is thrown, the `logGenericError` method on the `errorLoggingService` bean is invoked.
330330

331-
### 3.6. AOP Examples
331+
### 3.5. AOP Examples
332332

333333
**Example 1: Activity-level Request Logging**
334334

@@ -866,21 +866,58 @@ In the configuration above, the `daily-batch` schedule is managed by `mainSchedu
866866

867867
## 7. Template-related Elements (`<template>`)
868868

869-
Defines reusable templates at the top level.
869+
Defines reusable templates at the top level. The defined template can be referenced and rendered anywhere in the application using the `~{templateId}` token.
870870

871871
#### `<template>` Attribute Details
872872

873873
- `id`: A unique ID to identify the template.
874874
- `engine`: Specifies the ID of the template engine bean to use.
875+
- If omitted or set to `token` (default), Aspectran's built-in token engine is used to parse `${...}` and `@{...}` tokens.
876+
- If set to `none`, the content is treated as raw text.
877+
- Otherwise, it specifies the ID of an external template engine bean (e.g., FreeMarker, Pebble).
875878
- `name`: Specifies the name or path of the template.
876879
- `file`: Specifies the template file based on a file system path.
877880
- `resource`: Specifies the template resource based on a classpath path.
878881
- `url`: Specifies a remote template via a URL.
879882
- `style`: Specifies the style if using an APON-formatted template (`apon`, `compact`, `compressed`).
883+
- `apon`: Preserves indentation and line breaks using the pipe (`|`) character.
884+
- `compact`: Removes unnecessary whitespace from JSON or XML.
885+
- `compressed`: Removes all non-essential whitespace to minimize size.
880886
- `contentType`: Specifies the `Content-Type` of the template result.
881887
- `encoding`: Specifies the character encoding of the template file.
882888
- `noCache`: If set to `true`, the template is not cached. The default is `false`.
883889

890+
### 7.1. Example: Defining a Reusable Token Template
891+
892+
This example defines a simple text template using the `apon` style for readability and token expressions for dynamic values.
893+
894+
```xml
895+
<!-- Define a reusable template at the top level -->
896+
<template id="welcomeMailTemplate" style="apon">
897+
|Dear @{user^name},
898+
|
899+
|Welcome to Aspectran!
900+
|Your current point balance is: #{pointService^points}
901+
|
902+
|Best regards,
903+
|The Aspectran Team
904+
</template>
905+
```
906+
907+
### 7.2. Example: Using a Template in a Translet
908+
909+
You can use the `~{templateId}` token to render the defined template within a `<transform>` action.
910+
911+
```xml
912+
<translet name="/mail/welcome">
913+
<action id="user" bean="userService" method="getUser"/>
914+
<transform format="text">
915+
<template>~{welcomeMailTemplate}</template>
916+
</transform>
917+
</translet>
918+
```
919+
In this example, when `/mail/welcome` is requested, the `welcomeMailTemplate` is rendered. The `@{user^name}` and `#{pointService^points}` tokens inside the template are evaluated, and the resulting text is returned as the response.
920+
884921
## 8. Exception Handling (`<exception>`)
885922

886923
Aspectran provides a decentralized way to handle exceptions declaratively, defining handlers within the context where an error might occur. This is done using the `<exception>` element, which can be defined inside a `<translet>` or an `<aspect>`. There is no single, top-level global exception handler block; instead, handlers are co-located with the rules they protect.

_pages/ko/docs/guides/aspectran-xml-configuration.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public class MyService {
298298
}
299299
```
300300

301-
### 3.5. 애스펙트에서 예외 처리 (`<exception>`)
301+
### 3.4. 애스펙트에서 예외 처리 (`<exception>`)
302302

303303
주요 어드바이스 로직 외에도, `<aspect>`는 전용 예외 처리 어드바이스를 정의하기 위해 `<exception>` 블록을 포함할 수 있습니다. 이는 로깅이나 예외 변환과 같은 횡단 관심사의 오류 처리를 메인 어드바이스 빈을 복잡하게 만들지 않고 깔끔하게 관리하는 방법을 제공합니다.
304304

@@ -328,7 +328,7 @@ public class MyService {
328328
- 서비스 메소드가 `DataAccessLayerException`을 발생시키면, 요청은 `/error/databaseError` 트랜슬릿으로 포워드됩니다.
329329
- 다른 예외가 발생하면, `errorLoggingService` 빈의 `logGenericError` 메소드가 호출됩니다.
330330

331-
### 3.6. AOP 예제
331+
### 3.5. AOP 예제
332332

333333
**예제 1: 액티비티 레벨 요청 로깅**
334334

@@ -866,21 +866,58 @@ Aspectran은 생성자 주입과 수정자 주입 두 가지 주요 의존성
866866

867867
## 7. 템플릿(`<template>`) 관련 요소
868868

869-
최상위 레벨에서 재사용 가능한 템플릿을 정의합니다.
869+
최상위 레벨에서 재사용 가능한 템플릿을 정의합니다. 정의된 템플릿은 `~{templateId}` 토큰을 사용하여 애플리케이션의 어느 곳에서나 참조하고 렌더링할 수 있습니다.
870870

871871
#### `<template>` 속성 상세
872872

873873
- `id`: 템플릿을 식별하는 고유 ID입니다.
874874
- `engine`: 사용할 템플릿 엔진 빈의 ID를 지정합니다.
875+
- 생략하거나 `token`(기본값)으로 설정하면, Aspectran의 내장 토큰 엔진을 사용하여 `${...}``@{...}` 토큰을 파싱합니다.
876+
- `none`으로 설정하면, 내용을 원시 텍스트(Raw Text)로 취급합니다.
877+
- 그 외의 경우, 외부 템플릿 엔진 빈(예: FreeMarker, Pebble)의 ID를 지정합니다.
875878
- `name`: 템플릿의 이름 또는 경로를 지정합니다.
876879
- `file`: 파일 시스템 경로를 기준으로 템플릿 파일을 지정합니다.
877880
- `resource`: 클래스패스 경로를 기준으로 템플릿 리소스를 지정합니다.
878881
- `url`: URL을 통해 원격 템플릿을 지정합니다.
879882
- `style`: APON 형식의 템플릿을 사용할 경우 스타일을 지정합니다. (`apon`, `compact`, `compressed`)
883+
- `apon`: 파이프(`|`) 문자를 사용하여 들여쓰기와 줄 바꿈을 보존합니다.
884+
- `compact`: JSON이나 XML에서 불필요한 공백을 제거합니다.
885+
- `compressed`: 크기를 최소화하기 위해 필수적이지 않은 모든 공백을 제거합니다.
880886
- `contentType`: 템플릿 결과물의 `Content-Type`을 지정합니다.
881887
- `encoding`: 템플릿 파일의 문자 인코딩을 지정합니다.
882888
- `noCache`: `true`로 설정하면, 템플릿을 캐시하지 않습니다. 기본값은 `false`입니다.
883889

890+
### 7.1. 예제: 재사용 가능한 토큰 템플릿 정의
891+
892+
이 예제는 가독성을 위해 `apon` 스타일을 사용하고 동적인 값 처리를 위해 토큰 표현식을 사용하는 간단한 텍스트 템플릿을 정의합니다.
893+
894+
```xml
895+
<!-- 최상위 레벨에서 재사용 가능한 템플릿 정의 -->
896+
<template id="welcomeMailTemplate" style="apon">
897+
|안녕하세요, @{user^name}님.
898+
|
899+
|Aspectran에 오신 것을 환영합니다!
900+
|현재 보유 포인트는 #{pointService^points}점 입니다.
901+
|
902+
|감사합니다.
903+
|Aspectran 팀 드림
904+
</template>
905+
```
906+
907+
### 7.2. 예제: 트랜슬릿에서 템플릿 사용
908+
909+
`~{templateId}` 토큰을 사용하여 `<transform>` 액션 내에서 정의된 템플릿을 렌더링할 수 있습니다.
910+
911+
```xml
912+
<translet name="/mail/welcome">
913+
<action id="user" bean="userService" method="getUser"/>
914+
<transform format="text">
915+
<template>~{welcomeMailTemplate}</template>
916+
</transform>
917+
</translet>
918+
```
919+
이 예제에서 `/mail/welcome`이 요청되면 `welcomeMailTemplate`이 렌더링됩니다. 템플릿 내부의 `@{user^name}``#{pointService^points}` 토큰이 평가되고, 결과 텍스트가 응답으로 반환됩니다.
920+
884921
## 8. 예외 처리 (`<exception>`)
885922

886923
Aspectran은 오류가 발생할 수 있는 컨텍스트 내에서 핸들러를 선언적으로 정의하여 예외를 처리하는 분산된 방법을 제공합니다. 이는 `<translet>` 또는 `<aspect>` 내부에 정의할 수 있는 `<exception>` 요소를 사용하여 수행됩니다. 단일 최상위 전역 예외 핸들러 블록은 없으며, 대신 핸들러는 보호하는 규칙과 함께 배치됩니다.

0 commit comments

Comments
 (0)