Intercept class loading [message #55297] |
Tue, 27 December 2005 05:14  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
I have some model beans that have getter/setter. Setter always should
do this steps for simple field assignment setter:
1) remember old value;
2) change field;
3) invoke firePropertyChange with old and new values.
I want remove 1) and 3) from beans and add them in runtime during
class loading. So, I have questions:
1. Is it possible in Eclipse? (I know one not very nice way - Java5 java
agent, but I don't like changing Java launch line).
2. May be there is already some better solution for property change
notifying?
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
|
Re: Intercept class loading [message #55352 is a reply to message #55324] |
Tue, 27 December 2005 06:42   |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
ted stockwell wrote:
>> I have some model beans that have getter/setter. Setter always
>> should do this steps for simple field assignment setter:
>>
>> 1) remember old value;
>> 2) change field;
>> 3) invoke firePropertyChange with old and new values.
>>
>> I want remove 1) and 3) from beans and add them in runtime during
>> class loading. So, I have questions:
>>
>> 1. Is it possible in Eclipse? (I know one not very nice way - Java5
>> java agent, but I don't like changing Java launch line).
>>
>> 2. May be there is already some better solution for property change
>> notifying?
>>
>
> AspectJ is a good way to do this.
> With AspectJ you can develop an 'aspect' that will perform steps 1) and 3).
> AspectJ will then add the aspect to all your beans.
>
> The AspectJ web page, http://eclipse.org/aspectj/, describes the AspectJ
> language.
>
> The AspectJ Development Tools (AJDT) web page,
> http://www.eclipse.org/ajdt/, is an Eclipse plugin that makes it easy to
> use AspectJ in the Eclipse IDE.
Ah, yes. How could I forget about aspects! I know about aspects, but
don't have any experience.
I think that AspectJ can help in 1) and 3), but now I have one dream -
don't have getters/setters at all. :-)
May be you know, is it possible generate new methods using AspectJ? I
see several possible problems:
1. I don't know if I can then use these generated method in my code. Not
using reflection, but just direct calls.
2. I use Hibernate, so would be good if I could still use it. May be add
annotations to fields plus one more annotation that tells AspectJ that I
need getter/setter for these fields.
All this is just dreams, I did not read documentation yet. :-)
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
|
|
|
Re: Intercept class loading [message #55485 is a reply to message #55459] |
Wed, 28 December 2005 05:50  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
Venkataramana M wrote:
> AspectJ weaves aspects at byte-code level. Ofcourse the idea of
> Aspect was to be able to seperate concerns at java code level.
> But it becomes pretty difficult to debug/test
> java-code woven at bytecode level. We have developed a java
Hm... I am not going to debug my setters. :-)
I am absolutely happy with aspects - just one screen of code and I
automatically have property change notifications in all my beans.
> weaving-specification on similar lines of AspectJ but this one
> weaves at javacode level making use of Eclipse's JDT API.
> I think using JDT refactoring API to arrive at
> custom refactoring tools like a weaver is a pretty eask
> task given the fanstastic support from JDT.
I don't want dirty code.
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
Powered by
FUDForum. Page generated in 0.03747 seconds