开发者

How to expose a dynamic list of method calls in Java?

How would you suggest going about implementing the following scenario. I have a few thoughts, but none that satisfies my problem 开发者_运维技巧in totality, so I would like to get your input.

I am building a type of work-flow application. The user creates a pipeline of activities that then needs to be executed. The problem I face is this. Each "widget" in the pipeline must define what it can accept as input, and what it will produce as output. It can receive any number of input "streams" and also produce multiple "streams" of output. Now the problem occurs. These need to by dynamic. For instance, someone should be able to write a plugin for the application where he defines his own widget, with inputs and outputs. But other widgets need to be able to connect to it, so that they can send their output to the new one, or receive input from it.

How should one go about firstly exposing the list of acceptable inputs and outputs, and secondly, how can I calculate which method to call on the widget. For example if I want to send output from my widget to the new one, I need to be able to calculate if there is an acceptable receiving method (in which case there could be more than one), and secondly, I need to know the method to call to give the data to.

I have had a look at closure, delegates etc, which seem to be able to do what I need. Just thought I would get some more input first.

Thanks.


I would suggest that you enforce that all your components implement one or more interfaces allowing other components and the framework to use those interfaces to interrogate the component on what it can send and what it can receive.

This will make your code more robust, and require less magic to work.


Have a look at message-driven-architectures and Mule ESB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜