Class NtfyClientFactory
NtfyClient bean, built from the bound NtfyConfiguration.
Unconditional by design. The client is a plain HTTP publisher for ad-hoc
notifications from application code; it does not touch a logging framework, so it is contributed
whatever SLF4J backend the application binds and even when ntfy.url/ntfy.topic
are unset (an inactive configuration simply publishes nothing). Only the appender install in
NtfyLogbackInstaller is Logback-specific. The Spring starter originally gated its whole
auto-configuration on Logback being present and lost the client bean along with the appender on a
Log4j2 classpath; that mistake is not repeated here — no Logback type appears anywhere in this
class or in the signatures the container introspects on it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionntfyClient(NtfyConfiguration configuration) Builds the singletonNtfyClient.
-
Constructor Details
-
NtfyClientFactory
public NtfyClientFactory()
-
-
Method Details
-
ntfyClient
Builds the singletonNtfyClient.preDestroy = "close"hands the client's lifecycle to the container:NtfyClientisAutoCloseableand owns an async delivery worker, so the context shutdown must close it or the worker outlives the application.Two builder names deliberately differ from the configuration property names, mirroring the Spring starter:
ntfy.actionsmaps ontoNtfyConfig.Builder.actionsHeader(String)(the value is a raw ntfyActionsheader, not a parsed action list) andntfy.asyncmaps ontoNtfyConfig.Builder.asyncEnabled(boolean). A third,ntfy.include-mdc-keys, maps ontoNtfyConfig.Builder.includeMdcKeysCsv(String)— the comma-separated form, since the property binds as a singleString.Every bound property must be forwarded here. This method and
NtfyLogbackInstallerare two independent apply sites for one configuration, so a key wired into only one of them produces a client whose config silently disagrees with the appender's — with nothing failing to announce it.include-mdc-keyswas exactly that omission until it was added here; thewarn-*level-routing keys are forwarded for the same reason.- Parameters:
configuration- the boundntfy.*configuration- Returns:
- a client bean the container closes on shutdown
-