This file is indexed.

/usr/share/doc/libapache2-mod-perl2-doc/docs/2.0/api/ModPerl/RegistryLoader.html is in libapache2-mod-perl2-doc 2.0.8+httpd24-r1449661-6ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">



<ul id="index">
  <li><a href="#NAME">NAME</a></li>
  <li><a href="#Synopsis">Synopsis</a></li>
  <li><a href="#Description">Description</a></li>
  <li><a href="#Methods">Methods</a></li>
  <li><a href="#Implementation-Notes">Implementation Notes</a></li>
  <li><a href="#Authors">Authors</a></li>
  <li><a href="#SEE-ALSO">SEE ALSO</a></li>
</ul>

<h1 id="NAME">NAME</h1>

<p>ModPerl::RegistryLoader - Compile ModPerl::RegistryCooker scripts at server startup</p>

<h1 id="Synopsis">Synopsis</h1>

<pre><code>  # in startup.pl
  use ModPerl::RegistryLoader ();
  use File::Spec ();
  
  # explicit uri =&gt; filename mapping
  my $rlbb = ModPerl::RegistryLoader-&gt;new(
      package =&gt; &#39;ModPerl::RegistryBB&#39;,
      debug   =&gt; 1, # default 0
  );

  $rlbb-&gt;handler($uri, $filename);
  
  ###
  # uri =&gt; filename mapping using a helper function
  sub trans {
      my $uri = shift;
      $uri =~ s|^/registry/|cgi-bin/|;
      return File::Spec-&gt;catfile(Apache2::ServerUtil::server_root, $uri);
  }
  my $rl = ModPerl::RegistryLoader-&gt;new(
      package =&gt; &#39;ModPerl::Registry&#39;,
      trans   =&gt; \&amp;trans,
  );
  $rl-&gt;handler($uri);
  
  ###
  $rlbb-&gt;handler($uri, $filename, $virtual_hostname);</code></pre>

<h1 id="Description">Description</h1>

<p>This modules allows compilation of scripts, running under packages derived from <code>ModPerl::RegistryCooker</code>, at server startup. The script&#39;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&#39;s compilation on the first request in every httpd instance.</p>

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

<h1 id="Methods">Methods</h1>

<dl>

<dt id="new">new()</dt>
<dd>

<p>When creating a new <code>ModPerl::RegistryLoader</code> object, one has to specify which of the <code>ModPerl::RegistryCooker</code> derived modules to use. For example if a script is going to run under <code>ModPerl::RegistryBB</code> the object is initialized as:</p>

<pre><code>  my $rlbb = ModPerl::RegistryLoader-&gt;new(
      package =&gt; &#39;ModPerl::RegistryBB&#39;,
  );</code></pre>

<p>If the package is not specified <code>ModPerl::Registry</code> is assumed:</p>

<pre><code>  my $rlbb = ModPerl::RegistryLoader-&gt;new();</code></pre>

<p>To turn the debugging on, set the <i>debug</i> attribute to a true value:</p>

<pre><code>  my $rlbb = ModPerl::RegistryLoader-&gt;new(
      package =&gt; &#39;ModPerl::RegistryBB&#39;,
      debug   =&gt; 1,
  );</code></pre>

<p>Instead of specifying explicitly a filename for each uri passed to handler(), a special attribute <i>trans</i> can be set to a subroutine to perform automatic remapping.</p>

<pre><code>  my $rlbb = ModPerl::RegistryLoader-&gt;new(
      package =&gt; &#39;ModPerl::RegistryBB&#39;,
      trans   =&gt; \&amp;trans,
  );</code></pre>

<p>See the handler() item for an example of using the <i>trans</i> attribute.</p>

</dd>
<dt id="handler">handler()</dt>
<dd>

<pre><code>  $rl-&gt;handler($uri, [$filename, [$virtual_hostname]]);</code></pre>

<p>The handler() method takes argument of <code>uri</code> and optionally of <code>filename</code> and of <code>virtual_hostname</code>.</p>

<p>URI to filename translation normally doesn&#39;t happen until HTTP request time, so we&#39;re forced to roll our own translation. If the filename is supplied it&#39;s used in translation.</p>

<p>If the filename is omitted and a <code>trans</code> subroutine was not set in new(), the loader will try using the <code>uri</code> relative to the <code>ServerRoot</code> configuration directive. For example:</p>

<pre><code>  httpd.conf:
  -----------
  ServerRoot /usr/local/apache
  Alias /registry/ /usr/local/apache/cgi-bin/

  startup.pl:
  -----------
  use ModPerl::RegistryLoader ();
  my $rl = ModPerl::RegistryLoader-&gt;new(
      package =&gt; &#39;ModPerl::Registry&#39;,
  );
  # preload /usr/local/apache/cgi-bin/test.pl
  $rl-&gt;handler(/registry/test.pl);</code></pre>

<p>To make the loader smarter about the URI-&gt;filename translation, you may provide the <code>new()</code> method with a <code>trans()</code> function to translate the uri to filename.</p>

<p>The following example will pre-load all files ending with <i>.pl</i> in the <i>cgi-bin</i> directory relative to <code>ServerRoot</code>.</p>

<pre><code>  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-&gt;catdir(Apache2::ServerUtil::server_root,
                                  &quot;cgi-bin&quot;);
  
      sub trans {
          my $uri = shift; 
          $uri =~ s|^/registry/|cgi-bin/|;
          return File::Spec-&gt;catfile(Apache2::ServerUtil::server_root,
                                     $uri);
      }
  
      my $rl = ModPerl::RegistryLoader-&gt;new(
          package =&gt; &quot;ModPerl::Registry&quot;,
          trans   =&gt; \&amp;trans,
      );
      my $dh = DirHandle-&gt;new($dir) or die $!;
  
      for my $file ($dh-&gt;read) {
          next unless $file =~ /\.pl$/;
          $rl-&gt;handler(&quot;/registry/$file&quot;);
      }
  }</code></pre>

<p>If <code>$virtual_hostname</code> argument is passed it&#39;ll be used in the creation of the package name the script will be compiled into for those registry handlers that use <i>namespace_from_uri()</i> method. See also the notes on <code>$ModPerl::RegistryCooker::NameWithVirtualHost</code> in the <code><a>ModPerl::RegistryCooker</a></code> documentation.</p>

<p>Also explained in the <code><a>ModPerl::RegistryLoader</a></code> documentation, this only has an effect at run time if <code>$ModPerl::RegistryCooker::NameWithVirtualHost</code> is set to true, otherwise the <code>$virtual_hostname</code> argument is ignored.</p>

</dd>
</dl>

<h1 id="Implementation-Notes">Implementation Notes</h1>

<p><code>ModPerl::RegistryLoader</code> performs a very simple job, at run time it loads and sub-classes the module passed via the <i>package</i> 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.</p>

<h1 id="Authors">Authors</h1>

<p>The original <code>Apache2::RegistryLoader</code> implemented by Doug MacEachern.</p>

<p>Stas Bekman did the porting to the new registry framework based on <code>ModPerl::RegistryLoader</code>.</p>

<h1 id="SEE-ALSO">SEE ALSO</h1>

<p><code><a>ModPerl::RegistryCooker</a></code>, <code><a>ModPerl::Registry</a></code>, <code><a>ModPerl::RegistryBB</a></code>, <code><a>ModPerl::PerlRun</a></code>, Apache(3), mod_perl(3)</p>


</body>

</html>