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
|
|
1477
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
13
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA $VERSION);
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
70
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = '1.01';
|
16
|
|
|
|
|
|
|
@ISA = qw(Apache::Session);
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
526
|
use Apache::Session;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
203
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub populate {
|
21
|
2
|
|
|
2
|
0
|
2
|
my $self = shift;
|
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
9
|
my $store = "Apache::Session::Store::$self->{args}->{Store}";
|
24
|
2
|
|
|
|
|
4
|
my $lock = "Apache::Session::Lock::$self->{args}->{Lock}";
|
25
|
2
|
|
|
|
|
5
|
my $gen = "Apache::Session::Generate::$self->{args}->{Generate}";
|
26
|
2
|
|
|
|
|
3
|
my $ser = "Apache::Session::Serialize::$self->{args}->{Serialize}";
|
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
5
|
for my $class ($store, $lock) {
|
29
|
4
|
50
|
|
|
|
40
|
unless ($class->can('new')) {
|
30
|
0
|
0
|
|
|
|
0
|
eval "require $class" || die $@;
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
}
|
33
|
|
|
|
|
|
|
|
34
|
2
|
100
|
|
|
|
18
|
unless ($gen->can('validate')) {
|
35
|
1
|
50
|
|
|
|
56
|
eval "require $gen" || die $@;
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
2
|
100
|
|
|
|
23
|
unless ($ser->can('serialize')) {
|
39
|
1
|
50
|
|
|
|
52
|
eval "require $ser" || die $@;
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
14
|
$self->{object_store} = new $store $self;
|
43
|
2
|
|
|
|
|
8
|
$self->{lock_manager} = new $lock $self;
|
44
|
|
|
|
|
|
|
{
|
45
|
1
|
|
|
1
|
|
8
|
no strict 'refs';
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
166
|
|
|
2
|
|
|
|
|
4
|
|
46
|
2
|
|
|
|
|
3
|
$self->{generate} = \&{$gen . '::generate'};
|
|
2
|
|
|
|
|
7
|
|
47
|
2
|
|
|
|
|
4
|
$self->{validate} = \&{$gen . '::validate'};
|
|
2
|
|
|
|
|
5
|
|
48
|
2
|
|
|
|
|
4
|
$self->{serialize} = \&{$ser . '::serialize'};
|
|
2
|
|
|
|
|
5
|
|
49
|
2
|
|
|
|
|
2
|
$self->{unserialize} = \&{$ser . '::unserialize'};
|
|
2
|
|
|
|
|
7
|
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
3
|
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 'MySQL'>, and not
|
101
|
|
|
|
|
|
|
C '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 .
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SEE ALSO
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L, L,
|
138
|
|
|
|
|
|
|
L, L, L
|