From d3d2a39296b2b6cfeb6262bff8f61cd694582fa2 Mon Sep 17 00:00:00 2001 From: Alejandro Revilla Date: Mon, 2 Sep 2024 19:05:39 -0300 Subject: [PATCH] Simplify undeploy logging --- .../main/java/org/jpos/log/evt/UnDeploy.java | 4 +--- jpos/src/main/java/org/jpos/q2/Q2.java | 18 +++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/jpos/src/main/java/org/jpos/log/evt/UnDeploy.java b/jpos/src/main/java/org/jpos/log/evt/UnDeploy.java index 8ee994de51..c1a6f8bada 100644 --- a/jpos/src/main/java/org/jpos/log/evt/UnDeploy.java +++ b/jpos/src/main/java/org/jpos/log/evt/UnDeploy.java @@ -18,8 +18,6 @@ package org.jpos.log.evt; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import org.jpos.log.AuditLogEvent; -public record UnDeploy(String path, @JacksonXmlProperty(isAttribute = true) boolean start) implements AuditLogEvent { } - +public record UnDeploy(String path) implements AuditLogEvent { } diff --git a/jpos/src/main/java/org/jpos/q2/Q2.java b/jpos/src/main/java/org/jpos/q2/Q2.java index 75385eaa76..7d079b0dcb 100644 --- a/jpos/src/main/java/org/jpos/q2/Q2.java +++ b/jpos/src/main/java/org/jpos/q2/Q2.java @@ -527,20 +527,22 @@ private long persist (File f, ObjectName name) { private void undeploy (File f) { QEntry qentry = dirMap.get (f); + LogEvent evt = log != null ? log.createInfo().withTraceId(getInstanceId()) : null; try { - if (log != null) - log.info (new UnDeploy(f.getCanonicalPath(), true)); + if (evt != null) + evt.addMessage (new UnDeploy(f.getCanonicalPath())); if (qentry.isQBean()) { Object obj = qentry.getObject (); ObjectName name = qentry.getObjectName (); factory.destroyQBean (this, name, obj); } - if (log != null) - log.info (new UnDeploy(f.getCanonicalPath(), false)); - } catch (Exception e) { - getLog().warn ("undeploy", e); + if (evt != null) + evt.addMessage (e); + } finally { + if (evt != null) + Logger.log(evt); } } @@ -561,10 +563,8 @@ private boolean register (File f) { private boolean deploy (File f) { LogEvent evt = log != null ? log.createInfo().withTraceId(getInstanceId()) : null; - boolean enabled = false; - String filePath = ""; + boolean enabled; try { - filePath = f.getCanonicalPath(); QEntry qentry = dirMap.get (f); SAXBuilder builder = createSAXBuilder(); Document doc;