Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Super calls to inter-type methods

I dont think there is a syntax that you can access the injected "public void SelectAction<T>.select(T selection)" method inside StringSelectAction.

The interface method implementation injection just provide a default implementation of that method. What ajc do is actually injecting the select(T selection) method with the default implementation to all classes which are implementors of interface SelectAction.

You can have a clear understanding if you try the following:

a. public class StringSelectAction implements SelectAction<T> { }
b. then compile it with ajc
c. javap StringSelectAction
   javap SelectAction

So, if you really wanna do this, you can 
public interface SelectAction<T>{

	public void select(T selection);

}

public aspect SelectAspect{

	private T SelectAction<T>.selection;

	public void SelectAction<T>.defaultSelect(T selection){ //here
		this.selection = selection;
	}

}

then,

public class StringSelectAction implements SelectAction<T>{
public void select(String selection){
	checkPermissions(selection);
	defaultSelect(selection); //here
}
}

--
Dehua Zhang
Sable Research Group, McGill University
Montréal, Québec, Canada
http://www.cs.mcgill.ca/~dzhang25





-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Dave Whittaker
Sent: Wed 3/12/2008 12:23
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Super calls to inter-type methods
 
Hi there.  I'm having trouble figuring out the best method to do  
something and I was hoping someone out there with more AspectJ  
experience might be able to help.

I am trying to use inter-type declarations on interfaces to simulate  
multiple inheritance.  The trouble comes in when I want to override  
the inherited method from an interface.  For instance if I have:

public interface SelectAction<T>{

	public void select(T selection);

}

public aspect SelectAspect{

	private T SelectAction<T>.selection;

	public void SelectAction<T>.select(T selection){
		this.selection = selection;
	}

}

then:

public class StringSelectAction implements SelectAction<T>{...}

Causes StringSelectAction to inherit the select method correctly, but  
what if I wanted to override the inherited method and say check  
permissions before selecting an object?  I can't have:

public void select(String selection){
	checkPermissions(selection);
	super.select(selection);
}

because the select method is not a member of the super class.  Is  
there a syntax in AspectJ to indicate I want to call the inherited  
method?  If not, what is the best practice for this type of thing?


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



Back to the top