mod_perl logo
perl icon







previous page: ModPerl::RegistryCooker - Cook mod_perl 2.0 Registry Modulespage up: mod_perl APIsnext page: ModPerl::Util - Helper mod_perl 2.0 Functions


ModPerl::RegistryLoader - Compile ModPerl::RegistryCooker scripts at server startup











Practical mod_perl

Practical mod_perl

By Stas Bekman, Eric Cholet
The mod_perl Developer's Cookbook

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Kobes
mod_perl Pocket Reference

mod_perl Pocket Reference

By Andrew Ford


Table of Contents

Synopsis

  # in startup.pl
  use ModPerl::RegistryLoader ();
  use APR::Pool ();
  
  # explicit uri => filename mapping 
  my $rlbb = ModPerl::RegistryLoader->new(
      package => 'ModPerl::RegistryBB',
      debug   => 1, # default 0
  );
  $rlbb->handler($uri, $filename);
  
  ###
  # uri => filename mapping using a helper function
  sub trans {
      my $uri = shift; 
      $uri =~ s|^/registry/|cgi-bin/|;
      return Apache::Server::server_root_relative(APR::Pool->new, $uri);
  }
  my $rl = ModPerl::RegistryLoader->new(
      package => 'ModPerl::Registry',
      trans   => \&trans,
  );
  $rl->handler($uri);
  
  ###
  $rlbb->handler($uri, $filename, $virtual_hostname);


TOP

Description

This modules allows compilation of scripts, running under packages derived from ModPerl::RegistryCooker, at server startup. The script's handler routine is compiled by the parent server, of which children get a copy and thus saves some memory by initially sharing the compiled copy with the parent and saving the overhead of script's compilation on the first request in every httpd instance.

This module is of course useless for those running the ModPerl::PerlRun handler, because the scripts get recompiled on each request under this handler.



TOP

Methods



TOP

Implementation Notes

ModPerl::RegistryLoader performs a very simple job, at run time it loads and sub-classes the module passed via the package attribute and overrides some of its functions, to emulate the run-time environment. This allows to preload the same script into different registry environments.



TOP

Authors

The original Apache::RegistryLoader implemented by Doug MacEachern.

Stas Bekman did the porting to the new registry framework based on ModPerl::RegistryLoader.



TOP

SEE ALSO

ModPerl::RegistryCooker, ModPerl::Registry, ModPerl::RegistryBB, ModPerl::PerlRun, Apache(3), mod_perl(3)







TOP
previous page: ModPerl::RegistryCooker - Cook mod_perl 2.0 Registry Modulespage up: mod_perl APIsnext page: ModPerl::Util - Helper mod_perl 2.0 Functions