Proxy
Transactional and security behavior often arrive through proxies that wrap target beans.
Spring is not a catalog of pure textbook patterns, but it uses many classic ideas repeatedly: Factory, Proxy, Strategy, Adapter, Template Method, Observer-style events, and more. This page maps those ideas to common Spring concepts so framework behavior feels more explainable.
Framework-driven Java development gets easier when teams can explain what the framework is doing instead of treating it as magic. Once you see proxies around transactions, strategies in pluggable resolvers, or templates in helper abstractions, the architecture becomes easier to debug and extend.
This page focuses on learning value, not on claiming one framework type equals one textbook pattern. Spring blends ideas pragmatically. The useful thing is seeing how these recurring shapes help the framework stay extensible and configurable.
Transactional and security behavior often arrive through proxies that wrap target beans.
Resolvers, converters, handlers, and policies are often represented as interchangeable strategies.
Template-style abstractions reduce repeated workflow code while allowing controlled variation.
| Pattern idea | Spring example | Why it matters |
|---|---|---|
| Proxy | Transactional AOP proxies | Cross-cutting behavior wraps business components cleanly |
| Factory | Bean factory and configuration methods | Object creation is managed and configurable |
| Strategy | HandlerMethodArgumentResolver, converters, policies | Framework extension points stay pluggable |
| Template | JdbcTemplate, earlier template abstractions | Common workflow stays fixed while small steps vary |
| Adapter | Handler adapters and integration adapters | Different components can participate behind common interfaces |
| Observer-style events | Application events and listeners | Loose in-process signaling between components |
package org.javaomnibus.reference;
public interface OrderPricingPolicy {
Money price(Order order);
}
public final class PromotionalOrderPricingPolicy implements OrderPricingPolicy {
@Override
public Money price(Order order) {
return order.total().subtract(order.promotionalDiscount());
}
}