line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ubic::ServiceLoader::Default; |
2
|
|
|
|
|
|
|
$Ubic::ServiceLoader::Default::VERSION = '1.60'; |
3
|
|
|
|
|
|
|
# ABSTRACT: default service loader |
4
|
|
|
|
|
|
|
|
5
|
23
|
|
|
23
|
|
23496
|
use strict; |
|
23
|
|
|
|
|
19
|
|
|
23
|
|
|
|
|
476
|
|
6
|
23
|
|
|
23
|
|
67
|
use warnings; |
|
23
|
|
|
|
|
19
|
|
|
23
|
|
|
|
|
438
|
|
7
|
|
|
|
|
|
|
|
8
|
23
|
|
|
23
|
|
68
|
use parent qw( Ubic::ServiceLoader::Base ); |
|
23
|
|
|
|
|
21
|
|
|
23
|
|
|
|
|
78
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
23
|
|
|
23
|
|
726
|
use Scalar::Util qw(blessed); |
|
23
|
|
|
|
|
24
|
|
|
23
|
|
|
|
|
4366
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $eval_id = 1; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
24
|
|
|
24
|
1
|
91
|
return bless {} => shift; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub load { |
20
|
24
|
|
|
24
|
1
|
27
|
my $self = shift; |
21
|
24
|
|
|
|
|
30
|
my ($file) = @_; |
22
|
|
|
|
|
|
|
|
23
|
24
|
50
|
|
|
|
800
|
open my $fh, '<', $file or die "Can't open $file: $!"; |
24
|
24
|
|
|
|
|
34
|
my $content = do { local $/; <$fh> }; |
|
24
|
|
|
|
|
101
|
|
|
24
|
|
|
|
|
372
|
|
25
|
24
|
50
|
|
|
|
196
|
close $fh or die "Can't close $file: $!"; |
26
|
|
|
|
|
|
|
|
27
|
24
|
|
|
|
|
84
|
$content = "# line 1 $file\n$content"; |
28
|
24
|
|
|
|
|
113
|
$content = "package UbicService".($eval_id++).";\n# line 1 $file\n$content"; |
29
|
24
|
|
|
|
|
7745
|
my $service = eval $content; |
30
|
24
|
50
|
|
|
|
74
|
if ($@) { |
31
|
0
|
|
|
|
|
0
|
die "Failed to eval '$file': $@"; |
32
|
|
|
|
|
|
|
} |
33
|
24
|
50
|
|
|
|
113
|
unless (blessed $service) { |
34
|
0
|
|
|
|
|
0
|
die "$file doesn't contain any service"; |
35
|
|
|
|
|
|
|
} |
36
|
24
|
50
|
|
|
|
174
|
unless ($service->isa('Ubic::Service')) { |
37
|
0
|
|
|
|
|
0
|
die "$file returned $service instead of Ubic::Service"; |
38
|
|
|
|
|
|
|
} |
39
|
24
|
|
|
|
|
105
|
return $service; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |