package com.qianwen.core.notify.notifier; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.qianwen.core.notify.NotifyType; import com.qianwen.core.notify.Provider; import com.qianwen.core.notify.event.NotifierEvent; import com.qianwen.core.notify.template.Template; import com.qianwen.core.tool.metadata.Values; /* loaded from: blade-starter-notify-9.3.0.0-SNAPSHOT.jar:org/springblade/core/notify/notifier/NotifierProxy.class */ public abstract class NotifierProxy implements Notifier { private static final Logger log = LoggerFactory.getLogger(NotifierProxy.class); private Notifier target; protected abstract void onEvent(NotifierEvent event); public NotifierProxy(final Notifier target) { this.target = target; } @Override // com.qianwen.core.notify.notifier.Notifier public NotifierProperties getNotifierProperties() { return this.target.getNotifierProperties(); } @Override // com.qianwen.core.notify.notifier.Notifier public String getNotifierId() { return this.target.getNotifierId(); } @Override // com.qianwen.core.notify.notifier.Notifier public NotifyType getType() { return this.target.getType(); } @Override // com.qianwen.core.notify.notifier.Notifier public Provider getProvider() { return this.target.getProvider(); } @Override // com.qianwen.core.notify.notifier.Notifier public void send(String templateId, String traceId, Values context, List notifiedParty) { try { this.target.send(templateId, traceId, context, notifiedParty); log.info("发送[{}]通知[{}-{}]完成", new Object[]{this.target.getType().getName(), getNotifierId(), templateId}); onSuccess(templateId, traceId, context); } catch (Exception exception) { log.error("发送[{}]通知[{}-{}]失败", new Object[]{this.target.getType().getName(), getNotifierId(), templateId, exception}); onError(templateId, traceId, context, exception); } } @Override public void send(T template, String traceId, Values context, List notifiedParty) { try { this.target.send(template, traceId, context, notifiedParty); onSuccess(template, traceId, context); } catch (Exception exception) { onError(template, traceId, context, exception); } } protected void onError(T template, String traceId, Values ctx, Throwable error) { onEvent(NotifierEvent.builder().cause(error).context(ctx.getAllValues()).notifierId(getNotifierId()).notifyType(getType()).provider(getProvider()).template(template).traceId(traceId).build()); } protected void onError(String templateId, String traceId, Values ctx, Throwable error) { onEvent(NotifierEvent.builder().cause(error).context(ctx.getAllValues()).notifierId(getNotifierId()).notifyType(getType()).provider(getProvider()).templateId(templateId).traceId(traceId).build()); } protected void onSuccess(T template, String traceId, Values ctx) { onEvent(NotifierEvent.builder().success(true).context(ctx.getAllValues()).notifierId(getNotifierId()).notifyType(getType()).provider(getProvider()).template(template).traceId(traceId).build()); } protected void onSuccess(String templateId, String traceId, Values ctx) { onEvent(NotifierEvent.builder().success(true).context(ctx.getAllValues()).notifierId(getNotifierId()).notifyType(getType()).provider(getProvider()).templateId(templateId).traceId(traceId).build()); } @Override // com.qianwen.core.notify.notifier.Notifier public void close() { this.target.close(); } @Override // com.qianwen.core.notify.notifier.Notifier public > R unwrap(Class type) { return (R) this.target.unwrap(type); } }