Skip to content
nimamoosavi edited this page Aug 6, 2021 · 2 revisions

This annotation is used AOP (Aspect Oriented Programming ) for Log Data in Kafka, File Or Elasticsearch etc. This CrossCutting is implemented in Audit Project where you Can add to your Project and Log Data.

Maven Audit

<dependency>
            <groupId>app.ladderproject</groupId>
            <artifactId>audit</artifactId>
            <version>1.0.2-Release</version>
</dependency>

Guide

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Log {
    
    AuditFactory.AuditType type() default AuditFactory.AuditType.ALL;

Log annotation has an attribute which can set How To Log.

  • BEFORE ( before the methode Run ...)
  • AFTER_RETURNING (After the Result back ...)
  • AFTER_TROWING (If the methode throw Exception)
  • All ( default )
package app.ladderproject.aggregation.integration.service;

import app.ladderproject.aggregation.integration.view.req.AffairReqVM;
import app.ladderproject.aggregation.integration.view.res.AffairResVM;
import app.ladderproject.client.service.impl.MicroClientService;
import app.ladderproject.framework.anotations.Log;
import app.ladderproject.framework.domain.dto.BaseDTO;
import app.ladderproject.framework.packages.audit.view.AuditFactory;
import org.springframework.stereotype.Service;

@Service
public class AffairService extends MicroClientService<AffairReqVM, AffairResVM, Long> {


    @Override
    @Log(type = AuditFactory.AuditType.AFTER_RETURNING)
    public BaseDTO<AffairResVM> create(AffairReqVM affairReqVM) {
        return super.create(affairReqVM);
    }
}
Clone this wiki locally