You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _pages/en/docs/guides/aspectran-xml-configuration.md
+40-3Lines changed: 40 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -298,7 +298,7 @@ public class MyService {
298
298
}
299
299
```
300
300
301
-
### 3.5. Exception Handling in Aspects (`<exception>`)
301
+
### 3.4. Exception Handling in Aspects (`<exception>`)
302
302
303
303
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.
304
304
@@ -328,7 +328,7 @@ In this example:
328
328
- If a service method throws a `DataAccessLayerException`, the request is forwarded to the `/error/databaseError` translet.
329
329
- If any other exception is thrown, the `logGenericError` method on the `errorLoggingService` bean is invoked.
330
330
331
-
### 3.6. AOP Examples
331
+
### 3.5. AOP Examples
332
332
333
333
**Example 1: Activity-level Request Logging**
334
334
@@ -866,21 +866,58 @@ In the configuration above, the `daily-batch` schedule is managed by `mainSchedu
866
866
867
867
## 7. Template-related Elements (`<template>`)
868
868
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.
870
870
871
871
#### `<template>` Attribute Details
872
872
873
873
-`id`: A unique ID to identify the template.
874
874
-`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).
875
878
-`name`: Specifies the name or path of the template.
876
879
-`file`: Specifies the template file based on a file system path.
877
880
-`resource`: Specifies the template resource based on a classpath path.
878
881
-`url`: Specifies a remote template via a URL.
879
882
-`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.
880
886
-`contentType`: Specifies the `Content-Type` of the template result.
881
887
-`encoding`: Specifies the character encoding of the template file.
882
888
-`noCache`: If set to `true`, the template is not cached. The default is `false`.
883
889
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
+
<templateid="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.
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
+
884
921
## 8. Exception Handling (`<exception>`)
885
922
886
923
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.
Copy file name to clipboardExpand all lines: _pages/ko/docs/guides/aspectran-xml-configuration.md
+40-3Lines changed: 40 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -298,7 +298,7 @@ public class MyService {
298
298
}
299
299
```
300
300
301
-
### 3.5. 애스펙트에서 예외 처리 (`<exception>`)
301
+
### 3.4. 애스펙트에서 예외 처리 (`<exception>`)
302
302
303
303
주요 어드바이스 로직 외에도, `<aspect>`는 전용 예외 처리 어드바이스를 정의하기 위해 `<exception>` 블록을 포함할 수 있습니다. 이는 로깅이나 예외 변환과 같은 횡단 관심사의 오류 처리를 메인 어드바이스 빈을 복잡하게 만들지 않고 깔끔하게 관리하는 방법을 제공합니다.
304
304
@@ -328,7 +328,7 @@ public class MyService {
328
328
- 서비스 메소드가 `DataAccessLayerException`을 발생시키면, 요청은 `/error/databaseError` 트랜슬릿으로 포워드됩니다.
329
329
- 다른 예외가 발생하면, `errorLoggingService` 빈의 `logGenericError` 메소드가 호출됩니다.
330
330
331
-
### 3.6. AOP 예제
331
+
### 3.5. AOP 예제
332
332
333
333
**예제 1: 액티비티 레벨 요청 로깅**
334
334
@@ -866,21 +866,58 @@ Aspectran은 생성자 주입과 수정자 주입 두 가지 주요 의존성
866
866
867
867
## 7. 템플릿(`<template>`) 관련 요소
868
868
869
-
최상위 레벨에서 재사용 가능한 템플릿을 정의합니다.
869
+
최상위 레벨에서 재사용 가능한 템플릿을 정의합니다. 정의된 템플릿은 `~{templateId}` 토큰을 사용하여 애플리케이션의 어느 곳에서나 참조하고 렌더링할 수 있습니다.
870
870
871
871
#### `<template>` 속성 상세
872
872
873
873
-`id`: 템플릿을 식별하는 고유 ID입니다.
874
874
-`engine`: 사용할 템플릿 엔진 빈의 ID를 지정합니다.
875
+
- 생략하거나 `token`(기본값)으로 설정하면, Aspectran의 내장 토큰 엔진을 사용하여 `${...}` 및 `@{...}` 토큰을 파싱합니다.
876
+
-`none`으로 설정하면, 내용을 원시 텍스트(Raw Text)로 취급합니다.
877
+
- 그 외의 경우, 외부 템플릿 엔진 빈(예: FreeMarker, Pebble)의 ID를 지정합니다.
875
878
-`name`: 템플릿의 이름 또는 경로를 지정합니다.
876
879
-`file`: 파일 시스템 경로를 기준으로 템플릿 파일을 지정합니다.
877
880
-`resource`: 클래스패스 경로를 기준으로 템플릿 리소스를 지정합니다.
878
881
-`url`: URL을 통해 원격 템플릿을 지정합니다.
879
882
-`style`: APON 형식의 템플릿을 사용할 경우 스타일을 지정합니다. (`apon`, `compact`, `compressed`)
883
+
-`apon`: 파이프(`|`) 문자를 사용하여 들여쓰기와 줄 바꿈을 보존합니다.
884
+
-`compact`: JSON이나 XML에서 불필요한 공백을 제거합니다.
885
+
-`compressed`: 크기를 최소화하기 위해 필수적이지 않은 모든 공백을 제거합니다.
이 예제에서 `/mail/welcome`이 요청되면 `welcomeMailTemplate`이 렌더링됩니다. 템플릿 내부의 `@{user^name}` 및 `#{pointService^points}` 토큰이 평가되고, 결과 텍스트가 응답으로 반환됩니다.
920
+
884
921
## 8. 예외 처리 (`<exception>`)
885
922
886
923
Aspectran은 오류가 발생할 수 있는 컨텍스트 내에서 핸들러를 선언적으로 정의하여 예외를 처리하는 분산된 방법을 제공합니다. 이는 `<translet>` 또는 `<aspect>` 내부에 정의할 수 있는 `<exception>` 요소를 사용하여 수행됩니다. 단일 최상위 전역 예외 핸들러 블록은 없으며, 대신 핸들러는 보호하는 규칙과 함께 배치됩니다.
0 commit comments