What is the significance of the @Aspect annotation in Spring?
@Aspect declares a class that holds cross-cutting logic in Spring AOP. See how it is registered, how pointcuts and advice work and where proxy-based AOP stops.
2,882 posts about Java: questions with answers, tutorials and articles, newest first.
@Aspect declares a class that holds cross-cutting logic in Spring AOP. See how it is registered, how pointcuts and advice work and where proxy-based AOP stops.
Create a Spring aspect with @Aspect and @Component, add advice methods and pointcut expressions, and avoid the proxy pitfalls that stop aspects from running.
Spring AOP separates cross-cutting concerns such as logging, caching and transactions from business logic. Learn aspects, advice types and proxy limits with examples.
Use Micrometer cache metrics, Caffeine and Redis statistics and load tests to measure hit ratio, evictions and the real latency saved.
CacheAspectSupport is the base class holding Spring's caching logic. See how it handles hits, misses, puts and evictions behind the annotations.
Combine a local Caffeine cache with a shared Redis cache behind one Spring CacheManager. Includes a working TwoLevelCache and notes on staleness and stampedes.
The key attribute of @Cacheable decides which cache entry a method call uses. Learn SpEL expressions, default keys, KeyGenerator and eviction pitfalls.
Spring's cache annotations have no TTL, so expiry is set on the provider. Learn Caffeine and Redis configuration, per-cache TTLs and manual eviction.
Set up Redis as a Spring Boot cache with starters, annotations, JSON serialization, per-cache TTLs and a safe fallback when Redis is down.
@CacheEvict removes stale entries from a Spring cache when data changes. Learn key, allEntries, beforeInvocation and the pitfalls that keep old data cached.
@Cacheable stores a method's return value in a cache so repeat calls with the same arguments skip the work. See setup, keys, eviction and pitfalls.
Spring events are synchronous by default. Add @EnableAsync and @Async to move slow listeners onto an executor without blocking the publisher.
Publish custom events in Spring and handle only the ones you want with @EventListener, SpEL conditions, async execution and transactional listeners.
ApplicationListener is Spring's interface for handling events published in the context. See built-in and custom events, @EventListener and async or transactional use.
Define an event record, publish it with ApplicationEventPublisher and handle it with @EventListener. Covers async and after-commit listeners in Spring 6.
ApplicationEvent is the base type of Spring's in-process event system. See how to publish custom events and handle them with @EventListener and transactional listeners.
@EventListener makes any Spring bean method react to application events. Covers publishing, conditions, async execution and transaction-bound listeners.
Spring has no WebSocketInterceptor. Use HandshakeInterceptor for the upgrade request and ChannelInterceptor for STOMP messages, with working examples.
Step-by-step Spring Boot 3 chat using STOMP over WebSocket: configuration, controller, a stompjs browser client, security and how to scale out.
In Spring WebSocket apps, @Controller makes a class a STOMP message handler. See @MessageMapping, @SendTo, SimpMessagingTemplate and security tips.