[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| [aspectj-users] Quick Question | 
How would I fashion a point cut that matched a method invocation only  
if it had not already been applied to an overridden form of that  
method in a superclass?  For instance in one project I have:
public class SimpleQuery{
	public void appendConstraints(){
		..add default constraints..
	}
}
public interface SuppressableQuery{
	...some stuff relevant to suppression...
}
public aspect SuppressableQueryAspect{
	void around(SuppressableQuery query) : execution(protected void  
SimpleQuery.appendConstraints()) && this(query) {
		/* Not really important what this does, just when it is applied */
		if(query.getSuppressed() != null){
			query.addClause(
					(query.getSuppressed() ? "" : "NOT ") + "EXISTS (SELECT  
suppression.partitionId " +
					"FROM " + query.getSuppressionType().getName() +
					" suppression WHERE suppression.partitionId IN  
(:suppressionOrder) " +
					"AND suppression.entity = " + query.getSuppressedEntityField() +  
")");
			query.addParameter("suppressionOrder", query.getSuppressionOrder());
		}
		proceed(query);
	}
}
Then in another project with a jar containing the jar from the first  
project on the aspect path:
public class ProfileQuery extends SimpleQuery<Profile> implements
        PartitionedQuery<Profile>, SuppressableQuery<Profile> {
	@Override
	protected void appendConstraints() {
		super.appendConstraints();
		if(onetOccupationStub != null){
			addClause(alias("delegate") + " = :onetOccupationStub");
			addParameter("onetOccupationStub", onetOccupationStub);
		}
	}
}
What I'm seeing is that  the clause is added to the query twice, when  
I only want it to match one invocation of appendConstraints, in this  
case the one in ProfileQuery.  Can that be done?