lm-sistemi-software-distrib.../src/main/kotlin/drills/drill02/exercise3/MathFactory.kt

16 lines
383 B
Kotlin

package drills.drill02.exercise3
import java.lang.reflect.Proxy
class MathFactory {
fun create(logger: Boolean = false): Math {
return if (logger) {
Proxy.newProxyInstance(
this::class.java.classLoader,
arrayOf(Math::class.java),
LogHandler(MathImpl())
) as Math
} else MathImpl()
}
}