line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Apache-Singleton |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2009 by Michael Schout. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Apache::Singleton::Request; |
11
|
|
|
|
|
|
|
$Apache::Singleton::Request::VERSION = '0.17'; |
12
|
|
|
|
|
|
|
# ABSTRACT: One instance per One Request |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
95435
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
48
|
|
15
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
7
|
use base 'Apache::Singleton'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
439
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
BEGIN { |
20
|
2
|
100
|
|
2
|
|
10
|
use constant MP2 => $mod_perl::VERSION >= 1.99 ? 1 : 0; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
159
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
5
|
if (MP2) { |
23
|
|
|
|
|
|
|
require Apache2::RequestUtil; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
2
|
|
|
|
|
350
|
require Apache; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _get_instance { |
31
|
8
|
|
|
8
|
|
10
|
my $class = shift; |
32
|
8
|
|
|
|
|
17
|
my $r = MP2 ? Apache2::RequestUtil->request : Apache->request; |
33
|
8
|
|
|
|
|
28
|
my $key = "apache_singleton_$class"; |
34
|
8
|
|
|
|
|
15
|
return $r->pnotes($key); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _set_instance { |
38
|
4
|
|
|
4
|
|
8
|
my($class, $instance) = @_; |
39
|
4
|
|
|
|
|
8
|
my $r = MP2 ? Apache2::RequestUtil->request : Apache->request; |
40
|
4
|
|
|
|
|
12
|
my $key = "apache_singleton_$class"; |
41
|
4
|
|
|
|
|
10
|
$r->pnotes($key => $instance); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |