"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/lib/Apache/Session/Flex.pm" (15 Sep 2009, 3826 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Flex.pm" see the Fossies "Dox" file reference documentation.

    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 use strict;
   13 use vars qw(@ISA $VERSION);
   14 
   15 $VERSION = '1.01';
   16 @ISA = qw(Apache::Session);
   17 
   18 use Apache::Session;
   19 
   20 sub populate {
   21     my $self = shift;
   22 
   23     my $store = "Apache::Session::Store::$self->{args}->{Store}";
   24     my $lock  = "Apache::Session::Lock::$self->{args}->{Lock}";
   25     my $gen   = "Apache::Session::Generate::$self->{args}->{Generate}";
   26     my $ser   = "Apache::Session::Serialize::$self->{args}->{Serialize}";
   27 
   28     for my $class ($store, $lock) {
   29         unless ($class->can('new')) {
   30             eval "require $class" || die $@;
   31         }
   32     }
   33 
   34     unless ($gen->can('validate')) {
   35         eval "require $gen" || die $@;
   36     }
   37 
   38     unless ($ser->can('serialize')) {
   39         eval "require $ser" || die $@;
   40     }
   41 
   42     $self->{object_store} = new $store $self;
   43     $self->{lock_manager} = new $lock  $self;
   44     {
   45         no strict 'refs';
   46         $self->{generate}     = \&{$gen . '::generate'};
   47         $self->{validate}     = \&{$gen . '::validate'};
   48         $self->{serialize}    = \&{$ser . '::serialize'};
   49         $self->{unserialize}  = \&{$ser . '::unserialize'};
   50     }
   51 
   52     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>