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.

Persistability.java 1019B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import org.aspectj.lang.annotation.Aspect;
  2. import org.aspectj.lang.annotation.Before;
  3. import org.aspectj.lang.annotation.DeclareParents;
  4. import org.aspectj.lang.annotation.Pointcut;
  5. @Aspect
  6. public class Persistability {
  7. static class Persistable implements IPersistable {
  8. private static final long serialVersionUID = 7120491865883787353L;
  9. private int id;
  10. public Persistable() {
  11. super();
  12. }
  13. public int getId() {
  14. return id;
  15. }
  16. public void setId(int id) {
  17. this.id = id;
  18. }
  19. }
  20. @DeclareParents(value = "PersistabilityTest", defaultImpl = Persistable.class)
  21. private IPersistable observable;
  22. @Pointcut("initialization(IPersistable.new(..)) && this(bean) && !this(Persistable)")
  23. void init(IPersistable bean) {
  24. }
  25. @Before("init(bean)")
  26. public void beforeInit(IPersistable bean) {
  27. bean.setId(System.identityHashCode(bean));
  28. }
  29. }