-
Notifications
You must be signed in to change notification settings - Fork 44
docs: add JavaDoc class-level comments to resolve 46 warnings #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # This file configures Lombok for the project | ||
| # See https://projectlombok.org/features/configuration | ||
|
|
||
| # Add @Generated annotation to all Lombok-generated code | ||
| # This suppresses Javadoc warnings about missing constructor documentation | ||
| lombok.addLombokGeneratedAnnotation = true |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,9 +11,13 @@ | |||||
| import lombok.extern.slf4j.Slf4j; | ||||||
|
|
||||||
| /** | ||||||
| * The UserConfiguration class is a Spring Boot configuration class that provides configuration for the DigitalSanctuary Spring Boot User Framework | ||||||
| * Library. This class is used to configure the user framework library, including enabling asynchronous processing and scheduling, and scanning for | ||||||
| * components and repositories. | ||||||
| * Main auto-configuration class for the DigitalSanctuary Spring Boot User Framework Library. | ||||||
| * Enables asynchronous processing, retry support, scheduling, method-level security, | ||||||
| * and component scanning for the user framework package. | ||||||
| * | ||||||
| * <p>Default constructor creates an instance of this configuration.</p> | ||||||
| * | ||||||
|
||||||
| * <p>Default constructor creates an instance of this configuration.</p> | |
| * |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,15 +6,31 @@ | |||||||||||||||
| import lombok.Data; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * The AuditConfig class is a Spring Boot configuration class that provides properties for configuring user audit logging. This class is used to | ||||||||||||||||
| * define properties that control the behavior of the audit logging, such as the log file path and the flush rate. | ||||||||||||||||
| * Configuration properties for the user audit logging system. | ||||||||||||||||
| * | ||||||||||||||||
| * <p>This class defines properties that control the behavior of audit logging, | ||||||||||||||||
| * including the log file path, flush behavior, and event logging toggle. | ||||||||||||||||
| * Properties are bound from the {@code user.audit.*} prefix in application configuration. | ||||||||||||||||
| * | ||||||||||||||||
| * <p>The class uses Lombok's {@code @Data} annotation which generates getters, setters, | ||||||||||||||||
| * and a default no-argument constructor. | ||||||||||||||||
| * | ||||||||||||||||
| * @see AuditLogWriter | ||||||||||||||||
| * @see AuditEventListener | ||||||||||||||||
| */ | ||||||||||||||||
| @Data | ||||||||||||||||
| @Component | ||||||||||||||||
| @PropertySource("classpath:config/dsspringuserconfig.properties") | ||||||||||||||||
| @ConfigurationProperties(prefix = "user.audit") | ||||||||||||||||
| public class AuditConfig { | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Creates a new AuditConfig instance with default values. | ||||||||||||||||
| */ | ||||||||||||||||
| public AuditConfig() { | ||||||||||||||||
| // Default constructor for Spring configuration binding | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
|
||||||||||||||||
| * Creates a new AuditConfig instance with default values. | |
| */ | |
| public AuditConfig() { | |
| // Default constructor for Spring configuration binding | |
| } | |
| /** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,25 +3,43 @@ | |
| import org.springframework.context.event.EventListener; | ||
| import org.springframework.scheduling.annotation.Async; | ||
| import org.springframework.stereotype.Component; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| /** | ||
| * This class processes AuditEvents. This class writes the AuditEvent data to a text file on the server. You could easily change the logic to write to | ||
| * a database, send events to a REST API, or anything else. | ||
| * Spring event listener that processes {@link AuditEvent} instances asynchronously. | ||
| * | ||
| * <p>This component listens for audit events and delegates the writing of event data | ||
| * to an {@link AuditLogWriter} implementation. The processing is asynchronous to avoid | ||
| * impacting application performance. | ||
| * | ||
| * <p>The listener only processes events when audit logging is enabled via | ||
| * {@code AuditConfig.isLogEvents()}. All exceptions are caught and logged to ensure | ||
| * audit failures never impact application flow. | ||
| * | ||
| * @see AuditEvent | ||
| * @see AuditLogWriter | ||
| * @see AuditConfig | ||
| */ | ||
| @Slf4j | ||
| @Async | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class AuditEventListener { | ||
|
|
||
| private final AuditConfig auditConfig; | ||
|
|
||
| private final AuditLogWriter auditLogWriter; | ||
|
|
||
| /** | ||
| * Creates a new AuditEventListener with the required dependencies. | ||
| * | ||
| * @param auditConfig the audit configuration | ||
| * @param auditLogWriter the audit log writer | ||
| */ | ||
| public AuditEventListener(AuditConfig auditConfig, AuditLogWriter auditLogWriter) { | ||
| this.auditConfig = auditConfig; | ||
| this.auditLogWriter = auditLogWriter; | ||
| } | ||
|
||
|
|
||
| /** | ||
| * Handle the AuditEvents. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,41 +3,42 @@ | |
| import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
| import org.springframework.scheduling.annotation.Scheduled; | ||
| import org.springframework.stereotype.Component; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| /** | ||
| * The FileAuditLogFlushScheduler class is a Spring Boot component that flushes the audit log buffer to the file. This class is used to ensure that | ||
| * the audit log buffer is flushed periodically to balance performance with data integrity. | ||
| * | ||
| * <p><strong>Conditional Activation Logic:</strong></p> | ||
| * <p>This scheduler is only active when BOTH conditions are met:</p> | ||
| * Scheduled task that periodically flushes the audit log buffer to disk. | ||
| * | ||
| * <p>This component ensures buffered audit data is written to the file at regular intervals, | ||
| * balancing write performance with data integrity. | ||
| * | ||
| * <p><strong>Conditional Activation:</strong> This scheduler is only active when both conditions are met: | ||
| * <ul> | ||
| * <li><code>user.audit.logEvents=true</code> (audit logging is enabled) AND</li> | ||
| * <li><code>user.audit.flushOnWrite=false</code> (immediate flush is disabled)</li> | ||
| * <li>{@code user.audit.logEvents=true} - audit logging is enabled</li> | ||
| * <li>{@code user.audit.flushOnWrite=false} - immediate flush is disabled</li> | ||
| * </ul> | ||
| * | ||
| * <p><strong>Why this conditional logic?</strong></p> | ||
| * <ul> | ||
| * <li>If audit logging is disabled (<code>logEvents=false</code>), no scheduler is needed</li> | ||
| * <li>If flush-on-write is enabled (<code>flushOnWrite=true</code>), logs are flushed immediately after each write, | ||
| * so periodic flushing is unnecessary and would be redundant</li> | ||
| * <li>Only when audit logging is enabled AND flush-on-write is disabled do we need this periodic scheduler | ||
| * to ensure buffered data gets written to disk at regular intervals</li> | ||
| * </ul> | ||
| * | ||
| * <p>The flush frequency is controlled by <code>user.audit.flushRate</code> (in milliseconds).</p> | ||
| * | ||
| * <p>When flush-on-write is enabled, logs are flushed immediately after each write, | ||
| * making this scheduler unnecessary. The flush frequency is controlled by | ||
| * {@code user.audit.flushRate} (in milliseconds). | ||
| * | ||
| * @see FileAuditLogWriter | ||
| * @see AuditConfig | ||
| */ | ||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| @ConditionalOnExpression("${user.audit.logEvents:true} && !${user.audit.flushOnWrite:true}") | ||
| public class FileAuditLogFlushScheduler { | ||
|
|
||
| private final FileAuditLogWriter fileAuditLogWriter; | ||
|
|
||
| /** | ||
| * The file audit log writer. This is the writer that is used to write audit log events to the file. | ||
| * Creates a new FileAuditLogFlushScheduler with the required dependencies. | ||
| * | ||
| * @param fileAuditLogWriter the file audit log writer to flush | ||
| */ | ||
| private final FileAuditLogWriter fileAuditLogWriter; | ||
| public FileAuditLogFlushScheduler(FileAuditLogWriter fileAuditLogWriter) { | ||
| this.fileAuditLogWriter = fileAuditLogWriter; | ||
| } | ||
|
||
|
|
||
| /** | ||
| * Flushes the audit log buffer to the file. This method is called on a schedule to ensure that the buffer is flushed periodically to balance | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,21 +12,42 @@ | |
| import org.springframework.util.StringUtils; | ||
| import jakarta.annotation.PostConstruct; | ||
| import jakarta.annotation.PreDestroy; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| /** | ||
| * Implementation of {@link AuditLogWriter} that writes audit logs to a file. This class handles the lifecycle of the log file, including opening, | ||
| * writing, and closing the file. It also supports scheduled flushing of the buffer to balance performance with data integrity. | ||
| * File-based implementation of {@link AuditLogWriter} that writes audit events to a log file. | ||
| * | ||
| * <p>This component manages the complete lifecycle of the audit log file, including: | ||
| * <ul> | ||
| * <li>Opening and creating the log file on startup ({@code @PostConstruct})</li> | ||
| * <li>Writing formatted audit events with pipe-delimited fields</li> | ||
| * <li>Periodic buffer flushing via {@link FileAuditLogFlushScheduler}</li> | ||
| * <li>Graceful cleanup on shutdown ({@code @PreDestroy})</li> | ||
| * </ul> | ||
| * | ||
| * <p>If the configured log path is not writable, the writer falls back to a temporary | ||
| * directory location. | ||
| * | ||
| * @see AuditLogWriter | ||
| * @see AuditConfig | ||
| * @see FileAuditLogFlushScheduler | ||
| */ | ||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class FileAuditLogWriter implements AuditLogWriter { | ||
|
|
||
| private final AuditConfig auditConfig; | ||
| private BufferedWriter bufferedWriter; | ||
|
|
||
| /** | ||
| * Creates a new FileAuditLogWriter with the required dependencies. | ||
| * | ||
| * @param auditConfig the audit configuration | ||
| */ | ||
| public FileAuditLogWriter(AuditConfig auditConfig) { | ||
| this.auditConfig = auditConfig; | ||
| } | ||
|
||
|
|
||
| /** | ||
| * Initializes the log file writer. This method is called after the bean is constructed. It validates the configuration and opens the log file for | ||
| * writing. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment "Default constructor creates an instance of this registrar" is unnecessary. This class doesn't have any dependencies and uses the implicit Java-generated default constructor. This comment adds no value and should be removed.