Package com.easydesk.notification.util
Class NotificationRenderer
java.lang.Object
com.easydesk.notification.util.NotificationRenderer
Notification(Email) 의 제목/본문 템플릿 renderer 이다.
예전: Avalon 객체 풀링(InitableRecyclable) + Turbine Template Service (TurbineTemplate.handleRequest) + Velocity(.vm) + 패키지를 거슬러 올라가며 Default.vm 을 찾는 Turbine Resolver.
이후: Spring bean(singleton) + standalone Thymeleaf(SpringTemplateEngine).
web(MVC) 과 무관하게 동작하며, 의도적으로 SpringTemplateEngine 을 Spring bean 으로
노출하지 않고 이 클래스 안에서만 만든다 - 그렇지 않으면 easydesk-spring-web-demo 처럼 Spring Boot
가 이미 자동설정한 화면용 SpringTemplateEngine 과 타입이 겹쳐 주입이 모호해지거나 Boot 의 자동설정이
물러난다.
템플릿 위치 (classpath)
- 제목 :
notifications/subject/<name>.txt(Thymeleaf TEXT mode, 예:[[#{...}]]) - 본문 :
notifications/layouts/<name>.html(Thymeleaf HTML mode, 예:th:text) - 다국어 : easydesk-localization 의 EasyDeskBundle 등 (템플릿에서
#{key})
NotificationType.getTemplate() 값(예: "ItemAdded.vm", "note/Foo.vm1")에서
확장자를 떼고 위 위치에서 찾는다. 해당 템플릿이 없으면 예전 Resolver 와 같이 상위 폴더의 Default
로 거슬러 올라간다 (note/Foo -> note/Default -> Default).
- Author:
- Youncho Cho
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal class템플릿에서${templates.find('html/activitysettype/inviteuser', itemTypeName)}처럼 쓰는 helper. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String못 찾으면 상위 폴더에서 찾는 template 이름static final String공통 fragment (header/footer 등) template 폴더 (예전 macros/GlobalMacros.vm 의 #macro 대체)static final Stringlayout 안에 들어가는 본문 내용 template 폴더 (예전 html/*.vm)static final String본문 template 종류 (폴더 이름)static final Stringlayout 아래쪽 안내문(수신거부 등) template 폴더 (예전 navigations/*.vm)static final String제목 template 종류 (폴더 이름) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrenderBody(NotificationContext context, String template, Locale locale) 본문(html)을 render 한다.renderSubject(NotificationContext context, String template, Locale locale) 제목을 render 한다.booleantemplateExists(String kind, String template) template 이 실제로 존재하는지 (Default 로의 fallback 포함하여) 확인한다.
-
Field Details
-
SUBJECT
제목 template 종류 (폴더 이름)- See Also:
-
LAYOUTS
본문 template 종류 (폴더 이름)- See Also:
-
HTML
layout 안에 들어가는 본문 내용 template 폴더 (예전 html/*.vm)- See Also:
-
NAVIGATIONS
layout 아래쪽 안내문(수신거부 등) template 폴더 (예전 navigations/*.vm)- See Also:
-
FRAGMENTS
공통 fragment (header/footer 등) template 폴더 (예전 macros/GlobalMacros.vm 의 #macro 대체)- See Also:
-
DEFAULT_TEMPLATE
못 찾으면 상위 폴더에서 찾는 template 이름- See Also:
-
-
Constructor Details
-
NotificationRenderer
public NotificationRenderer()Creates a new NotificationRenderer.
-
-
Method Details
-
renderSubject
제목을 render 한다. 제목은 한 줄이어야 하므로 줄바꿈/연속 공백은 공백 하나로 합치고 trim 한다.- Parameters:
context- template 변수template- NotificationType 의 template 이름 (확장자는 무시된다)locale- 수신자 locale- Returns:
- 제목
-
renderBody
본문(html)을 render 한다.- Parameters:
context- template 변수template- NotificationType 의 template 이름 (확장자는 무시된다)locale- 수신자 locale- Returns:
- html 본문
-
templateExists
template 이 실제로 존재하는지 (Default 로의 fallback 포함하여) 확인한다.
-