line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ubic::ServiceLoader::Default; |
2
|
|
|
|
|
|
|
$Ubic::ServiceLoader::Default::VERSION = '1.59'; |
3
|
|
|
|
|
|
|
# ABSTRACT: default service loader |
4
|
|
|
|
|
|
|
|
5
|
23
|
|
|
23
|
|
23366
|
use strict; |
|
23
|
|
|
|
|
27
|
|
|
23
|
|
|
|
|
513
|
|
6
|
23
|
|
|
23
|
|
68
|
use warnings; |
|
23
|
|
|
|
|
27
|
|
|
23
|
|
|
|
|
501
|
|
7
|
|
|
|
|
|
|
|
8
|
23
|
|
|
23
|
|
73
|
use parent qw( Ubic::ServiceLoader::Base ); |
|
23
|
|
|
|
|
23
|
|
|
23
|
|
|
|
|
92
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
23
|
|
|
23
|
|
816
|
use Scalar::Util qw(blessed); |
|
23
|
|
|
|
|
26
|
|
|
23
|
|
|
|
|
4895
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $eval_id = 1; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
24
|
|
|
24
|
1
|
101
|
return bless {} => shift; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub load { |
20
|
24
|
|
|
24
|
1
|
56
|
my $self = shift; |
21
|
24
|
|
|
|
|
37
|
my ($file) = @_; |
22
|
|
|
|
|
|
|
|
23
|
24
|
50
|
|
|
|
851
|
open my $fh, '<', $file or die "Can't open $file: $!"; |
24
|
24
|
|
|
|
|
30
|
my $content = do { local $/; <$fh> }; |
|
24
|
|
|
|
|
123
|
|
|
24
|
|
|
|
|
431
|
|
25
|
24
|
50
|
|
|
|
266
|
close $fh or die "Can't close $file: $!"; |
26
|
|
|
|
|
|
|
|
27
|
24
|
|
|
|
|
92
|
$content = "# line 1 $file\n$content"; |
28
|
24
|
|
|
|
|
111
|
$content = "package UbicService".($eval_id++).";\n# line 1 $file\n$content"; |
29
|
24
|
|
|
|
|
8603
|
my $service = eval $content; |
30
|
24
|
50
|
|
|
|
96
|
if ($@) { |
31
|
0
|
|
|
|
|
0
|
die "Failed to eval '$file': $@"; |
32
|
|
|
|
|
|
|
} |
33
|
24
|
50
|
|
|
|
136
|
unless (blessed $service) { |
34
|
0
|
|
|
|
|
0
|
die "$file doesn't contain any service"; |
35
|
|
|
|
|
|
|
} |
36
|
24
|
50
|
|
|
|
180
|
unless ($service->isa('Ubic::Service')) { |
37
|
0
|
|
|
|
|
0
|
die "$file returned $service instead of Ubic::Service"; |
38
|
|
|
|
|
|
|
} |
39
|
24
|
|
|
|
|
123
|
return $service; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |