-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs : #18643 : Added Cloneable features for Initialization Demo-POC
- Loading branch information
1 parent
bfcd8e5
commit bad7365
Showing
3 changed files
with
175 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
logharbour/src/main/java/com/remiges/logharbour/util/CloneableLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.remiges.logharbour.util; | ||
|
||
import com.remiges.logharbour.model.LogEntry.LogPriority; | ||
import com.remiges.logharbour.model.LogEntry.Status; | ||
|
||
import lombok.Data; | ||
|
||
import com.remiges.logharbour.model.LoggerContext; | ||
|
||
@Data | ||
public class LogHarbour implements Cloneable { | ||
|
||
private Params params; | ||
|
||
public LogHarbour(String app, String system, String module, LogPriority pri, String who, String op, String clazz, | ||
String instanceId, Status status, String error, String remoteIP, LoggerContext loggerContext) { | ||
this.params = new Params(app, system, module, pri, who, op, clazz, instanceId, status, error, remoteIP, | ||
loggerContext); | ||
} | ||
|
||
// Override the clone method | ||
@Override | ||
public LogHarbour clone() { | ||
try { | ||
LogHarbour cloned = (LogHarbour) super.clone(); | ||
cloned.params = this.params; // Share the same Params object | ||
return cloned; | ||
} catch (CloneNotSupportedException e) { | ||
throw new InternalError(e); | ||
} | ||
} | ||
|
||
public void setApp(String app) { | ||
this.params.setApp(app); | ||
} | ||
|
||
@Data | ||
private static class Params { | ||
private String app; | ||
private String system; | ||
private String module; | ||
private LogPriority pri; | ||
private String who; | ||
private String op; | ||
private String clazz; | ||
private String instanceId; | ||
private Status status; | ||
private String error; | ||
private String remoteIP; | ||
private LoggerContext loggerContext; | ||
|
||
public Params(String app, String system, String module, LogPriority pri, String who, String op, String clazz, | ||
String instanceId, Status status, String error, String remoteIP, LoggerContext loggerContext) { | ||
this.app = app; | ||
this.system = system; | ||
this.module = module; | ||
this.pri = pri; | ||
this.who = who; | ||
this.op = op; | ||
this.clazz = clazz; | ||
this.instanceId = instanceId; | ||
this.status = status; | ||
this.error = error; | ||
this.remoteIP = remoteIP; | ||
this.loggerContext = loggerContext; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Params [app=" + app + ", system=" + system + ", module=" + module + ", pri=" + pri + ", who=" + who | ||
+ ", op=" + op + ", clazz=" + clazz + ", instanceId=" + instanceId + ", status=" + status | ||
+ ", error=" + error + ", remoteIP=" + remoteIP + ", loggerContext=" + loggerContext + "]"; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters