The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::ServiceManage - Service management for Mojolicious Framework

VERSION

Version 0.01

SYNOPSIS

use Mojolicious::ServiceManage
my $service_manage = Mojolicious::ServiceManage->new({
      dbi=>DBIx::Custom->new(),
      models=>{},
      namespaces=>s["Mojolicious::Service"],
      lazy => 1
  });
  
## fetch a service
my $user_service = $service_manage->service("user");

DESCRIPTION

Mojolicious::ServiceManage是为Mojolicious框架提供Service支持的模块。

ATTRIBUTES

Mojolicious::ServiceManage 从 Mojolicious::Service中继承了所有属性,并实现以下属性。

services

存储service的属性。

namespaces

namespaces 用于说明service类所在的命名空间,这个属性的值是一个arrayref 类型的值,支持在多个命名空间中查找service。

lazy

用于说明是否启用懒加载模式。 如果值为true则启用懒加载,只有在实际请求一个service时才加载其类并实例化一个service对象。 如果为flase则在创建Mojolicious::ServiceManage时加载所有service类并实例化成对象。

METHODS

Mojolicious::ServiceManage 从 Mojolicious::Service中继承了所有方法,并实现以下方法。

load_service

根据service的名字加载service。

load_all_service

加载 namespaces 属性指定的所有命名空间下的所有service,并实例化。 注:只有在非懒加载模式的初始化阶段才会调用这个方法。

new

生成一个新的Mojolicious::ServiceManage对象。

service

根据 service 的名称从 services 属性中获取 service。如果在 services 属性中不存在对应的键,则尝试从 namespaces 属性指定的命名空间中加载并实例化一个service。如果尝试加载后仍获取失败,则返回 undef。

AUTHOR

wfso, <461663376@qq.com>

BUGS

Please report any bugs or feature requests to bug-mojolicious-servicemanage at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-ServiceManage. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Mojolicious::ServiceManage

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2017 wfso.

This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.