Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

pr103266.aj 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. abstract aspect WorkerExample {
  2. after() returning (RequestContext newContext) : call(RequestContext+.new(..)) {
  3. System.out.println("constructing "+newContext+" at "+thisJoinPoint.toLongString()+" from "+thisEnclosingJoinPointStaticPart+":");
  4. }
  5. abstract class RequestContext {
  6. public final Object execute() {
  7. return doExecute();
  8. }
  9. /** template method */
  10. public abstract Object doExecute();
  11. }
  12. public static void main(String args[]) {
  13. new Runnable() {
  14. public void run() {}
  15. }.run();
  16. };
  17. }
  18. aspect ConcreteAlpha extends WorkerExample {
  19. Object around(final Object runnable) : execution(void Runnable.run()) && this(runnable) {
  20. System.out.println("monitoring operation: "+runnable+" at "+thisJoinPoint+", for "+thisJoinPoint.getThis());
  21. RequestContext requestContext = new RequestContext() {
  22. public Object doExecute() {
  23. return proceed(runnable);
  24. }
  25. };
  26. return requestContext.execute();
  27. }
  28. }
  29. aspect ConcreteBeta extends WorkerExample {
  30. Object around() : call(void awqeyuwqer()) {
  31. RequestContext requestContext = new ConnectionRequestContext() {
  32. public Object doExecute() {
  33. return proceed();
  34. }
  35. };
  36. return requestContext.execute();
  37. }
  38. }