.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "libapache2-mod-perl2-2.0.11::docs::api::ModPerl::RegistryLoader 3pm" .TH libapache2-mod-perl2-2.0.11::docs::api::ModPerl::RegistryLoader 3pm "2021-02-22" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ModPerl::RegistryLoader \- Compile ModPerl::RegistryCooker scripts at server startup .SH "Synopsis" .IX Header "Synopsis" .Vb 3 \& # in startup.pl \& use ModPerl::RegistryLoader (); \& use File::Spec (); \& \& # explicit uri => filename mapping \& my $rlbb = ModPerl::RegistryLoader\->new( \& package => \*(AqModPerl::RegistryBB\*(Aq, \& 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 => \*(AqModPerl::Registry\*(Aq, \& trans => \e&trans, \& ); \& $rl\->handler($uri); \& \& ### \& $rlbb\->handler($uri, $filename, $virtual_hostname); .Ve .SH "Description" .IX Header "Description" This modules allows compilation of scripts, running under packages derived from \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR, 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. .PP This module is of course useless for those running the \&\f(CW\*(C`ModPerl::PerlRun\*(C'\fR handler, because the scripts get recompiled on each request under this handler. .SH "Methods" .IX Header "Methods" .IP "\fBnew()\fR" 4 .IX Item "new()" When creating a new \f(CW\*(C`ModPerl::RegistryLoader\*(C'\fR object, one has to specify which of the \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR derived modules to use. For example if a script is going to run under \&\f(CW\*(C`ModPerl::RegistryBB\*(C'\fR the object is initialized as: .Sp .Vb 3 \& my $rlbb = ModPerl::RegistryLoader\->new( \& package => \*(AqModPerl::RegistryBB\*(Aq, \& ); .Ve .Sp If the package is not specified \f(CW\*(C`ModPerl::Registry\*(C'\fR is assumed: .Sp .Vb 1 \& my $rlbb = ModPerl::RegistryLoader\->new(); .Ve .Sp To turn the debugging on, set the \fIdebug\fR attribute to a true value: .Sp .Vb 4 \& my $rlbb = ModPerl::RegistryLoader\->new( \& package => \*(AqModPerl::RegistryBB\*(Aq, \& debug => 1, \& ); .Ve .Sp Instead of specifying explicitly a filename for each uri passed to \&\fBhandler()\fR, a special attribute \fItrans\fR can be set to a subroutine to perform automatic remapping. .Sp .Vb 4 \& my $rlbb = ModPerl::RegistryLoader\->new( \& package => \*(AqModPerl::RegistryBB\*(Aq, \& trans => \e&trans, \& ); .Ve .Sp See the \fBhandler()\fR item for an example of using the \fItrans\fR attribute. .IP "\fBhandler()\fR" 4 .IX Item "handler()" .Vb 1 \& $rl\->handler($uri, [$filename, [$virtual_hostname]]); .Ve .Sp The \fBhandler()\fR method takes argument of \f(CW\*(C`uri\*(C'\fR and optionally of \&\f(CW\*(C`filename\*(C'\fR and of \f(CW\*(C`virtual_hostname\*(C'\fR. .Sp \&\s-1URI\s0 to filename translation normally doesn't happen until \s-1HTTP\s0 request time, so we're forced to roll our own translation. If the filename is supplied it's used in translation. .Sp If the filename is omitted and a \f(CW\*(C`trans\*(C'\fR subroutine was not set in \&\fBnew()\fR, the loader will try using the \f(CW\*(C`uri\*(C'\fR relative to the \&\f(CW\*(C`ServerRoot\*(C'\fR configuration directive. For example: .Sp .Vb 4 \& httpd.conf: \& \-\-\-\-\-\-\-\-\-\-\- \& ServerRoot /usr/local/apache \& Alias /registry/ /usr/local/apache/cgi\-bin/ \& \& startup.pl: \& \-\-\-\-\-\-\-\-\-\-\- \& use ModPerl::RegistryLoader (); \& my $rl = ModPerl::RegistryLoader\->new( \& package => \*(AqModPerl::Registry\*(Aq, \& ); \& # preload /usr/local/apache/cgi\-bin/test.pl \& $rl\->handler(/registry/test.pl); .Ve .Sp To make the loader smarter about the \s-1URI\-\s0>filename translation, you may provide the \f(CW\*(C`new()\*(C'\fR method with a \f(CW\*(C`trans()\*(C'\fR function to translate the uri to filename. .Sp The following example will pre-load all files ending with \fI.pl\fR in the \fIcgi-bin\fR directory relative to \f(CW\*(C`ServerRoot\*(C'\fR. .Sp .Vb 4 \& httpd.conf: \& \-\-\-\-\-\-\-\-\-\-\- \& ServerRoot /usr/local/apache \& Alias /registry/ /usr/local/apache/cgi\-bin/ \& \& startup.pl: \& \-\-\-\-\-\-\-\-\-\-\- \& { \& # test the scripts pre\-loading by using trans sub \& use ModPerl::RegistryLoader (); \& use File::Spec (); \& use DirHandle (); \& use strict; \& \& my $dir = File::Spec\->catdir(Apache2::ServerUtil::server_root, \& "cgi\-bin"); \& \& 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 => \e&trans, \& ); \& my $dh = DirHandle\->new($dir) or die $!; \& \& for my $file ($dh\->read) { \& next unless $file =~ /\e.pl$/; \& $rl\->handler("/registry/$file"); \& } \& } .Ve .Sp If \f(CW$virtual_hostname\fR argument is passed it'll be used in the creation of the package name the script will be compiled into for those registry handlers that use \fI\f(BInamespace_from_uri()\fI\fR method. See also the notes on \f(CW$ModPerl::RegistryCooker::NameWithVirtualHost\fR in the \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR documentation. .Sp Also explained in the \f(CW\*(C`ModPerl::RegistryLoader\*(C'\fR documentation, this only has an effect at run time if \&\f(CW$ModPerl::RegistryCooker::NameWithVirtualHost\fR is set to true, otherwise the \f(CW$virtual_hostname\fR argument is ignored. .SH "Implementation Notes" .IX Header "Implementation Notes" \&\f(CW\*(C`ModPerl::RegistryLoader\*(C'\fR performs a very simple job, at run time it loads and sub-classes the module passed via the \fIpackage\fR attribute and overrides some of its functions, to emulate the run-time environment. This allows one to preload the same script into different registry environments. .SH "Authors" .IX Header "Authors" The original \f(CW\*(C`Apache2::RegistryLoader\*(C'\fR implemented by Doug MacEachern. .PP Stas Bekman did the porting to the new registry framework based on \&\f(CW\*(C`ModPerl::RegistryLoader\*(C'\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR, \f(CW\*(C`ModPerl::Registry\*(C'\fR, \&\f(CW\*(C`ModPerl::RegistryBB\*(C'\fR, \f(CW\*(C`ModPerl::PerlRun\*(C'\fR, \fBApache\fR\|(3), \&\fBmod_perl\fR\|(3)