Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public class LoggingAspect {

private final ExceptionLogRepository exceptionLogRepository;

/**
* Measures and logs the execution time of controller methods in the specified package.
*
* @param joinPoint the join point representing the intercepted method
* @return the result of the intercepted method execution
* @throws Throwable if the intercepted method throws any exception
*/
@Around("execution(* in.newdevpoint.bootcamp.controller.*.*(..))") // Pointcut expression
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Expand All @@ -26,11 +33,17 @@ public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
return proceed;
}

/****
* Logs a message before any method execution in the UserService class.
*/
@Before("execution(* in.newdevpoint.bootcamp.service.UserService.*(..))") // Pointcut expression
public void logBeforeMethod() {
System.out.println("Before method execution");
}

/**
* Logs a message after the execution of any method in the UserService class.
*/
@After("execution(* in.newdevpoint.bootcamp.service.UserService.*(..))")
public void logAfterMethod() {
System.out.println("After method execution");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package in.newdevpoint.bootcamp.exceptions;

public class UserAlreadyExistsException extends RuntimeException {
/**
* Constructs a new exception indicating that a user already exists.
*
* @param message the detail message explaining the exception
*/
public UserAlreadyExistsException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package in.newdevpoint.bootcamp.exceptions;

public class UserNotFoundException extends RuntimeException {
/**
* Constructs a new UserNotFoundException with the specified detail message.
*
* @param message the detail message explaining the reason for the exception
*/
public UserNotFoundException(String message) {
super(message);
}
Expand Down