Custom Action 라이브러리
EIMS는 특정 InterfaceDefinition과 해당 인터페이스에 속한 MessageDefinition을 입력받아 사용자가 정의한 커스텀 액션(Custom Action)을 수행할 수 있는 기능을 제공합니다.
패키지 구조
com.tmax.anyeims.external.action
├── CustomAction.java # 커스텀 액션 추상 클래스
└── model
├── CustomActionParameter.java # 커스텀 액션 입력 파라미터
└── CustomActionResult.java # 커스텀 액션 결과
클래스
다음은 각 클래스에 대한 설명입니다.
|
CustomActionParameter에서 사용되는 InterfaceDefinition, MessageDefinition 타입은 eims-export-model 라이브러리에서 제공됩니다. 각 타입의 상세 명세는 Export Model 라이브러리를 참고하세요. |
CustomAction
커스텀 액션을 구현하기 위한 추상 클래스입니다.
| 메서드 | 반환 타입 | 설명 |
|---|---|---|
isFileOut() |
Boolean |
파일 반환 여부(기본값: true) |
process(CustomActionParameter, OutputStream)` |
CustomActionResult |
커스텀 액션 로직 구현 (추상 메서드) |
구현 예시
커스텀 액션은 호출 시 두 가지 방식으로 동작합니다.
| 동작 방식 | 설명 | isFileOut() 반환값 |
|---|---|---|
파일 반환 |
커스텀 액션 결과로 파일을 생성하여 반환 |
true(기본값) |
단순 액션 트리거링 |
파일 반환 없이 특정 액션만 수행 |
false(오버라이드(Override) 필요) |
각 방식에 대한 구현 예시는 아래와 같습니다.
-
파일을 생성하여 반환하는 경우
CustomAction 추상 클래스를 상속받아 process 메서드를 구현합니다.
package com.tmax.anymessage.adapter.service; import com.tmax.anyeims.external.action.CustomAction; import com.tmax.anyeims.export.model.resources.InterfaceDefinition; import com.tmax.anyeims.external.action.model.CustomActionParameter; import com.tmax.anyeims.external.action.model.CustomActionResult; import java.io.IOException; import java.io.OutputStream; public class DefaultCaseCustomActionImpl extends CustomAction { @Override public CustomActionResult process(CustomActionParameter parameter, OutputStream outputStream) throws IOException { // 1. 파라미터에서 인터페이스 정보 추출 InterfaceDefinition interfaceDefinition = parameter.getInterfaceDefinition(); String interfaceId = interfaceDefinition.getInterfaceId(); // 2. 결과 파일 이름 및 내용 구성 String fileName = interfaceId + ".java"; String content = "package com.tmax.test;\n\n" + "public class I" + interfaceId + " {\n" + " private final Boolean IS_DEFAULT_CASE = true;\n" + "}"; // 3. OutputStream에 파일 내용 작성 byte[] bytes = content.getBytes(); outputStream.write(bytes, 0, bytes.length); // 4. 결과 반환 (파일 이름 포함) return new CustomActionResult(fileName); } } -
파일 반환 없이 액션만 수행하는 경우
파일을 반환하지 않는 경우,
isFileOut()메서드를 오버라이드(Override)하여 false를 반환합니다.public class NoFileCustomActionImpl extends CustomAction { @Override public boolean isFileOut() { return false; // 파일 반환 안함 } @Override public CustomActionResult process(CustomActionParameter parameter, OutputStream outputStream) throws IOException { // 파일 생성 없이 원하는 액션 수행 InterfaceDefinition interfaceDefinition = parameter.getInterfaceDefinition(); // ... 커스텀 액션 로직 수행 ... return new CustomActionResult(null); } }
배포 및 설정
JAR 파일 배포
CustomAction을 구현한 Java 프로젝트를 JAR로 빌드한 후, EIMS 설치 디렉토리 내 lib 디렉토리에 위치시킵니다.
EIMS_HOME/
└── lib/ # EIMS 백엔드 JAR 의존성 디렉토리
└── my-custom-action.jar # 커스텀 액션 JAR 파일
설정 파일 등록
application-extensions.yml 파일에 커스텀 액션 클래스와 액션 이름을 매핑합니다.
eims:
custom-action:
activate: true
actions:
- class-name: com.tmax.anymessage.adapter.service.ZipFileCustomActionImpl
action-name: ZIP
- class-name: com.tmax.anymessage.adapter.service.EAINoFileCustomActionImpl
action-name: EAI By Pass Custom Action
- class-name: com.tmax.anymessage.adapter.service.EAICustomActionImpl
action-name: EAI Custom Action
- class-name: com.tmax.anymessage.adapter.service.DefaultCaseCustomActionImpl
action-name: 기본 커스텀 액션
| 설정 항목 | 설명 |
|---|---|
activate |
커스텀 액션 기능 활성화 여부 |
actions[].class-name |
커스텀 액션 구현 클래스의 전체 경로(FQCN) |
actions[].action-name |
EIMS UI에서 표시될 액션 이름 |
의존성 추가
커스텀 액션 프로젝트에서 이 라이브러리를 사용하려면 JAR 파일을 직접 프로젝트에 추가합니다.
|
CustomActionParameter는 eims-export-model의 클래스들을 사용합니다. 따라서 eims-export-model JAR 파일도 함께 추가해야 합니다. |
필요 JAR 파일
| JAR 파일 | 설명 |
|---|---|
eims-custom-action-{version}.jar |
EIMS Custom Action 라이브러리 |
eims-export-model-{version}.jar |
파라미터 필드 타입 제공 |
Maven(로컬 JAR 참조)
<dependencies>
<!-- EIMS Custom Action Library -->
<dependency>
<groupId>com.tmax.anyeims</groupId>
<artifactId>eims-custom-action</artifactId>
<version>{version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/eims-custom-action-{version}.jar</systemPath>
</dependency>
<!-- EIMS Export Model (파라미터 필드 타입 제공) -->
<dependency>
<groupId>com.tmax.anyeims</groupId>
<artifactId>eims-export-model</artifactId>
<version>{version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/eims-export-model-{version}.jar</systemPath>
</dependency>
</dependencies>