Dynamic Proxy vs Scripting in java

64 views Asked by At

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

1

There are 1 answers

2
Rami On BEST ANSWER

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.