1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import org.aspectj.lang.JoinPoint;
- import org.aspectj.lang.Signature;
-
-
- @Clientside
- public aspect ServiceCall
- {
-
- public pointcut ServicePoint()
- : call( * (@BussFacade *).*(..) )
- && !@within(Clientside)
- && !@annotation(Clientside)
- && ( !@within(ServiceImplementation)
- || @withincode(Clientside)
- )
- ;
-
- declare @type
- : hasmethod(* (@BussFacade *).*(..)) : @ServiceImplementation
- ;
-
- public @interface ServiceImplementation { }
-
-
- private pointcut call_Service(Object businessFacade)
- : ServicePoint()
- && target(businessFacade);
-
-
- protected Object findImpl(Object bussFacade, JoinPoint.StaticPart location)
- {
- Class dienstID;
- if ( null!=bussFacade )
- dienstID = bussFacade.getClass();
- else {
- Signature sig = location.getSignature();
- dienstID = sig.getDeclaringType();
- }
- Object impl = new MyServiceImpl(); // call ServiceLocator here
- return impl;
- }
-
-
-
- Object around(Object bussFacade)
- : call_Service(bussFacade)
- {
- try {
- Object umgelenkt = findImpl(bussFacade, thisJoinPointStaticPart);
- Object res = proceed(umgelenkt);
- return res;
- }
- catch(Throwable T) {
- System.out.println("oh my");
- throw new RuntimeException(T);
- }
- }
-
- }
|