`
george.gu
  • 浏览: 73418 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

AOP(3): Spring AOP

 
阅读更多

AOP References

  1. Please refer to Spring Framework AOP specification site for more details on spring aop concepts.
  2. General introduction to Aspect-Oriented Programming

Aspect

Aspect is "cross-cutting concern". For example:

  1. Transaction Management Aspect
  2. Logging Aspect  
  3. Security Aspect 

Transaction Management Aspect

Transaction is required in many enterprise application:

 

  • Before launch an operation, we should initialize an transaction to make sure the operation is atomic.
  • After each operation, we should make sure transaction is submit.
  • If any error happen during operation, we should make sure the Transaction rollback.
  • ...

 

All of those requirements are common to each enterprise applications regardless of the business requirements.

Security Aspect

There are many approaches to authenticate and authorize user's permission to manipulate specific system resources. Security Aspect can solve the scenario like: 

 

  • Some Methods can only be invoked by invoker who has specific permission. And all those checkings are before invocation.
  • Some User Interface or operation can only be show to specific user roles.
  • ...

 

For example,  Acegi and Spring security will manage security with AOP ascpect.

Logging Aspect

Logging is necessary requirement for all enterprise applications. We can use logging to trace/monitor the system status:

 

  • Trace methods invocation start/complete/failed...
  • Trace user operation on the server...
  • Trace data transmitting state during business logical...
  • ...

All those functions are common and not related to any business. We can manage logging in AOP aspect.

Pointcut

In Spring AOP, "Pointcut" define the points where aspect operations should be injected during business logical running. In Spring AOP, a join point always represents a method execution.

There are several kinds of Pointcut definition.

The execution of any public method 

execution(public * *(..)) 

 

The execution of any method with a name beginning with "set"

 

execution(* set*(..)) 
  

The execution of any method defined by the AccountService interface 

execution(* com.xyz.service.AccountService.*(..)) 
  

The execution of the process method taking a String in argument 

execution(public * com.xyz.service.BillingService.process(String)) 

The execution of the process method taking any argument, returning an Integer 

execution(public Integer com.xyz.service.BillingService.process(..))
 

 


分享到:
评论

相关推荐

    spring-aop-5.0.10.RELEASE-API文档-中文版.zip

    赠送jar包:spring-aop-5.0.10.RELEASE.jar; 赠送原API文档:spring-aop-5.0.10.RELEASE-javadoc.jar; 赠送源代码:spring-aop-5.0.10.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.0.10.RELEASE....

    spring-aop.jar各个版本

    spring-aop-1.1.1.jar spring-aop-1.2.6.jar spring-aop-1.2.9.jar spring-aop-2.0.2.jar spring-aop-2.0.6.jar spring-aop-2.0.7.jar spring-aop-2.0.8.jar spring-aop-2.0.jar spring-aop-2.5.1.jar spring-aop-...

    spring-aop-5.2.0.RELEASE-API文档-中文版.zip

    赠送jar包:spring-aop-5.2.0.RELEASE.jar; 赠送原API文档:spring-aop-5.2.0.RELEASE-javadoc.jar; 赠送源代码:spring-aop-5.2.0.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.2.0.RELEASE.pom;...

    第四章:Spring AOP API 设计模式1

    3. **工厂方法模式(Factory Method)**:Spring AOP中的`ProxyFactory`是一个典型的工厂方法模式实现,它根据不同的条件创建不同的代理对象,将实例化推迟到子类,提供了更大的灵活性。 4. **原型模式(Prototype...

    spring aop注解方式、xml方式示例

    Spring AOP(面向切面编程)是Spring框架的重要组成部分,它提供了一种强大的方式来实现横切关注点,如日志、事务管理、性能监控等,而无需侵入业务代码。下面将详细介绍Spring AOP的注解方式和XML配置方式。 ### ...

    spring-aop-5.0.8.RELEASE-API文档-中英对照版.zip

    赠送jar包:spring-aop-5.0.8.RELEASE.jar; 赠送原API文档:spring-aop-5.0.8.RELEASE-javadoc.jar; 赠送源代码:spring-aop-5.0.8.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.0.8.RELEASE.pom;...

    简单spring aop 例子

    Spring AOP(面向切面编程)是Spring框架的重要组成部分,它提供了一种模块化和声明式的方式来处理系统中的交叉关注点问题,如日志、事务管理、安全性等。本示例将简要介绍如何在Spring应用中实现AOP,通过实际的...

    spring-aop-5.3.15-API文档-中英对照版.zip

    赠送jar包:spring-aop-5.3.15.jar; 赠送原API文档:spring-aop-5.3.15-javadoc.jar; 赠送源代码:spring-aop-5.3.15-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.3.15.pom; 包含翻译后的API文档:spring...

    spring-aop-5.3.12-API文档-中英对照版.zip

    赠送jar包:spring-aop-5.3.12.jar; 赠送原API文档:spring-aop-5.3.12-javadoc.jar; 赠送源代码:spring-aop-5.3.12-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.3.12.pom; 包含翻译后的API文档:spring...

    Spring基础:Spring AOP简单使用

    3. **配置AOP** - **XML配置**:在Spring的配置文件中,可以使用<aop:config>标签来定义切面,<aop:pointcut>定义切点,<aop:advisor>定义通知,<aop:aspect>将切点和通知关联起来。 - **注解配置**:Spring 2.5...

    spring-aop-5.3.10-API文档-中文版.zip

    赠送jar包:spring-aop-5.3.10.jar; 赠送原API文档:spring-aop-5.3.10-javadoc.jar; 赠送源代码:spring-aop-5.3.10-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.3.10.pom; 包含翻译后的API文档:spring...

    spring-aop-5.3.15-API文档-中文版.zip

    赠送jar包:spring-aop-5.3.15.jar; 赠送原API文档:spring-aop-5.3.15-javadoc.jar; 赠送源代码:spring-aop-5.3.15-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.3.15.pom; 包含翻译后的API文档:spring...

    spring-aop-6.0.2.jar

    spring-aop-6.0.2.jar

    spring-aop-5.2.15.RELEASE-API文档-中文版.zip

    赠送jar包:spring-aop-5.2.15.RELEASE.jar; 赠送原API文档:spring-aop-5.2.15.RELEASE-javadoc.jar; 赠送源代码:spring-aop-5.2.15.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.2.15.RELEASE....

    Java流行框架源码分析:Spring源码、SpringBoot源码、SpringAOP源码、SpringSecurity源码、

    Java流行框架源码分析:Spring源码、SpringBoot源码、SpringAOP源码、SpringSecurity源码、SpringSecurity OAuth2源码、JDK源码、Netty源码

    Spring AOP面向方面编程原理:AOP概念

    3. **灵活的通知模型**:Spring AOP提供了多种类型的通知,包括around、before、after returning、after throwing等,使得开发者可以根据实际需求选择最适合的通知类型。 4. **丰富的切入点表达式语言**:Spring ...

    spring-aop-4.2.2.RELEASE-API文档-中文版.zip

    赠送jar包:spring-aop-4.2.2.RELEASE.jar; 赠送原API文档:spring-aop-4.2.2.RELEASE-javadoc.jar; 赠送源代码:spring-aop-4.2.2.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring-aop-4.2.2.RELEASE.pom;...

    Spring 2.5 AOP 例子

    3. `<aop:pointcut>`:定义一个切点表达式,匹配特定的方法或类。 4. `<aop:before>`、`<aop:after>`、`<aop:around>`、`<aop:after-returning>`和`<aop:after-throwing>`:分别用于定义在目标方法执行前、后、环绕...

    spring-boot aop

    Spring Boot AOP(面向切面编程)是一种强大的设计模式,它允许我们在不修改现有代码的情况下,插入额外的功能或监控代码。在Spring框架中,AOP主要用于日志记录、事务管理、性能统计等场景。本示例是关于如何在...

    spring-aop-5.1.3.RELEASE-API文档-中英对照版.zip

    赠送jar包:spring-aop-5.1.3.RELEASE.jar; 赠送原API文档:spring-aop-5.1.3.RELEASE-javadoc.jar; 赠送源代码:spring-aop-5.1.3.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring-aop-5.1.3.RELEASE.pom;...

Global site tag (gtag.js) - Google Analytics