How use AspectJ in Eclipse plugins
As mentioned in a previous qu开发者_运维技巧estion I am trying to check that all my ResultSet are closed. For that I want to use AspcetJ but after 1 day of hard fight I am not able to use aspects in a plugin context.
What I want is to have an aspect project defining several aspects to check resultset and then launch a new eclipse debug configuration with my custom plugins and have my aspects applied on these plugins.
How achieve that ?
Thanks in advance, Manu
Since you are running in an OSGi environment, you need to use a specific style of load-time weaving, one that is OSGi aware. Standard compile-time weaving or LTW will not work. This is because OSGi uses a different classloader for each plugin and the set of plugins used by Eclipse is not known before startup.
Have a look at Equinox Aspects (aka equinox weaving):
http://www.eclipse.org/equinox/incubator/aspects/equinox-aspects-quick-start.php
Essentially, you need to make some changes to your aspect plugin's manifest file, add an aop.xml file, and ensure that your aspect plugin is set to autostarted=true.
[edit] As of eclipse Juno the steps are changed see : http://wiki.eclipse.org/Equinox_Weaving_QuickStart
精彩评论