1 16 17 package org.springframework.aop.target; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 22 import org.springframework.aop.TargetSource; 23 24 42 public abstract class AbstractLazyCreationTargetSource implements TargetSource { 43 44 45 protected final Log logger = LogFactory.getLog(getClass()); 46 47 48 private Object lazyTarget; 49 50 51 55 public synchronized boolean isInitialized() { 56 return (this.lazyTarget != null); 57 } 58 59 67 public synchronized Class getTargetClass() { 68 return (this.lazyTarget != null ? this.lazyTarget.getClass() : null); 69 } 70 71 public boolean isStatic() { 72 return false; 73 } 74 75 80 public synchronized Object getTarget() throws Exception { 81 if (this.lazyTarget == null) { 82 logger.debug("Initializing lazy target object"); 83 this.lazyTarget = createObject(); 84 } 85 return this.lazyTarget; 86 } 87 88 public void releaseTarget(Object target) throws Exception { 89 } 91 92 93 99 protected abstract Object createObject() throws Exception ; 100 101 } 102 | Popular Tags |