Spring AOP是用純Java實現的。 不需要特殊的編譯過程。 Spring AOP不需要控制類加載器層次結構,因此適合在Servlet容器或應用程序服務器中使用。
Spring AOP目前僅支持方法執行連接點(建議在Spring bean上執行方法)。 雖然可以在不破壞核心Spring AOP API的情況下添加對字段攔截的支持,但并未實現字段攔截。 如果您需要建議字段訪問和更新連接點,請考慮使用AspectJ等語言。
Spring AOP的AOP方法與大多數其他AOP框架的方法不同。 目的不是提供最完整的AOP實現(盡管Spring AOP非常強大); 它是在AOP實現和Spring IoC之間提供緊密集成,以幫助解決企業應用程序中的常見問題。
因此,例如,Spring Framework的AOP功能通常與Spring IoC容器一起使用。 使用普通bean定義語法配置切面(盡管這允許強大的“自動代理”功能):這是與其他AOP實現的重要區別.使用Spring AOP有些事情是沒辦法做到的,例如建議非常細粒度的對象(例如域對象):在這種情況下,AspectJ是最佳選擇。 但是,我們的經驗是,Spring AOP為企業Java應用程序中的大多數問題提供了出色的解決方案。
Spring AOP永遠不會嘗試與AspectJ競爭,以提供全面的AOP解決方案。 我們相信像Spring AOP這樣的基于代理的框架和像AspectJ這樣的完整框架都很有價值,而且它們是互補的,而不是競爭。 Spring將Spring AOP和IoC與AspectJ無縫集成,以便在一致的基于Spring的應用程序架構中滿足AOP的所有使用需求。 此集成不會影響Spring AOP API或AOP Alliance API:Spring AOP保持向后兼容。 有關Spring AOP API的討論,請參閱以下章節。
>Spring框架的核心原則之一是非侵入性; 這是因為您不應該被迫在您的業務/域模型中引入特定于框架的類和接口。 但是,在某些地方,Spring Framework確實為您提供了將Spring Framework特定的依賴項引入代碼庫的選項:為您提供此類選項的基本原理是因為在某些情況下,它可能更容易閱讀或編寫某些特定的部分 以這種方式的功能。 Spring Framework(幾乎)總是為您提供選擇:您可以自由決定哪種選項最適合您的特定用例或場景。
>
>與本章相關的一個選擇是選擇哪種AOP框架(以及哪種AOP樣式)。 您可以選擇AspectJ和/或Spring AOP,也可以選擇@AspectJ注釋樣式方法或Spring XML配置樣式方法。 本章首先選擇引入@ AspectJ風格的方法,這一事實不應被視為Spring團隊傾向于采用Spring XML配置風格的@AspectJ注釋風格方法。
>與本章相關的一個選擇是選擇哪種AOP框架(以及哪種AOP樣式)。 您可以選擇AspectJ和/或Spring AOP,也可以選擇@AspectJ注解樣式方法或Spring XML配置樣式方法。 本章首先選擇引入@ AspectJ風格的方法,這一事實不代表Spring團隊偏愛@AspectJ注釋風格比Spring XML配置風格好。
- 正確打開本書的姿勢
- 第一部分 Core
- 1. Ioc container
- 1.1. Introduction to the Spring IoC container and beans
- 1.2. Container overview
- 1.2.1. Configuration metadata
- 1.2.2. Instantiating a container
- 1.2.3. Using the container
- 1.3. Bean overview
- 1.3.1. Naming beans
- 1.3.2. Instantiating beans
- 1.4. Dependencies
- 1.4.1. Dependency Injection
- 1.4.2. Dependencies and configuration in detail
- 1.4.3. Using depends-on
- 1.4.4. Lazy-initialized beans
- 1.4.5. Autowiring collaborators
- 1.4.6. Method injection
- 1.5 Bean Scopes
- 1.6. Customizing the nature of a bean TODO
- 1.7. Bean definition inheritance TODO
- 1.8. Container Extension Points TODO
- 1.9. Annotation-based container configuration
- 1.9.1. @Required
- 1.9.2. @Autowired
- 1.9.3. Fine-tuning annotation-based autowiring with @Primary
- 1.9.4. Fine-tuning annotation-based autowiring with qualifiers TODO
- 1.9.5. Using generics as autowiring qualifiers TODO
- 1.9.6. CustomAutowireConfigurer TODO
- 1.10. Classpath scanning and managed components
- 1.10.1. @Component and further stereotype annotations
- 1.11. Using JSR 330 Standard Annotations TODO
- 1.12. Java-based container configuration
- 1.12.1. Basic concepts: @Bean and @Configuration
- 1.12.2. Instantiating the Spring container using AnnotationConfigApplicationContext
- 2. Resources
- 2.1. Introduction
- 2.2. The Resource interface
- 2.3. Built-in Resource implementations
- 2.3.1. UrlResource
- 2.3.2. ClassPathResource
- 2.3.3. FileSystemResource
- 2.3.4. ServletContextResource
- 2.3.5. InputStreamResource
- 2.3.6. ByteArrayResource
- 2.4. The ResourceLoader
- 2.5. The ResourceLoaderAware interface
- 2.6. Resources as dependencies
- 2.7. Application contexts and Resource paths
- 2.7.1. Constructing application contexts
- 2.7.2. Wildcards in application context constructor resource paths
- 2.7.3. FileSystemResource caveats
- 3. Validation, Data Binding, and Type Conversion
- 4. Spring Expression Language (SpEL)
- 5. Aspect Oriented Programming with Spring
- 5.1. Introduction
- 5.1.1. AOP concepts
- 5.1.2. Spring AOP capabilities and goals
- 5.1.3. AOP Proxies
- 5.2. @AspectJ support
- 5.2.1. Enabling @AspectJ Support
- 5.2.2. Declaring an aspect
- 5.2.3. Declaring a pointcut
- 5.2.4. Declaring advice
- 5.2.5. Introductions TODO
- 5.2.6. Aspect instantiation models TODO
- 5.2.7. Example
- 5.3. Schema-based AOP support TODO
- 5.4. Choosing which AOP declaration style to use TODO
- 5.5. Mixing aspect types TODO
- 5.6. Proxying mechanisms
- 5.6.1. Understanding AOP proxies
- 5.7. Programmatic creation of @AspectJ Proxies
- 5.8. Using AspectJ with Spring applications
- 5.8.1. Using AspectJ to dependency inject domain objects with Spring
- 5.8.2. Other Spring aspects for AspectJ
- 第二部分 Testing
- 第三部分 Data Access
- 1. Transaction Management
- 1.1. Introduction to Spring Framework transaction management
- 1.2 Advantages of the Spring Framework’s transaction support model
- 1.2.1. Global transactions
- 1.2.2. Local transactions
- 1.2.3. Spring Framework’s consistent programming model
- 1.3. Understanding the Spring Framework transaction abstraction
- 1.4. Synchronizing resources with transactions
- 1.4.1. High-level synchronization approach
- 1.4.2. Low-level synchronization approach
- 1.4.3. TransactionAwareDataSourceProxy
- 1.5. Declarative transaction management
- 1.5.1. Understanding the Spring Framework’s declarative transaction implementation
- 1.5.2. Example of declarative transaction implementation
- 1.5.3. Rolling back a declarative transaction
- 1.5.4. Configuring different transactional semantics for different beans
- 1.5.5. tx:advice元素的 settings
- 1.5.6. Using @Transactional
- 1.5.7. Transaction propagation
- 1.5.8. Advising transactional operations
- 1.5.9. Using @Transactional with AspectJ TODO
- 第四部分 web servlet
- 第五部分 Web Reactive
- 第六部分 Integration
- 第七部分 Languages