⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modperl::registryloader.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...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" '''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 turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD.  Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\.    de IX.    tm Index:\\$1\t\\n%\t"\\$2"...    nr % 0.    rr F.\}.el \{\.    de IX...\}.\".\" 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 "mod_perl-2.0.2::docs::api::ModPerl::RegistryLoader 3".TH mod_perl-2.0.2::docs::api::ModPerl::RegistryLoader 3 "2005-10-21" "perl v5.10.0" "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 packagesderived from \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR, at server startup.  Thescript's handler routine is compiled by the parent server, of whichchildren get a copy and thus saves some memory by initially sharingthe compiled copy with the parent and saving the overhead of script'scompilation on the first request in every httpd instance..PPThis module is of course useless for those running the\&\f(CW\*(C`ModPerl::PerlRun\*(C'\fR handler, because the scripts get recompiled oneach request under this handler..SH "Methods".IX Header "Methods".IP "\fInew()\fR" 4.IX Item "new()"When creating a new \f(CW\*(C`ModPerl::RegistryLoader\*(C'\fR object, one has tospecify which of the \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR derived modules touse. 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.SpIf the package is not specified \f(CW\*(C`ModPerl::Registry\*(C'\fR is assumed:.Sp.Vb 1\&  my $rlbb = ModPerl::RegistryLoader\->new();.Ve.SpTo 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.SpInstead of specifying explicitly a filename for each uri passed to\&\fIhandler()\fR, a special attribute \fItrans\fR can be set to a subroutine toperform automatic remapping..Sp.Vb 4\&  my $rlbb = ModPerl::RegistryLoader\->new(\&      package => \*(AqModPerl::RegistryBB\*(Aq,\&      trans   => \e&trans,\&  );.Ve.SpSee the \fIhandler()\fR item for an example of using the \fItrans\fR attribute..IP "\fIhandler()\fR" 4.IX Item "handler()".Vb 1\&  $rl\->handler($uri, [$filename, [$virtual_hostname]]);.Ve.SpThe \fIhandler()\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 requesttime, so we're forced to roll our own translation. If the filename issupplied it's used in translation..SpIf the filename is omitted and a \f(CW\*(C`trans\*(C'\fR subroutine was not set in\&\fInew()\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.SpTo 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 totranslate the uri to filename..SpThe following example will pre-load all files ending with \fI.pl\fR inthe \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.SpIf \f(CW$virtual_hostname\fR argument is passed it'll be used in thecreation of the package name the script will be compiled into forthose registry handlers that use \fI\fInamespace_from_uri()\fI\fR method.  Seealso the notes on \f(CW$ModPerl::RegistryCooker::NameWithVirtualHost\fR inthe \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR documentation..SpAlsoexplained in the \f(CW\*(C`ModPerl::RegistryLoader\*(C'\fR documentation, thisonly 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 itloads and sub-classes the module passed via the \fIpackage\fR attributeand overrides some of its functions, to emulate the run-timeenvironment. This allows to preload the same script into differentregistry environments..SH "Authors".IX Header "Authors"The original \f(CW\*(C`Apache2::RegistryLoader\*(C'\fR implemented by Doug MacEachern..PPStas 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, \fIApache\fR\|(3),\&\fImod_perl\fR\|(3)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -