c******n 发帖数: 4965 | 1 the aspectJ docs refer to "aspectJtools.jar", but this jar is only present
in aspectj 1.1, and seems to be no longer present,
so the docs are out-dated.
but how can I define an ant task for aspectj??
I can't use eclipse build only because we need an ant task for automatic
builds
thanks |
|
S*O 发帖数: 52 | 2 what's diff between a aspect.java and aspect.aj (if they have the same content
) ?
how aspectJ weaver be triggered? |
|
c******n 发帖数: 4965 | 3 I have many existing methods
method1() ...
method2() ...
method3() ....
they all throw SomeException. now I want to wrap these methods so that each
inside simply does try {} catch (){} where the inside of the try loop does
the
original work, and in catch() I recast the exception into SOMEOtherException.
is this possible with AspectJ ?
I guess not??? since it changes the signature..... |
|
c******n 发帖数: 4965 | 4 I have many existing methods
method1() ...
method2() ...
method3() ....
they all throw SomeException. now I want to wrap these methods so that each
inside simply does try {} catch (){} where the inside of the try loop does
the
original work, and in catch() I recast the exception into SOMEOtherException.
is this possible with AspectJ ?
I guess not??? since it changes the signature..... |
|
|
c*****a 发帖数: 15 | 6 That is the cause I ask this question. :) I am looking at this new framework
and try to figure out if this is a better way to do AOP.
The AspectJ is the most popular impementation. however you have to insert the
aspect declaration (which is a totally new language independent of Java) into
your java source file, and use their special compiler to compile.
It is quite powerful to do some helping tasks with AspectJ such as logging
etc, I only wonder if it is worthwhile to do that in such a extreme w |
|
c*****a 发帖数: 15 | 7 I don't think AOP should hide from "normal" programmers, it gives you some
powerful features which I think will be added into Java language itself in the
future.
The extreme way is not necessarily the powerful way. IMHO, the AspectJ team
has a Academic background and they chose to have a cool new language. It has a
good academic reason, however, produces headaches for programmers who do the
really work. And they are limited to their pure language experience, the
AspectJ is good when you just pla |
|
r*****s 发帖数: 985 | 8 我觉得Spring的问题就是选择太多,
你看看搞个AOP你可以用@AspectJ or Schema定义,
可以用applicationContext or programatically,
然后applicationContext还可以这样或者那样,
又想兼容aspectJ又要自己搞一套
我看迟早大家又会说:这玩意儿太复杂,我们换个简单的。 |
|
|
z****e 发帖数: 54598 | 10 spring aop侵入少一点
aspectj要用它们自己的编译器
而且aspectj有自定义的语法
所以spring的aop更常用 |
|
y*d 发帖数: 2226 | 11 parc是cs行业的圣殿
除了贝尔实验室,就是parc最牛了
没有smalltalk就没有现在的IT行业
最后一次看到parc的paper是10年前AspectJ的
后来就不再能听说parc了
Mountain View的Computer History Museum设计得很有意思
在一个台子上放了PC和Apple II,台子后面是介绍PC和Apple的展板
当你瞻仰了这两个著名产品,转到那个展板背后的时候
发现展板背面是一张parc的大幅照片
这个设计颇有深意,估计99%的visitor都没看出来 |
|
z****e 发帖数: 54598 | 12 Google了一下
貌似在java上额外的包来实现
AspectJ
认真研究了一下,感觉跟oo的理念相左
要转换思路才行 |
|
z****e 发帖数: 54598 | 13 你上次问我的aop的问题
也没什么很fancy的部分
无非用spring aop或者aspectj做几个拦截器
然后生成log,扔在nosql里面
然后查找起来方便,这样可以分离log代码和主代码
这也是aop的本意,然后查找时候可以用hadoop或者scala
这样就不需要用蛋疼的grep了 |
|
d****i 发帖数: 4809 | 14 不错,恭喜,是准备全职还是兼职做?名字有点让我想起aspectj,哈哈。 |
|
w*******g 发帖数: 9932 | 15 use aspectJ to weave in debugging code. |
|
c*****a 发帖数: 15 | 16 AOP: Aspect-Oriented Programming?
What do you think about it?
Have you used it in your project?
What is your experience in using a AOP implementation such as AspectJ?
What are the reasons behind your conclusion? |
|
e***g 发帖数: 158 | 17 i'm a little worried that java language is becoming too complicated.
it's very hard to know what is essential, sun is reluctant to add new things.
generic java had existed for many years, it only goes to standard language
because of microsoft's theat. aspectJ is unlikely to have that chance.
by architects I refer to those senior developers in a project team who does
more infrastructure works than normal chors. |
|
t****r 发帖数: 25 | 18 experienced using it with testNG and AspectJ. so far so good as long as no
abusing. hehe. |
|
c*****t 发帖数: 1879 | 19 I actually needed this trick for the following task:
User define and compile a class T (along with nested classes). Then
my code scans T's nested classes (or trying to do so). Then replace
the nested classes with additional functionalities.
Sort of like AspectJ. Doing post-compile modification, except I am
generating Java code rather than binary class directly.
the |
|
s******e 发帖数: 493 | 20 that is kind of abusing exception handling block.
but if you have to do it. as suggested by redbull, aop is yur best shot.
if runtime performance is your concern, trying aspectj.
if you are in spring env, using spring native aop, but it will weave the
aspects on runtime.
if you are in jboss env, it also has its own aop, in which aspects will be
woven at classloading time. |
|
g*****g 发帖数: 34805 | 21 It seems self-invocation is the problem for AOP, I have to find a way to
refactor the code and basically make this function in another bean so it's
called on a proxy, or I have to use aspectJ, ft. |
|
s******e 发帖数: 493 | 22 As magicfat said, it is spring's limitation.
to understand this, I just want to add my two cents.
Basically, there are three types of AOP
1. like aspectj, the aspect will be woven during compilation time
2. like jboss, the aspect will be woven during class loading time.
3. like spring, the aspect will be woven during run time. And remember that
everything(almost true) in spring is singleton.
Put this together, you can see that there is no easy way for spring to solve
this limitation. |
|
s***e 发帖数: 122 | 23 spring (with aspectj) also have loading time weaving with its spring-agent.jar.
but for lz's specific problem, i think refactoring to avoid self-invocation
is the best way.
that
solve |
|
g*****g 发帖数: 34805 | 24 How you want to coin the names is not that important. The OP wants
to call some function by parsing a string from DB. And Spring IoC
is a perfect example for that. If you want to add new variable/function,
look at AspectJ.
are |
|
s******e 发帖数: 493 | 25 Even many terms are vague in cs.
But these two are not vague at all when we talk about language. actually
they are one of the criteria to distinguish a type strong langauge and a
dynamic language.
aspectj by nature is just another layer of compilation. actually no aop has
ever brought dynamic variable and dynamic functions to the table.
dynamic variable and fuctions are very useful when you do not know what and
how many things you want your object to carry at compilation time. |
|
c*****t 发帖数: 1879 | 26 Basically, I wanted to do the following, right after
out.setActivity (state.getActivity ());
I wanted to add another piece of code
out.setCount (state.getCount ());
How to write the aspect code? I tried the following and didn't work.
Any suggestions?
aspect X
{
after (Out out, State state):
(cflowbelow (call (int State.getActivityType ()) && target (state)))
&&
(call (void Out.setActivityType (int)) && target (out))
{
out.setCount (state.getCount ());
... 阅读全帖 |
|
c******n 发帖数: 4965 | 27 if I have method1 method2() method3() ...
and I create a pointcut so that I log the func call in each of them
is there a way to obtain the method name inside my advice ?
for example
pointcut blah() : execution ( * * () );
before(): blah() {
System.out.println( "running " + $_SOME_SPECIAL_VAR_FOR_FUNC_NAME );
} |
|
g*****g 发帖数: 34805 | 28 There may be a cleaner way, but use around advice will get
the job done easily. |
|
c******n 发帖数: 4965 | 29 sweet!
(your answer seems towards my other question , but that's a more important
one
)
thanks a lot |
|
c******n 发帖数: 4965 | 30 found it, in examples/ dir
present |
|
r*****s 发帖数: 985 | 31 关键是personally i don't like too much config.
not tracable and hard to debug
配上bad document (通常programmer写的都是),
一件简单的事情都不知道怎么办了。
你看for mixing aspect types chapter 7.5
用@AspectJ + ,
就没个像样的例子,
config就像在搞permutation,
选择又太多,
而且还要等到server起来了才能检验work不work。
当然,
我检讨,
我今天有点心浮气躁。 |
|
x*******i 发帖数: 777 | 32 1.你需要精通面向对象分析与设计(OOA/OOD)、涉及模式(GOF,J2EEDP)以及综合模式。你
应该十分了解UML,尤其是class,object,interaction以及statediagrams。
2.你需要学习JAVA语言的基础知识以及它的核心类库 (collections,
serialization
,streams,networking, multithreading,reflection,event,handling,
NIO,
localization,以及其他)。
3.你应该了解JVM,classloaders,classreflect,以及垃圾回收的基本工作机制
等。
你应该有能力反编译一个类文件并且明白一些基本的汇编指令。
4.如果你将要写客户端程序,你需要学习WEB的小应用程序(applet),必需掌握GUI设
计的思想和方法,以及桌面程序的 SWING,AWT, SWT。你还应该对UI部件的
JAVABEAN组
件模式有所了解。JAVABEANS也被应用在JSP中以把业务逻辑从表现层中分离出来。
5.你需要学习j... 阅读全帖 |
|
x*******i 发帖数: 777 | 33 1.你需要精通面向对象分析与设计(OOA/OOD)、涉及模式(GOF,J2EEDP)以及综合模式。你
应该十分了解UML,尤其是class,object,interaction以及statediagrams。
2.你需要学习JAVA语言的基础知识以及它的核心类库 (collections,
serialization
,streams,networking, multithreading,reflection,event,handling,
NIO,
localization,以及其他)。
3.你应该了解JVM,classloaders,classreflect,以及垃圾回收的基本工作机制
等。
你应该有能力反编译一个类文件并且明白一些基本的汇编指令。
4.如果你将要写客户端程序,你需要学习WEB的小应用程序(applet),必需掌握GUI设
计的思想和方法,以及桌面程序的 SWING,AWT, SWT。你还应该对UI部件的
JAVABEAN组
件模式有所了解。JAVABEANS也被应用在JSP中以把业务逻辑从表现层中分离出来。
5.你需要学习j... 阅读全帖 |
|
r*****l 发帖数: 2859 | 34 Use AOP.
If Spring, use one of the ProxyCreators. Otherwise, you can use AspectJ, or
write your own using Java instrument and/or Dynamic Proxy. |
|
c******n 发帖数: 4965 | 35 I hate this stupid idiom of
if (log.isDebugEnabled()) {
log.debug()
}
just wrap all log.debug() with AspectJ and the code will be automatically re
-written |
|
c******n 发帖数: 4965 | 36 I have a jar that contains a Blah class
and in Blah() ctor it somehow calls System.gc()
now let's say I use the jar that contains Blah(), and call new Blah().
I would get the gc(), so I am trying to detect this call ----- I'm not sure
where it called the "new Blah()" and System.gc() . I'm trying to do
through aspectj, by doing a pointcut on System.gc
but the problem is, now if I include the Blah() implementation in my code,
it's able to detect it, but if I just include the Blah() jar, it can'... 阅读全帖 |
|
c******n 发帖数: 4965 | 37 I want to catch all calls to HibernateTemplate.save(Obj)
so I want to use Aspects to define pointcuts around them
but the problem is
Spring AOP only catches calls on beans, if the object is not a bean, but
created instead through a new() , then it won't catch these calls.
in our existing project, the HibernateTemplate instances could be a bean
handed in or it could be created through new() somewhere.
so I have to use aspectj compiler directly now, right? |
|
g*****g 发帖数: 34805 | 38 Check if you can refactor a little bit. Spring AOP is much
simpler than AspectJ. |
|
n*********n 发帖数: 580 | 39 You will need to declare the AspectJ aspect as a spring bean with the
factory-method="aspectOf", so that its properties can be injected by spring. |
|
|
|
r*****l 发帖数: 2859 | 42 Can also try AspectJ.
reference
the byte code and substitue it. |
|
g*****g 发帖数: 34805 | 43 Although spring is proprietary, it's also open source with apache
license, so discontinued support is not really a concern. Someone
will just fork it.
Spring+Hibernate is more flexible and more powerful, with finer
control and a bigger set of API (e.g. Advanced AOP through aspectJ).
On the other hand, ejb3.1 is definitely more consise, has a lot of
convention over configuration learned from RoR.
I think ejb3.x is mature enough for most projects, so you can't go
wrong with either one. Personally... 阅读全帖 |
|
g*****g 发帖数: 34805 | 44 Although spring is proprietary, it's also open source with apache
license, so discontinued support is not really a concern. Someone
will just fork it.
Spring+Hibernate is more flexible and more powerful, with finer
control and a bigger set of API (e.g. Advanced AOP through aspectJ).
On the other hand, ejb3.1 is definitely more consise, has a lot of
convention over configuration learned from RoR.
I think ejb3.x is mature enough for most projects, so you can't go
wrong with either one. Personally... 阅读全帖 |
|
z*******3 发帖数: 13709 | 45 举个例子
比如oo,oo讲究你要把现实中的所有的实体全部包装成对象
这个是没错
但是j2ee并不是完全的oo
或者这么说,它的oo,是建立在某些并不是你想的那种情况基础之上的
比如你这么理解oo,现实中的每一个人
你要写程序建立一个object去映射它
然后这个人应该要有自己的思想吧?
要有行为吧?这没错
那既然如此,那这个对象的行为是不是它的方法啊?
对啊,是啊
但是你这么做j2ee你就等死吧
没有人这么做
因为当你把对象行为封装到对象本身中去的时候
你就在创造一个controller
而controller是要集中管理的
如果打散到各个实体中去的话
是错误的
所以要想理解j2ee,要先理解mvc
j2ee三个层面分别代表着mvc的三个部分
web就是viewer
db就是model
中间就是controller
但是mvc也有自己的问题
最典型的就是当你要建立ai的时候
理论上应该是单独跑一个线程吧?
比如游戏中一个角色,你要封装它,那应该至少单独给它跑一个ai的thread吧?
然后这个thread跟其他的m也就是游戏的model做通信
对吧?
但是这个是错误的,错误的主要原因是... 阅读全帖 |
|
t*******e 发帖数: 684 | 46 Spring自带的是proxy based AOP,比较弱,self-invocation skips the proxy class
。Aspectj支持compile time weaving CTW, post compile time weaving, load time
weaving LTW,就没有这个局限,不过用起来要多几个步骤。CTW用ANT,Maven,plugin不
同。LTW加java agent. |
|
t*******e 发帖数: 684 | 47 Spring的核心概念是要promote POJO style programming。DI和AOP都是为了达到POJO
的目的。没有DI可以用JNDI lookup, 没有AOP可以用UserTransaction.begin(),
Logger.log(),AspectJ API。EJB1和2就是这么样的。结果就是API intrusive code。
提出POJO style programming是Spring最大的贡献。 |
|
z****e 发帖数: 54598 | 48 你居然不知道
去看aspectj或者spring aop随便研究一个example就懂了 |
|
x****d 发帖数: 1766 | 49 aop is not only from spring. spring aop is not better than aspectj. |
|
z*******3 发帖数: 13709 | 50 修改得不多
比如增减fields就不能实现
增减方法也不行,唯一能动态增加方法的是用aop来实现
用spring或者aspectj
可以改变private/public这些modifier |
|