Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services 设计模式-使用一个服务从另一个服务逻辑上获取/释放资源_Web Services_Design Patterns_Web Applications - Fatal编程技术网

Web services 设计模式-使用一个服务从另一个服务逻辑上获取/释放资源

Web services 设计模式-使用一个服务从另一个服务逻辑上获取/释放资源,web-services,design-patterns,web-applications,Web Services,Design Patterns,Web Applications,我有一个服务,它提供对数据库的访问。此服务由多个应用程序使用。 其中一个应用程序需要特殊的功能。只有一个(管理)用户可以同时操作数据。此应用程序还与其他服务通信。我想用两种方法扩展第二个服务的功能: bool Acquire() 1. Check if an other user currently holds ownership. 1.1 if true => return false (acquirement failed). 1.2 if fa

我有一个服务,它提供对数据库的访问。此服务由多个应用程序使用。 其中一个应用程序需要特殊的功能。只有一个(管理)用户可以同时操作数据。此应用程序还与其他服务通信。我想用两种方法扩展第二个服务的功能:

bool Acquire()
    1. Check if an other user currently holds ownership.
        1.1 if true => return false (acquirement failed).
        1.2 if false => proceed.
    2. set ownership to client connection at server side.
    3. return true.

void Release()
    1. Check if the client connection currently holds ownership.
        1.1 if true => remove ownership of client connection at server side.
        1.2 if false => do nothing.

我的问题是:这是一个好的设计模式吗?在我看来,我不应该只为一个特殊的应用程序需求而更改数据库服务。

同意,这听起来像是一个泄漏的抽象。我认为将其转化为安全/授权问题更合适

定义一个特殊的安全令牌,该令牌一次只能授予一个用户

现在,您可以创建一个用于检查特定安全令牌是否是当前安全上下文的一部分的


通过将关注点分为不同的类,您可以忠实于原则。

+1 |因此,让我更详细地解释我的场景。以前称为“数据库服务”的是DomainContext(WCF)的派生类。我知道,有可能应用RequiresAuthentication或RequiresRole属性。。。你的意思是我应该使用类似的东西吗?因为你在.NET上,最简单的事情可能是将安全令牌作为角色添加到Thread.CurrentPrincipal。