How about this; change you pointcut to match calls to execute, then you can add the cachemanager as an argument to the pointcut and the advice. Something like
pointcut callExecuteThatCallsGetServiceUtil(Map cacheManager): call (public void MyCommand.execute(Map)) && args(cacheManager);
before (Map cacheManager): callExecuteThatCallsGetServiceUtil(cacheManager) { Class Command = thisJoinPoint.getSourceLocation ().getWithinType(); IPreProcessor preprocessor = (IPreProcessor)PrePostProcessorResolver.getPreProcessor(Command); preprocessor.preprocess( cachmanager); }
dean
On May 31, 2007, at 3:56 AM, Ingudam Manoranjan wrote: I have the following scenario:
public class MyCommand { public void execute(Map cachmanager) { System.out.println("I am in MyCommand: Before Service Call"); ServiceUtil.getService ("MyService"); System.out.println("I am in MyCommand: After Service Call"); }
public class ServiceUtil { public static String getService(String serviceName){ String serviceObject = "Static Service"; System.out.println("Service invoked is : "+ serviceName); return serviceObject; } }
I want to add Preprocessing beforethe Service Call.
public aspect ServiceUtilAspect { pointcut callServiceUtil(): call (public static String ServiceUtil.getService(String));
before() :callServiceUtil() { Class Command = thisJoinPoint.getSourceLocation ().getWithinType(); IPreProcessor preprocessor = (IPreProcessor)PrePostProcessorResolver.getPreProcessor(Command); //Map cachmanager = new HashMap(); preprocessor.preprocess( cachmanager);
} }
I want to be get the cachmanager from the Command. Is it possible using Aspectj? Can anyone help?
_______________________________________________ aspectj-dev mailing list Dean Wampler, Ph.D. dean at objectmentor.com
I want my tombstone to say: Unknown Application Error in Dean Wampler.exe. Application Terminated. [Okay] [Cancel]
|