Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: how to inject proxyfactorybean?

  1. #11
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    Well, your story tells us you want to wrap the proxy factory bean itself.

    The proxy factory bean creates proxies, as the name says so you should be fine with that. Maybe you could explain your situation a bit more.
    Alef Arendsen
    SpringSource
    http://www.springsource.com

  2. #12
    Join Date
    Sep 2004
    Posts
    18

    Default

    So I will give you the code to explain that, this is code I have shown before:
    applicationContext.xml
    Code:
    <bean id="mixinbean" class="org.springframework.aop.framework.ProxyFactoryBean">
           <property name="target"><ref local="testBean"/></property>
           <property name="interceptorNames">
            <list>
                <value>mixinAdvisor</value>
            </list>
           </property>
     </bean>
    
    <bean id="wrapbean" 
        class="org.springframework.aop.framework.ProxyFactoryBean"> 
        <property name="target"><ref local="mixinbean"/></property> 
        <property name="interceptorNames"> 
            <list> 
                <value>testInterceptor</value> 
            </list> 
        </property> 
    </bean> 
    
    	<bean id="mixinAdvisor"
    		class="test.advisor.MixinAdvisor"
    		singleton="false">
    	</bean>
    	<bean id="testBean" class="test.beans.TestBean">	
    	</bean>
    this is the code of app-servlet.xml
    Code:
    	<bean id="testController" class=test.controller.testController">
    	   <property name="testbean"><ref bean="wrapbean"/></property>
    	</bean>
    this is the test.advisor.MixinAdvisor class code:
    Code:
    public class MixinAdvisor  extends DefaultIntroductionAdvisor&#123;
       public MixinAdvisor&#40;&#41;&#123;
    	super&#40;new testmixinImpl&#40;&#41;, testmixin.class&#41;;
       &#125;
    &#125;
    so the testbean will implements testmixinImpl class after mixin.

    this is the testInterceptor code:
    Code:
    public Object invoke&#40;MethodInvocation invocation&#41; throws Throwable &#123;
    ReflectiveMethodInvocation rinvocation = &#40;ReflectiveMethodInvocation&#41;invocation;
    if&#40;rinvocation.getThis&#40;&#41; instanceof testmixin&#41;
    &#123;
    //do some business code.....
    &#125;
    &#125;
    I have some error will the code like above.

  3. #13
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    I'd just add both advisors (the interceptor as well as the mixinAdvisor) to the same ProxyFactoryBean. You should be all set then!
    Alef Arendsen
    SpringSource
    http://www.springsource.com

  4. #14
    Join Date
    Dec 2004
    Posts
    14

    Default multipal proxyfactorybean use case

    i have the same situation. i am using the followling code

    WebApplicationContext waContext = WebApplicationContextUtils.getRequiredWebApplicati onContext(servletContext);
    return (BusinessServices) waContext.getBean("springBusinessService");

    and this is my spring-config.xml file

    <bean id="hibernateDataService" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>DataServices</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>hibernateInterceptor</value>

    //hibernate target code
    <value>hibernateDataServiceTarget</value>
    </list>
    </property>
    </bean>




    <bean id="businessServiceImpl" class="BusinessService">
    <property name="dataService">
    <ref bean="hibernateDataService"/>
    </property>
    </bean>

    <bean id="springBusinessService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="springTransactionManager"/>
    </property>
    <property name="target">
    <ref bean="businessServiceImpl"/>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="echo">PROPAGATION_REQUIRED</prop>
    <prop key="echoUnique">PROPAGATION_REQUIRES_NEW</prop>
    <prop key="test">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>


    can i create the multiple ProxyFactoryBean so that i pass the differen bean to my businessServiceImpl bean.

    i want to create multipal TransactionProxyFactoryBean that will be get when my application is using hibernate code, only require code will be there not all the code.

    Regards
    Ajay

  5. #15
    Join Date
    Feb 2009
    Location
    Kolkata
    Posts
    1

    Default

    Quote Originally Posted by kalfen View Post
    this is the test code:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    	 <!-- <bean id="multiinterface" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    		  <list>
    			<value>com.tmd.bingo.portal.framework.InterfaceA</value>
    			<value>com.tmd.bingo.portal.framework.InterfaceB</value>
    			<value>com.tmd.bingo.portal.framework.InterfaceC</value>
    		  </list>	
    		</property>
    		<property name="interceptorNames">
    			<value>NameMethodPointCutAdvisor</value>
    		</property>
    		<property name="target">
    			<ref bean="interfaceAimpl" />
    			<ref bean="interfaceBimpl" />
    			<ref bean="interfaceCimpl" />
    		</property>
    	</bean>-->
    	
    	
    	<bean id="interfacea" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    		  	<value>com.tmd.bingo.portal.framework.InterfaceA</value>
    		</property>
    		<!-- <property name="interceptorNames">
    			<value>NameMethodPointCutAdvisor</value>
    		</property>-->
    		<property name="target">
    			<ref bean="interfaceAimpl" />
    		</property>
    	</bean>
    	
    	<bean id="interfaceb" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    		  	<value>com.tmd.bingo.portal.framework.InterfaceB</value>
    		</property>
    		<!-- <property name="interceptorNames">
    			<value>NameMethodPointCutAdvisor</value>
    		</property>-->
    		<property name="target">
    			<ref bean="interfaceBimpl" />
    		</property>
    	</bean>
    	
    	<bean id="interfacec" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    		  	<value>com.tmd.bingo.portal.framework.InterfaceC</value>
    		</property>
    		<!-- <property name="interceptorNames">
    			<value>NameMethodPointCutAdvisor</value>
    		</property>-->
    		<property name="target">
    			<ref bean="interfaceCimpl" />
    		</property>
    	</bean>
    	
    	
    	
    	
    	<!-- <bean id="NameMethodPointCutAdvisor"
    		class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
    		<property name="mappedName">
    			<value>dis*</value>
    		</property>
    		<property name="advice">
    			<ref bean="LoggingAroundAdvice" />
    		</property>
    	</bean>-->
    	
    	<bean id="interfaceAimpl" class="com.tmd.bingo.portal.framework.InterfaceA"></bean>
    	<bean id="interfaceBimpl" class="com.tmd.bingo.portal.framework.InterfaceB"></bean>
    	<bean id="interfaceCimpl" class="com.tmd.bingo.portal.framework.InterfaceC"></bean>
    	
    	<!-- <bean id="LoggingAroundAdvice" class="com.tmd.bingo.portal.framework.LoggingAroundAdvice"></bean>-->
    	
    	<!-- <bean id="messagewritter" class="com.tmd.bingo.portal.framework.MessageWritter">
    	
    	     <constructor-arg>
    			<value>Arabinda</value>
    		</constructor-arg>
    	</bean>	-->
    		
    		
    	
    </beans>
    I got org.springframework.beans.BeanInstantiationExcepti on when I went this type of code
    Last edited by Arabinda; Feb 26th, 2009 at 04:32 AM.

Similar Threads

  1. Replies: 6
    Last Post: Sep 28th, 2005, 04:14 PM
  2. Replies: 6
    Last Post: Apr 21st, 2005, 06:41 PM
  3. Inject into a Struts form bean?
    By azzoti in forum Web
    Replies: 1
    Last Post: Apr 5th, 2005, 11:49 AM
  4. Replies: 1
    Last Post: Dec 14th, 2004, 11:53 PM
  5. ProxyFactoryBean proxying singleton
    By bst@jcs.be in forum AOP
    Replies: 2
    Last Post: Nov 22nd, 2004, 09:21 AM

Posting Permissions

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