Custom Notifications 라이브러리
EIMS에서는 특정 이벤트가 발생하면 알림을 제공합니다. 이 알림은 화면 왼쪽 하단의 종 모양 아이콘 또는 알림 배지를 클릭하여 확인할 수 있습니다.
또한 EIMS는 특정 이벤트 상황에서 사용자 커스텀 알림(Custom Notification)을 지원합니다. 사용자는 본 모듈을 구현하여 해당 상황에 원하는 동작을 실행시킬 수 있습니다.
|
알림 메서드의 파라미터에는 알림 수신자 정보와 해당 이벤트에서 발생한 리소스 정보가 포함되어 있습니다. |
현재 커스텀 알림은 다음 두 가지 상황에서 지원됩니다.
| 상황 | 알림 타입 | 설명 |
|---|---|---|
인터페이스 잠금 획득 |
CustomLockNotification |
잠금 소유자에게 알림 전달 |
인터페이스 배포 결재 상신 |
CustomDeploymentApprovalNotification |
현재 결재 라인에 해당하는 결재 승인자에게 알림 전달 |
패키지 구조
com.tmax.anyeims.external.notification
├── spi
│ └── CustomNotificationHandler.java # 커스텀 알림 핸들러 인터페이스
├── internal
│ └── model
│ ├── Notification.java # 알림 마커 인터페이스
│ ├── common
│ │ ├── Receiver.java # 알림 수신자 정보
│ │ └── InterfaceDefinitionInfo.java # 인터페이스 정보
│ ├── lock
│ │ └── CustomLockNotification.java # 잠금 알림
│ └── approval
│ ├── CustomDeploymentApprovalNotification.java # 배포 결재 알림
│ └── Approval.java # 결재 정보
└── sample
├── SampleCustomLockNotificationHandler.java
└── SampleCustomDeployApprovalNotificationHandler.java
클래스
CustomNotificationHandler (SPI)
커스텀 알림을 처리하기 위한 핸들러 인터페이스입니다.
public interface CustomNotificationHandler<N extends Notification> {
void handle(N notification);
}
|
Generic 타입 N에는 Notification 구현체 중 하나를 지정합니다. |
Notification
알림 클래스를 식별하기 위한 마커 인터페이스입니다.
이 인터페이스를 구현한 클래스만 CustomNotificationHandler에서 처리할 수 있습니다.
| 구현체 | 설명 |
|---|---|
CustomLockNotification |
인터페이스 잠금 획득 알림 |
CustomDeploymentApprovalNotification |
인터페이스 배포 결재 상신 알림 |
CustomLockNotification
인터페이스 잠금 획득 시 전달되는 알림 클래스입니다.
| 필드명 | 타입 | 설명 |
|---|---|---|
receiver |
Receiver |
알림 수신자(잠금 소유자) |
interfaceDefinition |
InterfaceDefinitionInfo |
잠금 대상 인터페이스 정보 |
CustomDeploymentApprovalNotification
인터페이스 배포 결재 상신 시 전달되는 알림 클래스입니다.
| 필드명 | 타입 | 설명 |
|---|---|---|
receiver |
Receiver |
알림 수신자(결재 승인자) |
interfaces |
List<InterfaceDefinitionInfo> |
배포 대상 인터페이스 목록 |
approval |
Approval |
결재 정보 |
Receiver
알림 수신자 정보를 담는 클래스입니다.
| 필드명 | 타입 | 설명 |
|---|---|---|
resourceId |
Long |
사용자 PK |
id |
String |
사용자 ID |
name |
String |
사용자 이름 |
phoneNumber |
String |
휴대폰 번호 |
contactNumber |
String |
연락처 |
구현 예시
사용자는 각 상황에 맞는 커스텀 알림을 구현하기 위해 CustomNotificationHandler를 구현해야 합니다. 이때 Generic 타입으로 처리할 Notification 구현체를 지정합니다.
-
인터페이스 잠금 알림 핸들러
package com.tmax.anyeims.external.notification.sample; import com.tmax.anyeims.external.notification.internal.model.lock.CustomLockNotification; import com.tmax.anyeims.external.notification.spi.CustomNotificationHandler; public class SampleCustomLockNotificationHandler implements CustomNotificationHandler<CustomLockNotification> { @Override public void handle(CustomLockNotification notification) { // 1. 알림 수신자 정보 추출 String receiverName = notification.getReceiver().getName(); String phoneNumber = notification.getReceiver().getPhoneNumber(); // 2. 잠금 대상 인터페이스 정보 추출 String interfaceId = notification.getInterfaceDefinition().getInterfaceId(); // 3. 원하는 알림 동작 수행 (예: SMS 발송, 이메일 전송 등) System.out.println("잠금 알림 - 수신자: " + receiverName + ", 인터페이스: " + interfaceId); } } -
배포 결재 상신 알림 핸들러
package com.tmax.anyeims.external.notification.sample; import com.tmax.anyeims.external.notification.internal.model.approval.CustomDeploymentApprovalNotification; import com.tmax.anyeims.external.notification.spi.CustomNotificationHandler; public class SampleCustomDeployApprovalNotificationHandler implements CustomNotificationHandler<CustomDeploymentApprovalNotification> { @Override public void handle(CustomDeploymentApprovalNotification notification) { // 1. 알림 수신자 정보 추출 String receiverName = notification.getReceiver().getName(); String phoneNumber = notification.getReceiver().getPhoneNumber(); // 2. 결재 정보 추출 String approvalTitle = notification.getApproval().getTitle(); String approvalContent = notification.getApproval().getContent(); // 3. 배포 대상 인터페이스 목록 추출 notification.getInterfaces().forEach(iface -> { System.out.println("배포 대상 인터페이스: " + iface.getInterfaceId()); }); // 4. 원하는 알림 동작 수행 (예: SMS 발송, 이메일 전송 등) System.out.println("결재 알림 - 수신자: " + receiverName + ", 결재 제목: " + approvalTitle); } }
배포 및 설정
JAR 파일 배포
CustomNotificationHandler를 구현한 Java 프로젝트를 JAR로 빌드한 후, EIMS 설치 디렉토리 내 lib 디렉토리에 위치시킵니다.
EIMS_HOME/
└── lib/ # EIMS 백엔드 JAR 의존성 디렉토리
└── my-custom-notification.jar # 커스텀 알림 JAR 파일
설정 파일 등록
application-extensions.yml 파일에 커스텀 알림 핸들러 클래스를 등록합니다.
eims:
custom-notification:
class-names:
- com.tmax.anyeims.external.notification.sample.SampleCustomLockNotificationHandler
- com.tmax.anyeims.external.notification.sample.SampleCustomDeployApprovalNotificationHandler
| 설정 항목 | 설명 |
|---|---|
class-names |
커스텀 알림 핸들러 구현 클래스의 전체 경로(FQCN) 목록 |
|
각 알림 상황별로 핸들러를 등록할 수 있습니다. |
의존성 추가
커스텀 알림 프로젝트에서 이 라이브러리를 사용하려면 JAR 파일을 직접 프로젝트에 추가합니다.