Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] problem retreiving from chain


I am trying to solve the following problem with aspectj and have run into a
problem. Any help in fixing this will be highly appreciated.

I have call stack in which one or more objects in the call chain implement
an interface called IEnhancer

public interface IEnhancer
{
	public Context getFromCallStack();
	public Context getContext();
}

I need advice(s) to overwrite the getFromCallStack to fetch the context from
the previous IEnhancer in the call stack.

the getContext method is meant to retreive the Context from getFromCallStack
and enhance it. 

for Example

public Class MyEnhancer implements IEnhancer
{
	public Context getFromCallStack()
	{
		return null;
		//will be overwritten by advice.
	}

	public Context getContext()
	{
		Context context = getFromCallStack();
		context.enhance(value);
	}
}

I want the around advice to retreive context from the previous enhancer and
NOT the same object. 


I have written the following code.

pointcut contextWormHoleEnhancerPointCut(IEnhancer enhancer)
:execution(* IEnhancer+.*(..)) && this(enhancer);

pointcut contextWormHoleEnhancerReadPointCut(IEnhancer enhancer)
:execution(public * IEnhancer +.getFromCallStack(..)) 
	 && this(enhancer);


pointcut ContextEnhancerToEnhancer(IEnhancer interim, IEnhancer reader)
:if(interim != reader)&& cflow(contextWormHoleEnhancerPointCut(interim))&&
contextWormHoleEnhancerReadPointCut(reader);


Context around(IEnhancer interim,IEnhancer reader):IEnhancer(interim,
reader){
		return interim.getContext();
};

with the if pointcut in the ContextEnhancerToEnhancer point the around
advice is not getting kicked in. If i exclude it the getFromCallStack is
being invoked on this and it returns null.


-- 
View this message in context: http://www.nabble.com/problem-retreiving-from-chain-tp23596176p23596176.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top