line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Session::Driver::aggregator::Drivers; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id$ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
CGI::Session::Driver::aggregator::Drivers - Drivers container for CGI::Session::Driver::aggregator |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
42956
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
88
|
|
12
|
2
|
|
|
2
|
|
12
|
use Carp qw(croak); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
863
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
0
|
102
|
sub new { bless { drivers => [] }, shift } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 add($driver_name, $driver_arguments) |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Adding a driver with extra arguments. driver_arguments will be used to instanctiate the driver. The driver must be an instance of CGI::Session::Driver. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$drivers = CGI::Session::Driver::aggregator::Drivers->new; |
25
|
|
|
|
|
|
|
$drivers->add('file', { Directory => '/tmp' }); |
26
|
|
|
|
|
|
|
$drivers->add('mysql', { Handle => $dbh }); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
NOTE: session data is read from drivers in the added order. In above example, reading from 'file' first, and then from 'mysql' (only when cannot read from 'file'). On the other hand, When writing session data, the order is 'mysql' -> 'file'. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
sub add { |
32
|
2
|
|
|
2
|
1
|
14
|
my ($self, $name, $args) = @_; |
33
|
2
|
|
|
|
|
7
|
$name = lc $name; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
6
|
my $package = "CGI::Session::Driver::$name"; |
36
|
2
|
0
|
0
|
|
|
2
|
if (!defined defined ${"${name}::VERSION"} || !defined @{"${name}::ISA"}) { |
|
2
|
|
|
|
|
304
|
|
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
eval "require $package"; |
38
|
0
|
0
|
|
|
|
|
if ($@) { |
39
|
0
|
|
|
|
|
|
croak "Failed to load a driver: $@"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
push @{ $self->{drivers} }, { package => $package, args => $args }; |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
0
|
|
sub drivers { @{ shift->{drivers} } } |
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |