The Artima Developer Community
Sponsored Link

Java Buzz Forum
Spring: Encapsulate the fact that you have a proxy and a target bean via "inner beans"

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Spring: Encapsulate the fact that you have a proxy and a target bean via "inner beans" Posted: Jul 27, 2004 6:23 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Spring: Encapsulate the fact that you have a proxy and a target bean via "inner beans"
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
I have always been a little irked when I saw two bean definitions: The target: This is the real service that will do things The proxy: This holds interceptors and such, and then finally delegates to the target A usual Spring convention is to have fooTarget and foo. You know not to lookup *Target beans. However, I want to stop people :) I don't want it as an option. Well, while talking about this with Rod Johnson, he told me that he had implemented this while sitting at an AOP talk at a BeJUG meeting :) So now we can use inner bean classes: <bean id="person" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"><value>com.mycompany.Person</value></property> <!-- Use inner bean, not local reference to target --> <property name="target"> <bean class="com.mycompany.PersonImpl"> <property name="name"><value>Tony</value></property> <property name="age"><value>51</value></property> </bean> </property> <property name="interceptorNames"> <list> <value>myAdvisor</value> <value>debugInterceptor</value> </list> </property> </bean> Compare that to the old way: <bean id="personTarget" class="com.mycompany.PersonImpl"> <property name="name"><value>Tony</value></property> <property name="age"><value>51</value></property> </bean> <bean id="person" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"><value>com.mycompany.Person</value></property> <property name="target"><ref local="personTarget"/></property> <property name="interceptorNames"> <list> <value>myAdvisor</value> <value>debugInterceptor</value> </list> </property> </bean> Obviously, I omitted the interceptor declarations Thanks Rod, Juergen, and co!

Read: Spring: Encapsulate the fact that you have a proxy and a target bean via "inner beans"

Topic: HISTORY... Does it matter? Previous Topic   Next Topic Topic: User Experience Matters

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use