Index: trunk/Nebulous-Server/Changes
===================================================================
--- trunk/Nebulous-Server/Changes	(revision 10576)
+++ trunk/Nebulous-Server/Changes	(revision 10579)
@@ -9,4 +9,7 @@
     - make Nebulous::Server->db() Apache::DBI aware
     - make SQL syntax MySQL 5 compatible
+    - change Nebulous::Server::SOAP to be mod_perl aware
+    - change Nebulous::Server::SOAP install stub methods to bypass AUTOLOAD on
+      successive calls to the same method
 
 0.02 Fri Dec  2 17:36:59 HST 2005
Index: trunk/Nebulous-Server/lib/Nebulous/Server/SOAP.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server/SOAP.pm	(revision 10576)
+++ trunk/Nebulous-Server/lib/Nebulous/Server/SOAP.pm	(revision 10579)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: SOAP.pm,v 1.2 2005-06-30 02:35:06 jhoblitt Exp $
+# $Id: SOAP.pm,v 1.3 2006-12-08 22:23:25 jhoblitt Exp $
 
 package Nebulous::Server::SOAP;
@@ -8,11 +8,38 @@
 use warnings FATAL => qw( all );
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
+import SOAP::Data 'name'; 
+use Apache2::Const -compile => qw(OK);
 use Nebulous::Server;
 use SOAP::Lite;
-import SOAP::Data 'name'; 
 
 our $AUTOLOAD;
+
+our @args;
+our $neb;
+
+sub new_on_init {
+    my $self = shift;
+
+    require mod_perl2;
+    require Apache2::Module;
+    require Apache2::ServerUtil;
+
+    @args = @_;
+
+    my $s = Apache2::ServerUtil->server;
+    $s->push_handlers(PerlChildInitHandler => \&init);
+
+    return $self;
+}
+
+sub init {
+    my $self = shift;
+
+    $neb = Nebulous::Server->new(@args);        
+
+    return Apache2::Const::OK;
+}
 
 sub AUTOLOAD {
@@ -22,5 +49,27 @@
     return undef if $method eq 'DESTROY';
 
-    return name( result => Nebulous::Server->$method( @_ ) );
+    die "process $$ has not been initialized"
+        unless defined $neb;
+
+    die "method $method does not exist in Nebulous::Server"
+        unless defined ${Nebulous::Server::}{$method};
+
+    # create a sub and install it in the package so successive calls to the
+    # same method don't have to go through AUTOLOAD
+    my $method_sub;
+    eval q|
+    $method_sub = sub {
+        my $self = shift;
+        return name( result => $neb->| . $method . q|( @_ ) );
+    }
+    |;
+    die $@ if $@;
+
+    no strict 'refs';
+    *{"${package}::${method}"} = $method_sub;
+    use strict;
+
+    # invoke the method we just created
+    return $self->$method(@_);
 }
 
