| 1 | # Apache::AppSamurai:Session - Extension/wrapper for Apache::Session providing | ||||||||||||||
| 2 | # the same interface as Apache::Session::Flex with the ability to use | ||||||||||||||
| 3 | # additional features. | ||||||||||||||
| 4 | |||||||||||||||
| 5 | # $Id: Session.pm,v 1.9 2008/04/30 21:40:06 pauldoom Exp $ | ||||||||||||||
| 6 | |||||||||||||||
| 7 | ## | ||||||||||||||
| 8 | # Copyright (c) 2008 Paul M. Hirsch (paul@voltagenoir.org). | ||||||||||||||
| 9 | # All rights reserved. | ||||||||||||||
| 10 | # | ||||||||||||||
| 11 | # This program is free software; you can redistribute it and/or modify it under | ||||||||||||||
| 12 | # the same terms as Perl itself. | ||||||||||||||
| 13 | ## | ||||||||||||||
| 14 | |||||||||||||||
| 15 | # Includes code from Apache::Session developed by Jeffrey William Baker | ||||||||||||||
| 16 | # (jwbaker@acm.org) and others. | ||||||||||||||
| 17 | |||||||||||||||
| 18 | package Apache::AppSamurai::Session; | ||||||||||||||
| 19 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 21 | |||||||||||||||
| 22 | 1 | ▶ | use vars qw($VERSION @ISA $incl); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 23 | 1 | $VERSION = substr(q$Revision: 1.9 $, 10, -1); | |||||||||||||
| 24 | |||||||||||||||
| 25 | 1 | ▶ | use Apache::Session; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 26 | |||||||||||||||
| 27 | 1 | @ISA = qw( Apache::Session ); | |||||||||||||
| 28 | 1 | $incl = {}; | |||||||||||||
| 29 | |||||||||||||||
| 30 | 0 | ▶ | sub populate { | ||||||||||||
|
Subroutine
populate: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||
| 32 | |||||||||||||||
| 33 | # Allow standard Apache::Session syntax, special AppSamurai/<ITEM> | ||||||||||||||
| 34 | # syntax, or specifying a full module path. | ||||||||||||||
| 35 | 0 | my ($store, $lock, $gen, $ser); | |||||||||||||
| 36 | 0 | ▶ | if ($self->{args}->{Store} =~ /^AppSamurai\/([\w\d\_]+?)\s*$/i) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 37 | 0 | $store = "Apache::AppSamurai::Session::Store::$1"; | |||||||||||||
| 38 | } elsif ($self->{args}->{Store} =~ /::/) { | ||||||||||||||
| 39 | 0 | $store = $self->{args}->{Store}; | |||||||||||||
| 40 | } else { | ||||||||||||||
| 41 | 0 | $store = "Apache::Session::Store::$self->{args}->{Store}"; | |||||||||||||
| 42 | } | ||||||||||||||
| 43 | 0 | ▶ | if ($self->{args}->{Lock} =~ /^AppSamurai\/([\w\d\_]+?)\s*$/i) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 44 | 0 | $lock = "Apache::AppSamurai::Session::Lock::$1"; | |||||||||||||
| 45 | } elsif ($self->{args}->{Lock} =~ /::/) { | ||||||||||||||
| 46 | 0 | $lock = $self->{args}->{Lock}; | |||||||||||||
| 47 | } else { | ||||||||||||||
| 48 | 0 | $lock = "Apache::Session::Lock::$self->{args}->{Lock}"; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | 0 | ▶ | if ($self->{args}->{Generate} =~ /^AppSamurai\/([\w\d\_]+?)\s*$/i) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 51 | 0 | $gen = "Apache::AppSamurai::Session::Generate::$1"; | |||||||||||||
| 52 | } elsif ($self->{args}->{Generate} =~ /::/) { | ||||||||||||||
| 53 | 0 | $gen = $self->{args}->{Generate}; | |||||||||||||
| 54 | } else { | ||||||||||||||
| 55 | 0 | $gen = "Apache::Session::Generate::$self->{args}->{Generate}"; | |||||||||||||
| 56 | } | ||||||||||||||
| 57 | 0 | ▶ | if ($self->{args}->{Serialize} =~ /^AppSamurai\/([\w\d\_]+?)\s*$/i) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 58 | 0 | $ser = "Apache::AppSamurai::Session::Serialize::$1"; | |||||||||||||
| 59 | } elsif ($self->{args}->{Serialize} =~ /::/) { | ||||||||||||||
| 60 | 0 | $ser = $self->{args}->{Serialize}; | |||||||||||||
| 61 | } else { | ||||||||||||||
| 62 | 0 | $ser = "Apache::Session::Serialize::$self->{args}->{Serialize}"; | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | 0 | ▶ | if (!exists $incl->{$store}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 66 | 0 | ▶ | eval "require $store" || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 67 | 0 | $incl->{$store} = 1; | |||||||||||||
| 68 | } | ||||||||||||||
| 69 | |||||||||||||||
| 70 | 0 | ▶ | if (!exists $incl->{$lock}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 71 | 0 | ▶ | eval "require $lock" || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 72 | 0 | $incl->{$lock} = 1; | |||||||||||||
| 73 | } | ||||||||||||||
| 74 | |||||||||||||||
| 75 | 0 | ▶ | if (!exists $incl->{$gen}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 76 | 0 | ▶ | eval "require $gen" || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 77 | 0 | ▶ | eval '$incl->{$gen}->[0] = \&' . $gen . '::generate' || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 78 | 0 | ▶ | eval '$incl->{$gen}->[1] = \&' . $gen . '::validate' || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 79 | } | ||||||||||||||
| 80 | |||||||||||||||
| 81 | 0 | ▶ | if (!exists $incl->{$ser}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 82 | 0 | ▶ | eval "require $ser" || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 83 | 0 | ▶ | eval '$incl->{$ser}->[0] = \&' . $ser . '::serialize' || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 84 | 0 | ▶ | eval '$incl->{$ser}->[1] = \&' . $ser . '::unserialize' || die $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | 0 | $self->{object_store} = new $store $self; | |||||||||||||
| 88 | 0 | $self->{lock_manager} = new $lock $self; | |||||||||||||
| 89 | 0 | $self->{generate} = $incl->{$gen}->[0]; | |||||||||||||
| 90 | 0 | $self->{validate} = $incl->{$gen}->[1]; | |||||||||||||
| 91 | 0 | $self->{serialize} = $incl->{$ser}->[0]; | |||||||||||||
| 92 | 0 | $self->{unserialize} = $incl->{$ser}->[1]; | |||||||||||||
| 93 | |||||||||||||||
| 94 | 0 | return $self; | |||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | |||||||||||||||
| 98 | 1 | 1; # End of Apache::AppSamurai::Session | |||||||||||||
| 99 | |||||||||||||||
| 100 | __END__ | ||||||||||||||