`
sillycat
  • 浏览: 2542545 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

AspectJ(3)Examples

 
阅读更多
AspectJ(3)Examples

Chapter 3. Examples
3.1 Obtaining, Compiling and Running the Examples
I download the aspectj stable version with these URLs
http://mirror.neu.edu.cn/eclipse/tools/aspectj/aspectj-1.6.12-src.jar
http://download.actuatechina.com/eclipse/tools/aspectj/aspectj-1.6.12.jar

Double click aspectj-1.6.12.jar, install aspectj in my local machine. I install it in d:/tool directory.
And I add this location D:\tool\aspectj1.6.12\bin to my system PATH.
Add location D:\tool\aspectj1.6.12\lib\aspectjrt.jar to my system CLASSPATH

And all the example is in this directory D:\tool\aspectj1.6.12\doc\examples\.
>cd D:\tool\aspectj1.6.12\doc\examples\
>ajc -argfile telecom/billing.lst
>java telecom.BillingSimulation

3.2. Basic Techniques
Join Points and thisJoinPoint
(examples/tjp)
When using a pointcut that picks out join points of a single kind by name, typicaly the advice will know exactly what kind of join point it is associated with.
thisJoinPoint    JoinPoint
Object[] args = jp.getArgs();
String[] names = ((CodeSignature)jp.getSignature()).getParameterNames();
Class[] types = ((CodeSignature)jp.getSignature()).getParameterTypes();

cflow(this(Demo) && execution(void go()));
So that only executions made in the control flow of Demo.go are iintercepted. !execution(* go()) to exclude go itself.

Roles and Views
examples/introduction
Unlike advice, inter-type declarations affect not only the behavior of the application, but also the structural relationship between an application's classes.
The Point class -----> The CloneablePoint aspect
public aspect CloneablePoint{
...snip...
declare parents: Point implements Cloneable;
public Object Point.clone() throws CloneNotSupportedException{
makeRectangular();
makePolar();
return super.clone();
}
...snip...
}

The ComparablePoint aspect
The HashablePoint aspect

3.3. Development Aspects
Tracing using aspects
examples/tracing
Sometimes, tracing is one of those things that slows the system down, so these calls should often be pulled out of the system before the product is shipped.

3.4. Production Aspects
A Bean Aspect
examples/bean
The Point class ----> The BoundPoint aspect
...snip..
private PropertyChangeSupport Point.support = new PropertyChangeSupport(this);
...snip...
class Demo implements PropertyChangeListener
...snip...

The Subject/Observer Protocol
examples/observer

A Simple Telecom Simulation
examples/telecom

3.5. Reusable Aspects
Tracing using Aspects, Revisited

references:
http://www.eclipse.org/aspectj/doc/released/progguide/examples.html



分享到:
评论

相关推荐

    org.aspectj,aspectj项目库(org.aspectj).zip

    8. **examples**:示例代码,帮助用户理解如何使用AspectJ。 9. **.idea**或**.project**:IDE相关的配置文件,通常用于Eclipse或IntelliJ IDEA。 通过深入研究这些文件,开发者可以了解到AspectJ的实现细节,学习...

    aspectj.zip

    3. **examples** - 提供了一些示例代码,演示了如何使用AspectJ进行切面编程,包括切点定义、通知类型(前置通知、后置通知、环绕通知等)以及切面的编写。 4. **src** - 可能包含AspectJ的源代码,对于学习其内部...

    Manning-AspectJInAction

    To further complicate the situation, the examples of AOP that are widely available today either repeat the same logging problem or are too abstract to be of immediate practical value. My mission ...

    AspectJCookBook 源码

    该压缩包包含两部分主要内容:一本名为《Oreilly.AspectJ.Cookbook.Dec.2004.eBook-LiB.chm》的电子书和一个名为`aspectjcookbook_examples.zip`的源码文件夹。 电子书《AspectJ Cookbook》提供了丰富的示例和解释...

    Spring Recipes: A Problem-Solution Approach, Second Edition

    With over 3 Million users/developers, Spring Framework is the leading “out of the box” Java framework. Spring addresses and offers simple solutions for most aspects of your Java/Java EE application ...

    Spring中文帮助文档

    2.3.4. 对AspectJ装载时织入(AspectJ load-time weaving)的支持 2.4. 中间层 2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. 对Websphere 事务管理的完整支持 2.4.3. JPA 2.4.4. 异步的JMS 2.4.5. JDBC ...

    Spring API

    2.3.4. 对AspectJ装载时织入(AspectJ load-time weaving)的支持 2.4. 中间层 2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. 对Websphere 事务管理的完整支持 2.4.3. JPA 2.4.4. 异步的JMS 2.4.5. JDBC ...

    GitHub优秀的学习总结资料4

    - `spring-boot-examples`:可能包含更多的Spring Boot实战示例,涵盖不同场景和功能的应用。 3. **Spring Security**: `shirodemo-master`:Apache Shiro是另一个Java安全框架,常用于身份验证、授权、会话管理...

    spring2.0技术手册 源代码例子

    7. **AspectJ集成**:Spring 2.0开始支持AspectJ,可以进行类型级别的AOP编程,提供更强大的切面定义能力。 8. **国际化(i18n)与本地化(l10n)**:Spring提供了方便的工具和支持,使应用程序能够根据用户区域...

    基于SpringMVC+Hibernate4的考勤管理系统+.zip

    poi-examples-3.15.jar poi-excelant-3.15.jar poi-ooxml-3.15.jar poi-ooxml-schemas-3.15.jar poi-scratchpad-3.15.jar spring-aop-4.0.0.RELEASE.jar 使用Spring 的AOP 特性时所需的类和源码级元数据支持 spring-...

    springside示例quickstart的eclipse工程

    3. **src/main/resources**:这是存放资源配置文件的地方,如Spring的bean定义XML文件(可能命名为applicationContext.xml或类似),Hibernate的映射文件(.hbm.xml),以及日志配置(log4j.properties)等。...

    Barter - beyond design by contract-开源

    3. `build.xml`:Ant构建脚本,用于自动化构建、测试和打包项目,是Java项目中常见的构建配置文件。 4. `src`:源代码目录,存放Barter的Java源代码,开发者可以通过阅读这些代码来深入理解Barter的工作原理。 5. `...

    spring-framework-reference4.1.4

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    spring-framework-reference-4.1.2

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    Maven权威指南 很精典的学习教程,比ANT更好用

    3. Font Conventions 4. Maven Writing Conventions 5. Acknowledgements 1. 介绍 Apache Maven 1.1. Maven... 它是什么? 1.2. 约定优于配置(Convention Over Configuration) 1.3. 一个一般的接口 1.4. ...

Global site tag (gtag.js) - Google Analytics