1 22 package org.jboss.aop.proxy.container; 23 24 import org.jboss.aop.Advisor; 25 import org.jboss.aop.InstanceAdvisor; 26 import org.jboss.aop.metadata.SimpleMetaData; 27 28 32 public class ProxyTemplate implements Delegate, AspectManaged 33 { 34 35 public ProxyTemplate() 36 { 37 } 38 39 private Advisor classAdvisor; 40 private InstanceAdvisor instanceAdvisor; 41 protected volatile Advisor currentAdvisor; 42 43 private Object delegate; 44 private Object [] mixins; private SimpleMetaData metadata; 46 47 48 public Object getDelegate() 49 { 50 return delegate; 51 } 52 53 public void setDelegate(Object delegate) 54 { 55 this.delegate = delegate; 56 } 57 58 public Advisor getAdvisor() 59 { 60 return currentAdvisor; 61 } 62 63 public void setAdvisor(Advisor advisor) 64 { 65 this.classAdvisor = advisor; 66 this.currentAdvisor = classAdvisor; 67 } 68 69 public void setMetadata(SimpleMetaData metadata) 70 { 71 this.metadata = metadata; 72 } 73 74 public void setInstanceAdvisor(InstanceAdvisor ia) 75 { 76 synchronized (this) 77 { 78 if (this.instanceAdvisor != null) 79 { 80 throw new RuntimeException ("InstanceAdvisor already set"); 81 } 82 83 if (!(ia instanceof org.jboss.aop.proxy.container.InstanceProxyContainer)) 84 { 85 throw new RuntimeException ("Wrong type for instance advisor: " + instanceAdvisor); 86 } 87 this.instanceAdvisor = ia; 88 89 currentAdvisor = (org.jboss.aop.proxy.container.InstanceProxyContainer)ia; 90 } 91 } 92 93 public InstanceAdvisor getInstanceAdvisor() 94 { 95 synchronized(this) 96 { 97 if (instanceAdvisor == null) 98 { 99 org.jboss.aop.proxy.container.InstanceProxyContainer ipc = ((org.jboss.aop.proxy.container.ClassProxyContainer)currentAdvisor).createInstanceProxyContainer(); 100 setInstanceAdvisor(ipc); 101 } 102 } 103 return instanceAdvisor; 104 } 105 106 } 107 | Popular Tags |