1 16 17 package org.springframework.aop.aspectj.annotation; 18 19 import org.springframework.core.Ordered; 20 import org.springframework.util.Assert; 21 22 29 public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwareAspectInstanceFactory { 30 31 private final MetadataAwareAspectInstanceFactory maaif; 32 33 private Object materialized; 34 35 36 40 public LazySingletonAspectInstanceFactoryDecorator(MetadataAwareAspectInstanceFactory maaif) { 41 Assert.notNull(maaif, "AspectInstanceFactory must not be null"); 42 this.maaif = maaif; 43 } 44 45 public synchronized Object getAspectInstance() { 46 if (this.materialized == null) { 47 this.materialized = this.maaif.getAspectInstance(); 48 } 49 return this.materialized; 50 } 51 52 public boolean isMaterialized() { 53 return (this.materialized != null); 54 } 55 56 public AspectMetadata getAspectMetadata() { 57 return this.maaif.getAspectMetadata(); 58 } 59 60 public int getOrder() { 61 if (this.maaif instanceof Ordered) { 62 return ((Ordered) this.maaif).getOrder(); 63 } 64 return Ordered.LOWEST_PRECEDENCE; 65 } 66 67 68 @Override 69 public String toString() { 70 return "LazySingletonAspectInstanceFactoryDecorator: decorating " + this.maaif; 71 } 72 73 } 74 | Popular Tags |