Announcement Announcement Module
Collapse
No announcement yet.
Using a dynamic proxy as the command class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a dynamic proxy as the command class

    I want to use a dynamic proxy as my controller's command class but i get the following error:

    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy160] to required type [
    java.lang.Class] for property 'commandClass'

    The reason I am doing this is because I have 2 interfaces to one implementation class, since I want to use 1 interface when using the class internally and the other when exposing the class in the API. I find that using a dynamic proxy will solve this problem for me.

    My spring configuration are as follows:

    The definition of the proxy is as follows:



    Code:
    <bean id="jobTarget" class="com.bsd.cg.core.job.JobImpl"/>
    
        <bean id="job" class="org.springframework.aop.framework.ProxyFactoryBean">
            <property name="proxyInterfaces">
                <value>com.bsd.cg.core.job.Job</value>
            </property>
            <property name="target">
                <ref local="jobTarget"/>
            </property>
        </bean>
    and the controller is as follows:


    Code:
    <bean id="submissionController" class="com.bsd.webapp.action.submission.DEXSubmissionController" singleton="false">
            <property name="commandName">
                <value>job</value>
            </property>
            <property name="commandClass">
                <ref bean="job"/>
            </property>
            <property name="formView">
                <value>submission</value>
            </property>
            <property name="successView">
                <value>submission</value>
            </property>
            <property name="sessionForm">
                <value>true</value>
            </property>
            <property name="validators">
                <list>
                    <ref local="beanValidator"/>
                    <ref local="submissionValidator"/>
                </list>
            </property>
        </bean>

  • #2
    Don't supply the commandClass. The controller will use this setting to construct a new form. You will also need to override createForm and return the proxy.

    I would (doesn't mean its correct ) pass in the factory that creates the proxy to the controller, and then on createForm return a new instance from that factory.

    Comment

    Working...
    X