JiveJdon Community Forums
在线206人 J道首页 | 论坛首页 | 培训咨询 | 开源框架 | 精华 | 查搜 | 注册 | 登陆 |
首页 » 论坛 » 项目工程开发经验谈
???en_US.forumThreadPrev.name??? 上一主题
Go back to the topic listing   返回主题列表
???en_US.forumThreadNext.name??? 下一主题
这个主题共有 4 回复 / 1 页 [ ]  发表新帖子  回复该主题贴
justin

发表文章: 8
注册时间: 2002年11月04日 21:38
有用AspectJ开发项目的么?或者计划 发表: 2003年12月07日 22:01 回复
希望能和对此有过研究的人进行讨论。

我看了些aosd的论文,也从citeseer上找了些paper看了看,但实际
的项目还没看到用过AOP的。
banq

发表文章: 8914
注册时间: 2002年08月03日 17:08
Re: 有用AspectJ开发项目的么?或者计划 发表: 2003年12月16日 17:50 回复
JBoss 4.0用AOP开发的
fiddle

发表文章: 113
注册时间: 2003年12月17日 17:54
Re: 有用AspectJ开发项目的么?或者计划 发表: 2003年12月17日 18:11 回复
想学习,有达人领领路么?
justin

发表文章: 8
注册时间: 2002年11月04日 21:38
Re: 有用AspectJ开发项目的么?或者计划 发表: 2003年12月25日 09:44 回复
http://www.aosd.net/

google:[ aspect oriented programming filetype:pdf ]

citeseer.nj.nec.com/cs:[ AOP ]


其中
http://www.aosd.net/archive/index.php
有近两年AOSD会议在ACM的论文集


最近我主要在想两个Aspect,一个就是缓存,还有一个是异常

.NET有个AspectC++ Add-In,上面缓存的例子很不错
以下是code:
aspect

#include "ResultCache.h"

aspect cache {
advice call(
"% square(...)") : around () {
if (!cache.find(*(unsigned*)tjp->arg(0), tjp->result())) {
tjp->proceed();
cache.insert(*(unsigned*)tjp->arg(0), *tjp->result());
}
}
};

test code

#include <stdio.h>
#if defined(i386)
#include <unistd.h>
#endif

unsigned square(unsigned s) {
#if defined(i386)
sleep(1);
#else
volatile int j=0;
for (unsigned i=1; i<10000000; i++) j++;
#endif
return s*s;
}

int main() {
for (unsigned i=0; i<2; i++) {
for (unsigned s=0; s<10; s++) {
printf(
"square(%d, %d)\n", s, square(s));
}
}
getchar();
}


缓存和求平方两个关注点分离了。


异常似乎比较麻烦, 主要是出现exception后forward到何地需要解决,比如通常的SQLException...

有一篇paper:‘a study on exception detection and handling using aspect-oriented programming’值得一看。


先给一个很土的例子(别骂)

package net.tongji.hzt;

aspect ExceptionHandle {

pointcut all():
execution(* *(..));

before() throwing(Exception e) : all() {
System.out.println(
"[" + e + "]@"
+ thisJoinPoint.getSignature());
System.exit(1);
}
}

上面的~aspect~表示, 所有类的所有方法中, 只要出现异常,
就记录异常出现的位置, 并终止程序的执行。

以下是一个将要被上面的~aspect~注射的代码:

package net.tongji.hzt;

public class Main {

public static void main(String[] args) {
System.out.println(
"before call foo");
foo();
System.out.println(
"done with call to foo");
}

static void foo() {;
String nullstring = null;
if (nullstring.equals(
"nullstring")) {
System.out.println(
"if::true");
}
}
}


快考试了,没时间想这些问题了,下学起来了可能会实践一下 ;)



justin

发表文章: 8
注册时间: 2002年11月04日 21:38
Re: 有用AspectJ开发项目的么?或者计划 发表: 2003年12月25日 09:48 回复
AOP 实现 23 种模式
http://www.cs.ubc.ca/~jan/AODPs/

虽然感觉aspectj实现的23GoF patterns很别扭,但还是值得讨论的。
这个主题有 4 回复 / 1 页 [ ]
???en_US.forumThreadPrev.name??? 上一主题
Go back to the topic listing   返回主题列表    返回页首  返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Spring Struts
查询本论坛内 回复超过的热门帖子
快速发表回复
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
 

解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-07 jdon.com

anti spam