line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Apache::Session::Flex |
4
|
|
|
|
|
|
|
# Apache persistent user sessions stored however you want |
5
|
|
|
|
|
|
|
# Copyright(c) 2000, 2001 Jeffrey William Baker (jwbaker@acm.org) |
6
|
|
|
|
|
|
|
# Distribute under the Perl License |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
############################################################################ |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Apache::Session::Flex; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
2772
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
138
|
|
13
|
1
|
|
|
1
|
|
7
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
152
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = '1.01'; |
16
|
|
|
|
|
|
|
@ISA = qw(Apache::Session); |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
786
|
use Apache::Session; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
199
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub populate { |
21
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
13
|
my $store = "Apache::Session::Store::$self->{args}->{Store}"; |
24
|
2
|
|
|
|
|
5
|
my $lock = "Apache::Session::Lock::$self->{args}->{Lock}"; |
25
|
2
|
|
|
|
|
6
|
my $gen = "Apache::Session::Generate::$self->{args}->{Generate}"; |
26
|
2
|
|
|
|
|
5
|
my $ser = "Apache::Session::Serialize::$self->{args}->{Serialize}"; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
4
|
for my $class ($store, $lock) { |
29
|
4
|
50
|
|
|
|
64
|
unless ($class->can('new')) { |
30
|
0
|
0
|
|
|
|
0
|
eval "require $class" || die $@; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
2
|
100
|
|
|
|
31
|
unless ($gen->can('validate')) { |
35
|
1
|
50
|
|
|
|
88
|
eval "require $gen" || die $@; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
2
|
100
|
|
|
|
29
|
unless ($ser->can('serialize')) { |
39
|
1
|
50
|
|
|
|
49
|
eval "require $ser" || die $@; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
19
|
$self->{object_store} = new $store $self; |
43
|
2
|
|
|
|
|
13
|
$self->{lock_manager} = new $lock $self; |
44
|
|
|
|
|
|
|
{ |
45
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
152
|
|
|
2
|
|
|
|
|
2
|
|
46
|
2
|
|
|
|
|
3
|
$self->{generate} = \&{$gen . '::generate'}; |
|
2
|
|
|
|
|
11
|
|
47
|
2
|
|
|
|
|
3
|
$self->{validate} = \&{$gen . '::validate'}; |
|
2
|
|
|
|
|
9
|
|
48
|
2
|
|
|
|
|
2
|
$self->{serialize} = \&{$ser . '::serialize'}; |
|
2
|
|
|
|
|
7
|
|
49
|
2
|
|
|
|
|
4
|
$self->{unserialize} = \&{$ser . '::unserialize'}; |
|
2
|
|
|
|
|
7
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
6
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Apache::Session::Flex - Specify everything at runtime |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
use Apache::Session::Flex; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
tie %hash, 'Apache::Session::Flex', $id, { |
68
|
|
|
|
|
|
|
Store => 'DB_File', |
69
|
|
|
|
|
|
|
Lock => 'Null', |
70
|
|
|
|
|
|
|
Generate => 'MD5', |
71
|
|
|
|
|
|
|
Serialize => 'Storable' |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# or |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
tie %hash, 'Apache::Session::Flex', $id, { |
77
|
|
|
|
|
|
|
Store => 'Postgres', |
78
|
|
|
|
|
|
|
Lock => 'Null', |
79
|
|
|
|
|
|
|
Generate => 'MD5', |
80
|
|
|
|
|
|
|
Serialize => 'Base64' |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# you decide! |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This module is an implementation of Apache::Session. Unlike other |
88
|
|
|
|
|
|
|
implementations, it allows you to specify the backing store, locking scheme, |
89
|
|
|
|
|
|
|
ID generator, and data serializer at runtime. You do this by passing |
90
|
|
|
|
|
|
|
arguments in the usual Apache::Session style (see SYNOPSIS). You may |
91
|
|
|
|
|
|
|
use any of the modules included in this distribution, or a module of your |
92
|
|
|
|
|
|
|
own making. If you wish to use a module of your own making, you should |
93
|
|
|
|
|
|
|
make sure that it is available under the Apache::Session package namespace. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 USAGE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
You pass the modules you want to use as arguments to the constructor. The |
98
|
|
|
|
|
|
|
Apache::Session::Whatever part is appended for you: you should not supply it. |
99
|
|
|
|
|
|
|
For example, if you wanted to use MySQL as the backing store, you should give |
100
|
|
|
|
|
|
|
the argument C<Store => 'MySQL'>, and not |
101
|
|
|
|
|
|
|
C<Store => 'Apache::Session::Store::MySQL'>. There are four modules that you |
102
|
|
|
|
|
|
|
need to specify. Store is the backing store to use. Lock is the locking scheme. |
103
|
|
|
|
|
|
|
Generate is the ID generation module. Serialize is the data serialization |
104
|
|
|
|
|
|
|
module. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
There are many modules included in this distribution. For each role, they are: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Store: |
109
|
|
|
|
|
|
|
MySQL |
110
|
|
|
|
|
|
|
Postgres |
111
|
|
|
|
|
|
|
DB_File |
112
|
|
|
|
|
|
|
File |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Lock: |
115
|
|
|
|
|
|
|
Null |
116
|
|
|
|
|
|
|
MySQL |
117
|
|
|
|
|
|
|
Semaphore |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Generate: |
120
|
|
|
|
|
|
|
MD5 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Serialize: |
123
|
|
|
|
|
|
|
Storable |
124
|
|
|
|
|
|
|
Base64 |
125
|
|
|
|
|
|
|
UUEncode |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
In addition to the arguments needed by this module, you must provide whatever |
128
|
|
|
|
|
|
|
arguments are expected by the backing store and lock manager that you are |
129
|
|
|
|
|
|
|
using. Please see the documentation for those modules. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This module was written by Jeffrey William Baker <jwbaker@acm.org>. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SEE ALSO |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L<Apache::Session::File>, L<Apache::Session::DB_File>, |
138
|
|
|
|
|
|
|
L<Apache::Session::MySQL>, L<Apache::Session::Postgres>, L<Apache::Session> |