# 4.8 Proxy dynamic proxy

# 4.8 Proxy Dynamic Proxy

The Proxy dynamic proxy is the underlying implementation mechanism of jfinal AOP. The jfinal 4.0 version added the com.jfinal.proxy module to eliminate the dependency on cglib/asm for dynamic proxy implementation.

The proxy module needs to run under the JDK environment. If you need to run it under JRE, you can add the following configuration for support:

public void configConstant(Constants me) {
 
  // Configuration method for versions before 4.6: me.setProxyFactory(new CglibProxyFactory());
  me.setToCglibProxyFactory();  // New configuration method in version 4.6
}
1
2
3
4
5

The above configuration will switch to the cglib implementation of the proxy module. You need to add its maven dependency in pom.xml:

<dependency>
   <groupId>cglib</groupId>
   <artifactId>cglib-nodep</artifactId>
   <version>3.2.5</version>
</dependency>
1
2
3
4
5

If you are using it in a "non-web environment", the configuration method is as follows:

// Configuration method for versions before 4.6: ProxyManager.me().setProxyFactory(new CglibProxyFactory());
ProxyManager.me().setToCglibProxyFactory();
1
2
Last Updated: 9/17/2023, 6:05:19 AM