<div dir="ltr">I don&#39;t think this is a good change... RosterStorage is not a singleton.&nbsp; You can run multiple vhosts within a process, all with different RosterStorage mechanisms.<br><br><br><div class="gmail_quote">On Tue, Aug 5, 2008 at 7:30 AM,  <span dir="ltr">&lt;<a href="mailto:commits@code.sixapart.com">commits@code.sixapart.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&nbsp;r6532@coke: &nbsp;josboum | 2008-08-05 16:30:19 +0200<br>
&nbsp;* for several plugins it&#39;s not possible to access their object after the -&gt;register()<br>
 &nbsp; phase is over; the object is then only referenced in closures.<br>
 &nbsp; This patch adds a method, -&gt;singleton, to retrieve the object for later use. This is<br>
 &nbsp; particularly useful for setting up applications a la DJabberd::Plugin::MyApp<br>
<br>
<br>
_U &nbsp;trunk/<br>
U &nbsp; trunk/DJabberd/lib/DJabberd/Bot.pm<br>
U &nbsp; trunk/DJabberd/lib/DJabberd/RosterStorage.pm<br>
<br>
<br>
<br>
Property changes on: trunk<br>
___________________________________________________________________<br>
Name: svk:merge<br>
 &nbsp; - 02e31fea-a713-0410-9bb5-81a53d0f95f7:/djabberd-trunk:4879<br>
1b5ff1af-660f-0410-86e2-35bade70ffec:/trunk/djabberd:61<br>
391f84f8-cfa2-4f6b-a47d-f52c5dc88d86:/local/sixapart/djabberd-trunk:6518<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/groupchat:328<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/local:667<br>
 &nbsp; + 02e31fea-a713-0410-9bb5-81a53d0f95f7:/djabberd-trunk:4879<br>
1b5ff1af-660f-0410-86e2-35bade70ffec:/trunk/djabberd:61<br>
391f84f8-cfa2-4f6b-a47d-f52c5dc88d86:/local/sixapart/djabberd-trunk:6532<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/groupchat:328<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/local:667<br>
<br>
Modified: trunk/DJabberd/lib/DJabberd/Bot.pm<br>
===================================================================<br>
--- trunk/DJabberd/lib/DJabberd/Bot.pm &nbsp;2008-08-05 11:17:05 UTC (rev 794)<br>
+++ trunk/DJabberd/lib/DJabberd/Bot.pm &nbsp;2008-08-05 14:30:33 UTC (rev 795)<br>
@@ -10,6 +10,16 @@<br>
<br>
&nbsp;our $logger = DJabberd::Log-&gt;get_logger();<br>
<br>
+### store the object in a closure, so we can retrieve it later<br>
+{ &nbsp; my $singleton;<br>
+ &nbsp; &nbsp;sub singleton { $singleton };<br>
+<br>
+ &nbsp; &nbsp;sub new {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;my $self = shift;<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;$singleton = $self-&gt;SUPER::new( @_ );<br>
+ &nbsp; &nbsp;}<br>
+}<br>
+<br>
&nbsp;sub set_config_nodename {<br>
 &nbsp; &nbsp; my ($self, $nodename) = @_;<br>
 &nbsp; &nbsp; $self-&gt;{nodename} = $nodename;<br>
<br>
Modified: trunk/DJabberd/lib/DJabberd/RosterStorage.pm<br>
===================================================================<br>
--- trunk/DJabberd/lib/DJabberd/RosterStorage.pm &nbsp; &nbsp; &nbsp; &nbsp;2008-08-05 11:17:05 UTC (rev 794)<br>
+++ trunk/DJabberd/lib/DJabberd/RosterStorage.pm &nbsp; &nbsp; &nbsp; &nbsp;2008-08-05 14:30:33 UTC (rev 795)<br>
@@ -6,6 +6,18 @@<br>
&nbsp;use DJabberd::Roster;<br>
&nbsp;use DJabberd::RosterItem;<br>
<br>
+### store the object in a closure, so we can retrieve it later<br>
+### this allows us to manipulate the roster storage from other<br>
+### places, to for example pre-link users.<br>
+{ &nbsp; my $singleton;<br>
+ &nbsp; &nbsp;sub singleton { $singleton };<br>
+<br>
+ &nbsp; &nbsp;sub new {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;my $self = shift;<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;$singleton = $self-&gt;SUPER::new( @_ );<br>
+ &nbsp; &nbsp;}<br>
+}<br>
+<br>
&nbsp;# don&#39;t override, or at least call SUPER to this if you do.<br>
&nbsp;sub register {<br>
 &nbsp; &nbsp; my ($self, $vhost) = @_;<br>
<br>
<br>
</blockquote></div><br></div>