Announcement Announcement Module
No announcement yet.
controlling names of autogenerated proxies Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • controlling names of autogenerated proxies

    I am just using the default cglib stuff, and I've noticed that all of my interesting classes (dao's and services) get turned into things like '$Proxy154'. I would really like to control the auto-generated naming; for example, "com.myapp.$Proxy154" would be preferable or "com.myapp.MyClass$Proxy154" would be even better. This way I could use standard profiling tools to measure the runtime performance of my application.

    Can this be done?

  • #2
    For Jdk Dynamic Proxies (like $ProxyNNN) not. The name is build from private static final Strings and the package name it's added only if the interface is not pubilc, for public interfaces use "" as package name.

    For cglib proxys you have chances

    Need to set a net.sf.cglib.core.NamingPolicy implementation on the cglib Enhancer used by spring.
    The method createEnhancer of org.springframework.aop.framework.Cglib2AopProxy is protected, overwrite
    and configure the Enhancer.

    Extend DefaultAopProxyFactory and overwrite the public method createAopProxy to return your Cglib2AopProxy subclass.

    Now you can configure ProxyFactoryBeans to use this AopProxyFactory.



    • #3
      Thanks; I hunted around in the source to core container, but would have never found that stuff.