Hi,

Thank you for your reply! I was not aware that the woven class file will not
be situated in WeavingTarget. So, I first tried the simple solution that you
proposed and found out that it is only working when setting a required
plug-in dependency to WeavingSource in WeavingTarget's manifest file. So, it
is now working but not really what I want to do. Thus, I tried to use
equinox aspects. LTW was what I initially had in mind for my use case but I
thought that compile-time weaving would be easier to realise.

For the equinox aspects example I used the same setup. WeavingTarget is
still the Sample XML Editor plug-in. WeavingSource is still a plug-in that
contains only the mentioned aspect and is an aspectj project. According to
the equinox aspects quick-start guide WeavingSource's manifest file looks
like the following:

     Manifest-Version: 1.0
     Bundle-ManifestVersion: 2
     Bundle-Name: WeavingSource
     Bundle-SymbolicName: WeavingSource
     Bundle-Version: 1.0.0.qualifier
     Require-Bundle: org.aspectj.runtime;visibility:=reexport
     Export-Package: weavingsource
     Bundle-ActivationPolicy: lazy
     Bundle-RequiredExecutionEnvironment: J2SE-1.5
     Import-Package: org.osgi.framework;version="1.5.0"
     Eclipse-SupplementBundle: weavingtarget

The aop.xml file in the manifest folder just contains:

     <?xml version="1.0" encoding="UTF-8"?>
     <aspectj>
         <aspects>
             <aspect name="weavingsource.ActivatorAspect" />
         </aspects>
     </aspectj>

And at last the run-configuration parses, among others, the following
arguments to the VM:

     -Dorg.aspectj.osgi.verbose=true
-Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook


When starting the run-time, the information

     [org.eclipse.equinox.weaving.hook] info adding AspectJ hooks ...

is displayed. But, when opening the Sample XML Editor no aspect message is
displayed. What is the reason for this behavior? Using LTW it cannot be that
the woven class is in the wrong plug-in. Is it that the aspect class file is
not found?

Best,
Holger




> Over the context menu's properties entry I set the Inpath of
> "WeavingSource"
> > to the project "WeavingTarget" and enabled the output of weaving
> information
> > to the problems view.
>
> This configuration means that when building WeavingSource it will
> consume the output class files from WeavingTarget, apply the aspect,
> and then write the woven class files *to the output folder for
> WeavingSource*.  WeavingTarget is completely untouched and the class
> files within it remain unwoven.  This means you will only be executing
> the woven classes if you 'run'/'load' those in the WeavingSource as
> replacements for those in WeavingTarget.
>
> The simplest configuration is Convert WeavingTarget to an AspectJ
> project then put WeavingSource on its aspectpath.  I realise you don't
> want to change WeavingTarget, but this would be the simplest way.  Or
> you could use equinox aspects weaving as you are in a plugin
> environment anyway, that will load time weaving your aspect, but
> weaving is then a loadtime activity rather than a compile time
> activity.
>
> Andy
>
> 2010/1/11 Holger Gulrot <holger.gul...@gmail.com>:
> > Dear all,
> >
> > I am new to this list and new to Aspectj, and I would like to ask my
> first,
> > perhaps a freshman, question.
> >
> > Question:
> > Why is advice of an aspect in one eclipse plug-in not invoked when
> running
> > another eclipse plug-in that contains a class with the corresponding join
> > point despite ajdt telling me that the join point is advised?
> >
> > Explanation:
> > I have two eclipse plug-in projects. As a minimal example, I created a
> > plug-in "WeavingTarget" that contains the "Sample XML Editor" which you
> can
> > choose when creating a new plug-in project. As a second plug-in, named
> > "WeavingSource", I generated an empty plug-in project (without an
> activator)
> > converted it into an Aspectj project (using the context menu entry) and
> > added the following aspect to it:
> >
> >
> >     package weavingsource;
> >
> >     public aspect ActivatorAspect {
> >
> >         pointcut start() : execution(public void *.start(..));
> >
> >         after() : start() {
> >             System.out.println("plugin was started");
> >         }
> >     }
> >
> > Over the context menu's properties entry I set the Inpath of
> "WeavingSource"
> > to the project "WeavingTarget" and enabled the output of weaving
> information
> > to the problems view. Where the folowing information gets displayed:
> >
> >     Join point 'method-execution(void
> > weavingtarget.Activator.start(org.osgi.framework.BundleContext))' in Type
> > 'weavingtarget.Activator' (Activator.java:28)     advised by after advice
> > from 'weavingsource.ActivatorAspect' (ActivatorAspect.aj:7)
> WeavingSource
> >
> > Thus I assume that my advice was correctly applied to the specified join
> > point.
> >
> > After starting eclipse's runtime instance (via run as eclipse
> application)
> > and after opening an xml file with the Sample XML Editor, the Activator's
> > start method was called and the console should display the message
> specified
> > in the aspect's advice.
> > But this does not happen. Why? Do I need to set something else/more then
> the
> > Inpath of "WeavingSource"? Even setting a plug-in dependency in the
> manifest
> > file from "WeavingSource" to "WeavingTarget" does not produce another
> > result...
> > For testing purposes I put the aspect next to the Activator in the
> > "WeavingTarget" plug-in and this results in displaying the aspect's
> advice
> > message when opening the Sample XML Editor. I do not want to make use of
> > this workaround since I want to leave the "WeavingTarget" plug-in
> > unmodified.
> >
> > Setup:
> > I am using eclipse galileo (3.5.1) with ajdt (2.0.1) and aspectj (1.6.6).
> >
> >
> > I would appreciate if you could help me out.
> >
> > Best,
> > Holger
> >
>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to