【发布时间】:2014-02-19 21:41:03
【问题描述】:
如果我正在考虑为我正在设计的库中的 RBAC 子系统实现设计,我将不胜感激。下表提供了类名和简要说明:
Name Description
User Abstract Base Class (so it can't be instantiated)
IRole Interface
Role Implements IRole
RoleCollection Collection of roles
Personnel ABC. Represents a user in the system. Derives from User, delegates to (i.e. has-a) collection of roles (RoleCollection)
PersonnelFactory Creates specific personnel types
PersonnelFactory创建的一些人员示例:
SystemAdminPersonnel
AccountsPersonnel
... etc
我想将角色划分为离散的类,其中专用的自定义角色类(实现 IRole 接口)执行特定的功能。也就是说例如:
SystemAdminRole 可以有以下方法:
clearSystemCache();
createNewCache();
... etc.
虽然 AccountsRole 可以有以下方法:
updateUserAccount();
getAccountBalance();
addAmountToAccountBalance();
... etc
理想情况下,我希望系统显示以下属性:
能够向角色添加新功能,而无需修改代码。我打算通过使用(a)脚本(b)可调用存储过程来做到这一点
-
当我向角色添加新方法时,我希望具有该角色的 Personnel 对象能够“自动”执行新功能,而无需重新编译代码。
李>
不管它的价值,这是我在许多项目中都需要的一个系统组件——一旦我有了正确的设计,我设想用以下语言(不同的项目)实现代码:Java、Python、Ruby(可能,PHP,C++),但是,我想首先正确地设计系统(连同上面提到的所需属性),而不必依赖于实现系统的语言提供的结构。
非常感谢任何有关如何改进或修改上述设计以获得所需功能(无需重新编码的可扩展性)的建议。
【问题讨论】:
标签: design-patterns architecture rbac