From ae4305641e4caf77f753631dd59be1aeccec393f Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 7 Feb 2005 21:19:33 +0000 Subject: [PATCH] updating method lookup and registration in the demo git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@26 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/Application.pm | 3 -- src/perlmods/OpenSRF/Application/Demo/Math.pm | 40 ++++++------------------- src/perlmods/OpenSRF/Application/Demo/MathDB.pm | 11 ++++++- 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/perlmods/OpenSRF/Application.pm b/src/perlmods/OpenSRF/Application.pm index 1dfeeaa..dbc3f5c 100644 --- a/src/perlmods/OpenSRF/Application.pm +++ b/src/perlmods/OpenSRF/Application.pm @@ -196,9 +196,6 @@ sub method_lookup { my $method = shift; my $proto = shift; - my $super_lookup = $self->SUPER::method_lookup($method,$proto); - return $super_lookup if (ref $super_lookup); - my $class = ref($self) || $self; $log->debug("Specialized lookup of [$method] in [$class]", INTERNAL); diff --git a/src/perlmods/OpenSRF/Application/Demo/Math.pm b/src/perlmods/OpenSRF/Application/Demo/Math.pm index fe1717c..a9208af 100644 --- a/src/perlmods/OpenSRF/Application/Demo/Math.pm +++ b/src/perlmods/OpenSRF/Application/Demo/Math.pm @@ -3,7 +3,7 @@ use base qw/OpenSRF::Application/; use OpenSRF::Application; use OpenSRF::Utils::Logger qw/:level/; use OpenSRF::DomainObject::oilsResponse; -use OpenSRF::DomainObject::oilsPrimitive; +#use OpenSRF::DomainObject::oilsPrimitive; use OpenSRF::EX qw/:try/; use strict; use warnings; @@ -12,30 +12,6 @@ sub DESTROY{} our $log = 'OpenSRF::Utils::Logger'; -#sub method_lookup { -# -# my( $class, $method_name, $method_proto ) = @_; -# -# if( $method_name eq "add" ) { -# return \&add; -# } - -# if( $method_name eq "sub" ) { -# return \⊂ -# } -# -# if( $method_name eq "mult" ) { -# return \&mult; -# } -# -# if( $method_name eq "div" ) { -# return \÷ -# } - -# return undef; -# -#} - sub send_request { my $method_name = shift; @@ -92,31 +68,33 @@ sub send_request { } } - -sub add_1_action { 1 }; +__PACKAGE__->register_method( method => 'add_1', api_name => 'add' ); sub add_1 { - + my $self = shift; my $client = shift; my @args = @_; return send_request( "add", @args ); } -sub sub_1_action { 1 }; +__PACKAGE__->register_method( method => 'sub_1', api_name => 'sub' ); sub sub_1 { + my $self = shift; my $client = shift; my @args = @_; return send_request( "sub", @args ); } -sub mult_1_action { 1 }; +__PACKAGE__->register_method( method => 'mult_1', api_name => 'mult' ); sub mult_1 { + my $self = shift; my $client = shift; my @args = @_; return send_request( "mult", @args ); } -sub div_1_action { 1 }; +__PACKAGE__->register_method( method => 'div_1', api_name => 'div' ); sub div_1 { + my $self = shift; my $client = shift; my @args = @_; return send_request( "div", @args ); diff --git a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm index d4f7c36..24c13b6 100644 --- a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm +++ b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm @@ -3,15 +3,18 @@ use JSON; use base qw/OpenSRF::Application/; use OpenSRF::Application; use OpenSRF::DomainObject::oilsResponse qw/:status/; -use OpenSRF::DomainObject::oilsPrimitive; +#use OpenSRF::DomainObject::oilsPrimitive; use OpenSRF::Utils::Logger qw/:level/; use strict; use warnings; + sub DESTROY{} our $log = 'OpenSRF::Utils::Logger'; sub initialize {} +__PACKAGE__->register_method( method => 'add_1', api_name => 'add' ); sub add_1 { + my $self = shift; my $client = shift; my @args = @_; $log->debug("Adding @args", INTERNAL); @@ -23,7 +26,9 @@ sub add_1 { } +__PACKAGE__->register_method( method => 'sub_1', api_name => 'sub' ); sub sub_1 { + my $self = shift; my $client = shift; my @args = @_; $log->debug("Subbing @args", INTERNAL); @@ -34,7 +39,9 @@ sub sub_1 { return JSON::number::new($a); } +__PACKAGE__->register_method( method => 'mult_1', api_name => 'mult' ); sub mult_1 { + my $self = shift; my $client = shift; my @args = @_; $log->debug("Multiplying @args", INTERNAL); @@ -45,7 +52,9 @@ sub mult_1 { return JSON::number::new($a); } +__PACKAGE__->register_method( method => 'div_1', api_name => 'div' ); sub div_1 { + my $self = shift; my $client = shift; my @args = @_; $log->debug("Dividing @args", INTERNAL); -- 2.11.0