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.

AroundClosure.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * Alex Vasseur wired up for @AJ proceeding
  13. * Andy Clement 23-06-06 added extras for @AJ
  14. * ******************************************************************/
  15. package org.aspectj.runtime.internal;
  16. import org.aspectj.lang.ProceedingJoinPoint;
  17. public abstract class AroundClosure {
  18. protected Object[] state;
  19. // Records with the related joinpoint has a this or a target and whether
  20. // either of them are bound in the pointcut. Set in the 'link' call made
  21. // at each matching join point... (see pr126167)
  22. // bit6 being 1 means the flags haven't been initialized
  23. protected int bitflags = 0x100000;
  24. protected Object[] preInitializationState;
  25. public AroundClosure() {
  26. }
  27. public AroundClosure(Object[] state) {
  28. this.state = state;
  29. }
  30. public int getFlags() {return bitflags;}
  31. public Object[] getState() {
  32. return state;
  33. }
  34. public Object[] getPreInitializationState() {
  35. return preInitializationState;
  36. }
  37. /**
  38. * This takes in the same arguments as are passed to the proceed
  39. * call in the around advice (with primitives coerced to Object types)
  40. */
  41. public abstract Object run(Object[] args) throws Throwable;
  42. /**
  43. * This method is called to implicitly associate the closure with the joinpoint
  44. * as required for @AJ aspect proceed()
  45. */
  46. public ProceedingJoinPoint linkClosureAndJoinPoint() {
  47. //TODO is this cast safe ?
  48. ProceedingJoinPoint jp = (ProceedingJoinPoint)state[state.length-1];
  49. jp.set$AroundClosure(this);
  50. return jp;
  51. }
  52. /**
  53. * This method is called to implicitly associate the closure with the joinpoint
  54. * as required for @AJ aspect proceed()
  55. */
  56. public ProceedingJoinPoint linkClosureAndJoinPoint(int flags) {
  57. //TODO is this cast safe ?
  58. ProceedingJoinPoint jp = (ProceedingJoinPoint)state[state.length-1];
  59. jp.set$AroundClosure(this);
  60. this.bitflags = flags;
  61. return jp;
  62. }
  63. }