Class LoggedTargetGuardBeanPostProcessor
- All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor
Logged is applied to a method on a
class that should never carry observability instrumentation: a JPA
entity, a Spring Data repository interface implementation, or a class
annotated with @Repository.
Instrumenting these layers is almost always a mistake. Entities are plain data holders whose getters can be invoked extremely frequently (for example during JSON serialization or JPA dirty checking), turning a single request into thousands of log lines and metric updates. Repositories are already covered by lower-level persistence metrics (query timing, connection pool statistics); wrapping every repository call in the same interceptor as business logic tends to blur, rather than clarify, what is slow.
This check runs once per bean, before Spring's AOP auto-proxy creator
wraps the bean, so it inspects the original target class rather than a
proxy. It intentionally does not import jakarta.persistence.Entity,
org.springframework.stereotype.Repository, or
org.springframework.data.repository.Repository directly, and
instead compares fully qualified names through reflection. This keeps
this module free of a hard dependency on JPA or Spring Data, so consumers
who use neither are not forced to bring them onto the classpath.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionpostProcessBeforeInitialization(Object bean, @NonNull String beanName) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor
postProcessAfterInitialization
-
Constructor Details
-
LoggedTargetGuardBeanPostProcessor
public LoggedTargetGuardBeanPostProcessor()
-
-
Method Details
-
postProcessBeforeInitialization
public Object postProcessBeforeInitialization(Object bean, @NonNull String beanName) throws org.springframework.beans.BeansException - Specified by:
postProcessBeforeInitializationin interfaceorg.springframework.beans.factory.config.BeanPostProcessor- Throws:
org.springframework.beans.BeansException
-