简体   繁体   中英

Dynamic Proxy vs Scripting in java

In case of customize object behavior at runtime, Java seems to provide two solutions, Java Scripting and Dynamic Proxy.

suppose I have a configuration file and an interface I in Java, I can either create and load class implementing I according to configuration or I can use dynamic proxy to make implementation of the I as well. Both technique is a little advanced. I am now wondering

1- which of these two ways is more efficient in development? 2- which of these technology is more optimized in performance? 3- which way is more maintainable? (before product is stable, configuration might be changed frequently)

Sincerely

I think the first technique is the most widely used one. I have never used dynamic proxy to be honest, but coding against an interface and then determining the concrete type based on configuration is simply the inversion of control concept (or dependency injection ) which is used in Spring and adopted by many other frameworks as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM