Hi springers. I have a problem with the subject.
So, I have a request processor bean:
this class extends the AbstractRequestProcessor class.Code:<bean id="cifRequestProcessor" class="com.express.web.rc.cif.CifRequestProcessor" scope="prototype"/>
Then I have pooled that bean as follow:
Then, we have a class ServiceProcessorFactory which contains Map with the different request processors, and this map is populated in the Spring context file:Code:<bean id="cifProcessorCommonPoolProxy" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="targetSource" ref="cifProcessorCommonTargetSource"/> <property name="proxyTargetClass" value="true"/> </bean> <bean id="cifProcessorCommonTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource"> <property name="maxSize" value="10"/> <property name="targetBeanName" value="cifRequestProcessor"/> </bean>
As you can see I populate the map with the PoolProxy (not direct with the processor it self. And it works perfect in the code:Code:<bean id="serviceProcessorFactory" class="com.express.web.rc.util.ServiceProcessorFactory"> <property name="requestProcessors"> <map> <entry key="CIF"> <ref bean="cifProcessorCommonPoolProxy"/> </entry> <!-- Here are other entries for athe processors --> </map> </property> </bean>
where _requestProcessors is the Map.Code:AbstractRequestProcessor processor = (AbstractRequestProcessor) _requestProcessors.get(requestType);
Now, I desided to intercept the processor's processRequest and added the vollowing configuration to the spring context:
and, when I run the application, in the line: AbstractRequestProcessor processor =Code:<bean id="cifAspect" class="com.spring.aspect.CifAspect"/> <aop:config> <aop:pointcut id="cifProcessRequest" expression="execution(* com.express.web.rc.cif.CifRequestProcessor.processRequest(..))"/> <aop:aspect ref="cifAspect"> <aop:before pointcut-ref="cifProcessRequest" method="validateBrBeforeCifProcessRequest"/> </aop:aspect> </aop:config>
(AbstractRequestProcessor) _requestProcessors.get(requestType);
I have the exception:
So, before I added this adviser to the context it worked perfect. Why now I have this ClassCastException, and what to do to make it works?Code:ClassCastException: Cannot cast $Proxy9(id=209) to com.express..web.rc.AbstractRequestProcessor.
THANKS IN ADVANCE.


Reply With Quote
