/*
 * Created on 27-Feb-2006
 */
package uk.org.ponder.rsac;

import org.springframework.aop.TargetSource;


/** An "AOP Alliance" proxy that allows request-scope dependencies to
 * be injected into application scope.
 * @author Antranig Basman (antranig@caret.cam.ac.uk)
 *
 */

public class RSACBridgeProxy implements TargetSource {
  
  private RSACBeanLocator rsacbl;
  private String targetbean;

  public void setRSACBeanLocator(RSACBeanLocator rsacbl) {
    this.rsacbl = rsacbl;
  }
  
  public void setTargetBeanName(String targetbean) {
    this.targetbean = targetbean;
  }
  
  public Class getTargetClass() {
    return rsacbl.getBeanClass(targetbean);
  }

  public boolean isStatic() {
    return false;
  }

  public Object getTarget() throws Exception {
    return rsacbl.getBeanLocator().locateBean(targetbean);
  }

  public void releaseTarget(Object target) throws Exception {
    // apparently no action required here.
  }

}

@@ -106,16 +106,245 @@
 ource;%0D%0A
+import org.springframework.aop.framework.ProxyFactoryBean;%0D%0Aimport org.springframework.beans.factory.BeanFactory;%0D%0Aimport org.springframework.beans.factory.FactoryBean;%0D%0A%0D%0Aimport uk.org.ponder.springutil.BeanLocatorBeanFactory;%0D%0A
 %0D%0A%0D%0A/** 
@@ -568,16 +568,29 @@
 etSource
+, FactoryBean
  %7B%0D%0A  %0D%0A
@@ -1168,24 +1168,24 @@
 xception %7B%0D%0A
-
     // appar
@@ -1223,11 +1223,706 @@
 %0A  %7D%0D%0A%0D%0A
+  Object proxy = null;%0D%0A  %0D%0A  private void createProxy() %7B%0D%0A    ProxyFactoryBean pfb = new ProxyFactoryBean();%0D%0A    Class beanclass = getTargetClass();%0D%0A    if (beanclass.isInterface()) %7B%0D%0A      pfb.setInterfaces(new Class%5B%5D %7Bbeanclass%7D);%0D%0A    %7D%0D%0A    pfb.setTargetSource(this);%0D%0A    BeanFactory blfactory = new BeanLocatorBeanFactory(rsacbl.getBeanLocator());%0D%0A    pfb.setBeanFactory(blfactory);%0D%0A    proxy = pfb.getObject();%0D%0A  %7D%0D%0A  %0D%0A  public Object getObject() throws Exception %7B%0D%0A    if (proxy == null) %7B%0D%0A      createProxy();%0D%0A    %7D%0D%0A    return proxy;%0D%0A  %7D%0D%0A%0D%0A  public Class getObjectType() %7B%0D%0A    return getTargetClass();%0D%0A  %7D%0D%0A%0D%0A  public boolean isSingleton() %7B%0D%0A    return true;%0D%0A  %7D%0D%0A%0D%0A
 %7D%0D%0A

Fix to RSACBridgeProxy