Announcement Announcement Module
No announcement yet.
Best way to build custom proxies? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best way to build custom proxies?

    I thought I'd troll for some insight on the best way to build a custom proxy?

    The requirement: I have about 20 beans of various classes. I have another bean where I want to consume these 20 beans with some added functionality. Basically I want to declare 20 entries that wrap the 20 target beans and add 2 more methods, where the behavior of these 2 new methods is controlled by metadata introduced in the XML file.

    My current method of resolution: Create a new class that will subclass ProxyConfig and implement FactoryBean - and has its own getters and setters for the metadata properies, and implements the methods I need that are driven off that metadata.

    Was there a better way to do this?

  • #2
    I'm not sure if I completely understand what you want to do, but it seems that you should use an IntroductionAdvisor adding the new interface and add it using one of the auto proxy creators like BeanNameAutoProxyCreator.


    • #3
      Thanks Rod -- the IntroductionAdvisor was what I was looking for.

      I basically had a concrete bean instance but I wanted to wrap it with proxies when I was setting it into another bean so I could introduce an interface at runtime to the bean.

      I had subclassed ProxyConfig and implemented FactoryBean to do this in a similar manner to how transactions were handled.