- Import the newest version of Tracking-Spring in your maven Spring project (pom.xml):
<properties>
...
<tracking-spring.version>0.0.2</tracking-spring.version>
</properties>
<dependencies>
...
<dependency>
<groupId>io.github.h0n0riuss</groupId>
<artifactId>Tracking-Spring</artifactId>
<version>${tracking-spring.version}</version>
</dependency>
</dependencies>
- Create configuration and scan this basePackages to activate aspect (example):
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan(basePackages = "io.github.honoriuss.tracking")
public class TrackingConfig {
}
- Use @annotation to track parameters:
@PostMapping("login")
@TrackParameters(parameterNames = {"user"})
public String login(@RequestBody UserSignUpDto user) {
return homeService.login(user.username(), user.password());
}
- if no ITrackingHandler bean/component/service is implemented, all parameters are written on console.
- if no ITrackingObjectMapper bean/component/service is implemented, all parameters are mapped as JsonString.
- if no "parameterNames" are written, "defaultColumnName" + 0,1,... is used
- Implement own ITrackingHandler (example):
import io.github.honoriuss.tracking.interfaces.ITrackingHandler;
import org.springframework.stereotype.Service;
@Service
public class OwnTrackingHandler implements ITrackingHandler<String> {
@Override
public void handleTracking(String message) {
System.out.println(message);
}
}
- Implement own ITrackingObjectMapper (example):
Should match own ITrackingHandler
import io.github.honoriuss.tracking.interfaces.ITrackingObjectMapper;
import org.springframework.stereotype.Service;
@Service
public class OwnTrackingMapper implements ITrackingObjectMapper<String> {
@Override
public String mapParameters(Object[] args, String[] parameterNames) {
//implement own parameter mapping
}
@Override
public String mapResult(Object obj) {
}
}