Results 1 to 2 of 2

Thread: Using a dynamic proxy as the command class

  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    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.

Similar Threads

  1. Replies: 8
    Last Post: Oct 18th, 2007, 09:23 AM
  2. Other Hibernate DAO LazyInitializationExceptions
    By bernardsirius in forum Data
    Replies: 5
    Last Post: Feb 18th, 2005, 04:09 PM
  3. Replies: 9
    Last Post: Feb 8th, 2005, 09:25 PM
  4. dynamic proxies och hibernate
    By erik_romson in forum Data
    Replies: 3
    Last Post: Dec 18th, 2004, 04:19 AM
  5. dynamic proxies och hibernate
    By erik_romson in forum Security
    Replies: 1
    Last Post: Dec 13th, 2004, 01:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •