Results 1 to 3 of 3

Thread: TransactionProxyFactoryBean and cast

  1. #1
    Join Date
    Mar 2009
    Posts
    2

    Default TransactionProxyFactoryBean and cast

    Hi,

    The following code works fine, but I don't understand why :

    applicatinContext :

    Code:
    	<bean id="myUsersBusinessFacadeTarget" class="com.package.my.UsersBusinessFacadeImpl" autowire="autodetect"></bean>
    
    
    	<bean id="myUsersBusinessFacade" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager">
    			<ref bean="myTransactionManager" />
    		</property>
    		<property name="target">
    			<ref bean="myUsersBusinessFacadeTarget" />
    		</property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="*">PROPAGATION_REQUIRED</prop>
    				<prop key="*get">PROPAGATION_REQUIRED, readOnly</prop>
    				<prop key="*find">PROPAGATION_REQUIRED, readOnly</prop>
    			</props>
    		</property>
    	</bean>
    Java code :

    Code:
        public UsersBusinessFacade getUsersBusinessFacade() {
    
            ServletContext sc = ......;
            return (UsersBusinessFacade) WebApplicationContextUtils.getWebApplicationContext(sc).getBean("myUsersBusinessFacade");
        }
    Owing to me, myUsersBusinessFacade's type is TransactionProxyFactoryBean.
    How a cast to UsersBusinessFacade type works?

    Thanks for help.

  2. #2
    Join Date
    Jul 2008
    Location
    Columbus, OH
    Posts
    43

    Default

    Any 'FactoryBean' implementation doesn't follow the "regular" bean definition guidelines. The FactoryBean interface allows you to define the custom creation of objects if it is more difficult that just constructing a new instance.

    Another example of this is the LocalSessionFactoryBean to use with Hibernate.

    Check out the docs:

    http://static.springframework.org/sp...ctoryBean.html

    http://static.springframework.org/sp...on-factorybean
    Thanks,
    Frank Lamantia

  3. #3
    Join Date
    Mar 2009
    Posts
    2

    Default

    I missed this point.

    Thank you!

Posting Permissions

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