由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - invoke a function dynamically in Java?
相关主题
AJAX: simple question on parameter passingHow to use "p = r.exec("simon parameters
Can you show me ur Log4J config file?copy constructor都什么时候be called啊
a question on interfaceUrgent!
谁深入解答一下Java的Reflection机制How to make php and servlet work togethe
how do I get parameters passed by text area (formweblogic 分布式问题
A design for parameter passingparameters to main????
synchronized method does lock the object that passed into the method as a parameter?help: 如何用servlet实现zip文件下载?
有熟悉Java Reflection的吗Suggestion Re: 发现 synchronized 的一个问题
相关话题的讨论汇总
话题: function话题: string话题: java话题: invoke
进入Java版参与讨论
1 (共1页)
o*****l
发帖数: 539
1
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:




g*****g
发帖数: 34805
2
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:
:
:
:
:

k***r
发帖数: 4260
3
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:
:
:
:
:

g**********y
发帖数: 14569
4
少写reflective的code, 多活20年。写的时候看上去很neat, 但是debug reflective的
code真的是nightmare, 哪怕是你自己写的。
感觉reflective就象花credit card, 用的时候很爽,还钱的时候很痛!
T*********g
发帖数: 496
5
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:
:
:
:
:

b******y
发帖数: 1684
6
哈哈
写的时候是"i can handle every case"
debug的时候是"I can't even handle myself"

【在 g**********y 的大作中提到】
: 少写reflective的code, 多活20年。写的时候看上去很neat, 但是debug reflective的
: code真的是nightmare, 哪怕是你自己写的。
: 感觉reflective就象花credit card, 用的时候很爽,还钱的时候很痛!

A**o
发帖数: 1550
7
我是先debug过别人的reflection代码,于是从此敬而远之。

【在 b******y 的大作中提到】
: 哈哈
: 写的时候是"i can handle every case"
: debug的时候是"I can't even handle myself"

r*****l
发帖数: 2859
8
这个比喻有点意思。
不过reflection没有那么可怕了。话说回来,如果reflection能
被其它东西实现,Java里面也不会有reflection了。

【在 g**********y 的大作中提到】
: 少写reflective的code, 多活20年。写的时候看上去很neat, 但是debug reflective的
: code真的是nightmare, 哪怕是你自己写的。
: 感觉reflective就象花credit card, 用的时候很爽,还钱的时候很痛!

c******n
发帖数: 4965
9
我是新手啊
我觉得reflection 其实就是abstract,delegation 的concept 到extreme,
1 (共1页)
进入Java版参与讨论
相关主题
Suggestion Re: 发现 synchronized 的一个问题how do I get parameters passed by text area (form
Re: how do I get parameters passed by teA design for parameter passing
今天面试。synchronized method does lock the object that passed into the method as a parameter?
【跪求】java applet下怎么执行系统的一个程序?有熟悉Java Reflection的吗
AJAX: simple question on parameter passingHow to use "p = r.exec("simon parameters
Can you show me ur Log4J config file?copy constructor都什么时候be called啊
a question on interfaceUrgent!
谁深入解答一下Java的Reflection机制How to make php and servlet work togethe
相关话题的讨论汇总
话题: function话题: string话题: java话题: invoke