mod_perl logo perl icon
previous page: ModPerl::RegistryCooker - Cook mod_perl 2.0 Registry Modulespage up: mod_perl 2.0 APInext page: ModPerl::RegistryPrefork - Run unaltered CGI scripts under mod_perl

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






mod_perl2 User's Guide

mod_perl2 User's Guide

By Stas Bekman, Jim Brandt
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
Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

By Lincoln Stein, Doug MacEachern
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolsky, Ken Williams


Table of Contents

Synopsis

  # in startup.pl
  use ModPerl::RegistryLoader ();
  use File::Spec ();
  
  # 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 File::Spec->catfile(Apache2::ServerUtil::server_root, $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 Apache2::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 2.0 APInext page: ModPerl::RegistryPrefork - Run unaltered CGI scripts under mod_perl