如何在 Spring Web 应用程序中最好地实现用户特定的逻辑?
我面临以下问题:我正在构建的 Spring Web 应用程序非常特定于用户。每个用户可能都有一些适合他们需求的逻辑。 我想知道如何最好地实现这样一个“框架”,以便轻松注入新用户及其特定逻辑。
我正在考虑以下解决方案之一:
- 为所有用户提供通用接口并通过反射调用实际的特定于用户的实现。然后,当添加新用户时,我只需要编写逻辑、编译它并
- 使用某种 XML 可配置规则/工作流引擎将 *.class 文件放到服务器上。我可以预先构建各个逻辑块,然后当新用户出现时,我只需指定一个描述逻辑流程的 XML(Spring 配置)。
第一个解决方案最初看起来更容易,但在添加新用户时需要更多工作。第二个需要更多时间来开发规则/工作流程机制,但添加新用户应该更简单。
你怎么认为?还有其他想法吗?您知道有什么框架/模式可以帮助我完成这项任务吗?
谢谢, 彼得
I'm facing the following problem: the Spring web application I'm building is pretty user-specific. Each user might have some pieces of the logic tailored to their needs.
I'm wondering how to best implement such a 'framework' that would allow for easy injecting of new users along with their specific logic.
I'm thinking of one the following solutions:
- Providing a common interface for all users and invoking the actual user-specific implementations via reflection. Then, when adding a new user, I just need to write the logic, compile it and put the *.class file onto the server
- Using some sort of an XML-configurable rule/workflow engine. I can build the individual blocks of logic upfront and then when a new user shows up I just specify an XML (Spring config) describing the logic flow
The first solution seems initially easier but requires more work when adding a new user. The second takes more time to develop the rule/workflow mechanism, but then adding a new user should be simpler.
What do you think? Any other ideas? Do you know any frameworks/patterns that would help me in this task?
Thanks,
Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我更喜欢第一个解决方案(接口和编程),但它有一些缺点:
我会尝试使用一些脚本语言(例如 Java 脚本)。因此,特权用户可以通过前端上传脚本。脚本可以存储在数据库中,因此您可以更新应用程序而不必担心删除文件。
第二个好处是,可以限制脚本可以调用的函数。
I would prefer the first solution (Interface and programming) but it has some draw backs:
I would try use some scripting language (Java Script for example). So a privileged user can upload the scripts via the fronted. The scripts can be stored in the database, so you can update the application without fear to delete the files.
And the second good thing is, that it is may possible to restrict the functions that the script can invoke.