Newbie question about configuration of a ProxyFactoryBean
I want to know how to get access to methods in an implementation class via her interface with the utilisation of a ProxyFactoryBean.
I have an interface - BusinessDelegate - an her implementation class - BusinessdelegateImpl -. An Action class - BaseAction - from the web layer (using Struts) want to have access to a specific method from the interface - BusinessDelegate.
/*BusinessDelegate*/
public interface BusinessDelegate
{
public void test();
}
/*BusinessDelegate Implementation*/
public class BusinessDelegateImpl implements BusinessDelegate
{
public void test()
{
logger.debug("test");
}
}
/*The action class*/
public abstract class BaseAction extends Action
{
private BusinessDelegate businessDelegate;
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicati onContext(servletContext);
this.businessDelegate = (BusinessDelegate) wac.getBean("businessBean");
this.businessDelegate.test();
}
public BusinessDelegate getBusinessDelegate() {
return businessDelegate;
}
}
and finally the applicationContext.xml
<bean id="businessBean" class="org.springframework.aop.framework.ProxyFact oryBean">
<property name="proxyInterfaces">
<value>com.didbre.website.domain.logic.BusinessDel egate</value>
</property>
<property name="target">
<ref local="beanTarget"/>
</property>
</bean>
<bean id="beanTarget" class="com.didbre.website.domain.logic.BusinessDel egateImpl"/>
**********************
When I reach the "this.businessDelegate.test();" in the BaseAction class, I received well kind message that said:
AOP configuration seems to be invalid: tried calling public abstract void com.didbre.website.domain.logic.BusinessDelegate.t est() on [com.didbre.website.domain.logic.BusinessDelegateIm pl@d6ecc2]: java.lang.IllegalArgumentException: object is not an instance of declaring class
org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:68 )
org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:138)
$Proxy0.test(Unknown Source)
com.didbre.website.web.action.BaseAction.setServle t(BaseAction.java:23)
org.apache.struts.action.RequestProcessor.processA ctionCreate(RequestProcessor.java:341)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:268)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet .java:763)
javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
******************
What's the problem and how can have access to my business method test ?
I'm using :
Tomcat 5.0.19
Spring 1.0.2
Struts 1.1
Thanks.