Is there a way that we could invoke a function dynamically? For example, at some point of the program, I need to call a function, but the function name, input parameters need to be dynamic, which will be define in a config file, loaded when the program start. The function always return a integer. the config file like this:
You can either build on top of reflection APi to do this, or spring api has something similar.
define
【在 o*****l 的大作中提到】 : Is there a way that we could invoke a function dynamically? : For example, at some point of the program, I need to call a function, but : the function name, input parameters need to be dynamic, which will be define : in a config file, loaded when the program start. The function always : return a integer. : the config file like this: : : : :
Or you can use a fixed function name but dynamic class name. I think it's easier this way.
but define
【在 o*****l 的大作中提到】 : Is there a way that we could invoke a function dynamically? : For example, at some point of the program, I need to call a function, but : the function name, input parameters need to be dynamic, which will be define : in a config file, loaded when the program start. The function always : return a integer. : the config file like this: : : : :
if your methods are encapculated in specific class, java reflection will meet your requirement.
define
【在 o*****l 的大作中提到】 : Is there a way that we could invoke a function dynamically? : For example, at some point of the program, I need to call a function, but : the function name, input parameters need to be dynamic, which will be define : in a config file, loaded when the program start. The function always : return a integer. : the config file like this: : : : :
wh
11 楼
多谢!你还能找到链接吗?我google前几个都不是。
【在 w***s 的大作中提到】 : 好像是叫 有爱无爱都铭心刻骨?
b*y
12 楼
哈哈 写的时候是"i can handle every case" debug的时候是"I can't even handle myself"