You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import org.aspectj.lang.JoinPoint;
  2. import org.aspectj.lang.Signature;
  3. @Clientside
  4. public aspect ServiceCall
  5. {
  6. public pointcut ServicePoint()
  7. : call( * (@BussFacade *).*(..) )
  8. && !@within(Clientside)
  9. && !@annotation(Clientside)
  10. && ( !@within(ServiceImplementation)
  11. || @withincode(Clientside)
  12. )
  13. ;
  14. declare @type
  15. : hasmethod(* (@BussFacade *).*(..)) : @ServiceImplementation
  16. ;
  17. public @interface ServiceImplementation { }
  18. private pointcut call_Service(Object businessFacade)
  19. : ServicePoint()
  20. && target(businessFacade);
  21. protected Object findImpl(Object bussFacade, JoinPoint.StaticPart location)
  22. {
  23. Class dienstID;
  24. if ( null!=bussFacade )
  25. dienstID = bussFacade.getClass();
  26. else {
  27. Signature sig = location.getSignature();
  28. dienstID = sig.getDeclaringType();
  29. }
  30. Object impl = new MyServiceImpl(); // call ServiceLocator here
  31. return impl;
  32. }
  33. Object around(Object bussFacade)
  34. : call_Service(bussFacade)
  35. {
  36. try {
  37. Object umgelenkt = findImpl(bussFacade, thisJoinPointStaticPart);
  38. Object res = proceed(umgelenkt);
  39. return res;
  40. }
  41. catch(Throwable T) {
  42. System.out.println("oh my");
  43. throw new RuntimeException(T);
  44. }
  45. }
  46. }