IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 8, 2006, 12:23:25 PM (20 years ago)
Author:
jhoblitt
Message:

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

Location:
trunk/Nebulous-Server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Changes

    r10576 r10579  
    99    - make Nebulous::Server->db() Apache::DBI aware
    1010    - make SQL syntax MySQL 5 compatible
     11    - change Nebulous::Server::SOAP to be mod_perl aware
     12    - change Nebulous::Server::SOAP install stub methods to bypass AUTOLOAD on
     13      successive calls to the same method
    1114
    12150.02 Fri Dec  2 17:36:59 HST 2005
  • trunk/Nebulous-Server/lib/Nebulous/Server/SOAP.pm

    r4440 r10579  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: SOAP.pm,v 1.2 2005-06-30 02:35:06 jhoblitt Exp $
     3# $Id: SOAP.pm,v 1.3 2006-12-08 22:23:25 jhoblitt Exp $
    44
    55package Nebulous::Server::SOAP;
     
    88use warnings FATAL => qw( all );
    99
    10 our $VERSION = '0.01';
     10our $VERSION = '0.02';
    1111
     12import SOAP::Data 'name';
     13use Apache2::Const -compile => qw(OK);
    1214use Nebulous::Server;
    1315use SOAP::Lite;
    14 import SOAP::Data 'name';
    1516
    1617our $AUTOLOAD;
     18
     19our @args;
     20our $neb;
     21
     22sub new_on_init {
     23    my $self = shift;
     24
     25    require mod_perl2;
     26    require Apache2::Module;
     27    require Apache2::ServerUtil;
     28
     29    @args = @_;
     30
     31    my $s = Apache2::ServerUtil->server;
     32    $s->push_handlers(PerlChildInitHandler => \&init);
     33
     34    return $self;
     35}
     36
     37sub init {
     38    my $self = shift;
     39
     40    $neb = Nebulous::Server->new(@args);       
     41
     42    return Apache2::Const::OK;
     43}
    1744
    1845sub AUTOLOAD {
     
    2249    return undef if $method eq 'DESTROY';
    2350
    24     return name( result => Nebulous::Server->$method( @_ ) );
     51    die "process $$ has not been initialized"
     52        unless defined $neb;
     53
     54    die "method $method does not exist in Nebulous::Server"
     55        unless defined ${Nebulous::Server::}{$method};
     56
     57    # create a sub and install it in the package so successive calls to the
     58    # same method don't have to go through AUTOLOAD
     59    my $method_sub;
     60    eval q|
     61    $method_sub = sub {
     62        my $self = shift;
     63        return name( result => $neb->| . $method . q|( @_ ) );
     64    }
     65    |;
     66    die $@ if $@;
     67
     68    no strict 'refs';
     69    *{"${package}::${method}"} = $method_sub;
     70    use strict;
     71
     72    # invoke the method we just created
     73    return $self->$method(@_);
    2574}
    2675
Note: See TracChangeset for help on using the changeset viewer.