Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] advice on methods inherited from Eclipse

Hi Daniel,

You could use declare parents to interpose a superclass for all of your
subclasses of ItemProviderAdapter:

public class MyItemProviderAdapter extends ItemProviderAdapter {
	protected Object createWrapper(EObject object, EStructuralFeature
feature, Object value, int index) {
		return super.createWrapper(object, feature, value, index);
	}
}

aspect ExtendItemProvider {
    declare parents: (ItemProviderAdapter+ && !ItemProviderAdapter &&
!MyItemProviderAdapter) extends MyItemProviderAdapter;
}

This would give you a hook method for any of your implementations without
having to scatter the overrides.

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Daniel Mahler
Sent: Sunday, July 23, 2006 10:30 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] advice on methods inherited from Eclipse

I now know that one cannot apply aspects within Eclipse code
without using something like AJEER (or AOSGI when it becomes available).
However, I wonder if the above tools are really necessary in my case:

I want to put around() advice on MyItemProvider.createWrapper (either
call() or execution() would be adequate).

Eclipse provides the method
org.eclipse.emf.edit.provider.ItemProviderAdapter.createWrapper(EObject,EStr
ucturalFeature,Object,int)
and all EMF.Edit generated item provider classes extend
org.eclipse.emf.edit.provider.ItemProviderAdapter
I would have thought that

pointcut provider() :
  execution(Object ItemProviderAdapter+.createWrapper(EObject,
EStructuralFeature, Object, int) ) ;

would still get applied to MyItemProvider and so it would not matter
that ItemProviderAdapter is
not available for weaving, but the advice does not get applied.

Adding the trivial override

	protected Object createWrapper(EObject object, EStructuralFeature
feature, Object value, int index) {
		return super.createWrapper(object, feature, value, index);
	}

to MyItemProvider does trigger the advice.
The problem with that solution is that my model is generated from
a large XML schema, and I have many generated item provider classes.
Also the schema is evolving, forcing me to recheck
that all generated classes have the override each time the schema changes.
Unfortunatenately, ItemProviderAdapter, is the only common ancestor
the generated
classes have, so there is seems no simple way to factor out any
customizations
to ItemProviderAdapter.createWrapper, which is why I am trying apply
aspects to it in the first place.

So is there a way to define the aspect, or configure the build.
that does not force me to manually modify all my generated item providers?
I have tried using AJEER to get my aspect to work,
but at the moment I am not having any luck with that either.

I have could use dynamic templates, this was actually my first
approach to EMF customization.
That would cut out the repetition, but it entails forking the
Eclipse's own templates,
which is why I switched to AspectJ, which has worked well for upto this
point.

thanks
Daniel
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top