From 516ebeeb2ff4d70336f0f2cfb563a9c978553a4a Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 7 Feb 2005 15:20:37 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@17 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/Application/Demo/Math.pm | 27 ++++++------ src/perlmods/OpenSRF/Application/Demo/MathDB.pm | 57 ++++++++++++++++--------- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/perlmods/OpenSRF/Application/Demo/Math.pm b/src/perlmods/OpenSRF/Application/Demo/Math.pm index be5b46a..952a9ef 100644 --- a/src/perlmods/OpenSRF/Application/Demo/Math.pm +++ b/src/perlmods/OpenSRF/Application/Demo/Math.pm @@ -1,15 +1,15 @@ -package OpenSRF::Application::Demo::Math; -use base qw/OpenSRF::Application/; -use OpenSRF::Application; -use OpenSRF::Utils::Logger qw/:level/; -use OpenSRF::DomainObject::oilsResponse; -use OpenSRF::EX qw/:try/; +package OpenILS::App::Math; +use base qw/OpenILS::Application/; +use OpenILS::Application; +use OpenILS::Utils::Logger qw/:level/; +use OpenILS::DomainObject::oilsResponse; +use OpenILS::EX qw/:try/; use strict; use warnings; sub DESTROY{} -our $log = 'OpenSRF::Utils::Logger'; +our $log = 'OpenILS::Utils::Logger'; #sub method_lookup { # @@ -41,12 +41,12 @@ sub send_request { my @params = @_; $log->debug( "Creating a client environment", DEBUG ); - my $session = OpenSRF::AppSession->create( + my $session = OpenILS::AppSession->create( "dbmath", sysname => 'math', secret => '12345' ); $log->debug( "Sending request to math server", INTERNAL ); - my $method = OpenSRF::DomainObject::oilsMethod->new( method => $method_name ); + my $method = OpenILS::DomainObject::oilsMethod->new( method => $method_name ); $method->params( @params ); @@ -61,19 +61,20 @@ sub send_request { my $vv = $session->connect(); if($vv) { last; } if( $nn and !$vv ) { - throw OpenSRF::EX::CRITICAL ("DBMath connect attempt timed out"); + throw OpenILS::EX::CRITICAL ("DBMath connect attempt timed out"); } } $req = $session->request( $method ); $resp = $req->recv(10); - } catch OpenSRF::DomainObject::oilsAuthException with { + } catch OpenILS::DomainObject::oilsAuthException with { my $e = shift; $e->throw(); }; - if ( defined($resp) and $resp and $resp->class->isa('OpenSRF::DomainObject::oilsResult') ){ + $log->error("response is $resp"); + if ( defined($resp) and $resp and $resp->class->isa('OpenILS::DomainObject::oilsResult') ){ $log->debug( "Math server returned " . $resp->toString(1), INTERNAL ); $req->finish; @@ -86,7 +87,7 @@ sub send_request { else{ $log->debug( "Math received empty value", ERROR ); } $req->finish; $session->finish; - throw OpenSRF::EX::ERROR ("Did not receive expected data from MathDB"); + throw OpenILS::EX::ERROR ("Did not receive expected data from MathDB"); } } diff --git a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm index 0b40256..24c9ff1 100644 --- a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm +++ b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm @@ -1,13 +1,15 @@ -package OpenSRF::Application::Demo::MathDB; -use base qw/OpenSRF::Application/; -use OpenSRF::Application; -use OpenSRF::DomainObject::oilsResponse qw/:status/; -use OpenSRF::DomainObject::oilsPrimitive; -use OpenSRF::Utils::Logger qw/:level/; +package OpenILS::App::MathDB; +use JSON; +use base qw/OpenILS::Application/; +use OpenILS::Application; +use OpenILS::DomainObject::oilsResponse qw/:status/; +use OpenILS::DomainObject::oilsPrimitive; +use OpenILS::Utils::Logger qw/:level/; use strict; use warnings; sub DESTROY{} -our $log = 'OpenSRF::Utils::Logger'; +our $log = 'OpenILS::Utils::Logger'; +sub initialize {} #sub method_lookup { # @@ -41,9 +43,13 @@ sub add_1 { my $n1 = shift; my $n2 = shift; $n1 =~ s/\s+//; $n2 =~ s/\s+//; my $a = $n1 + $n2; - my $result = new OpenSRF::DomainObject::oilsResult; - $result->content( OpenSRF::DomainObject::oilsScalar->new($a) ); - return $result; + return JSON::number::new($a); + + + + my $result = new OpenILS::DomainObject::oilsResult; + $result->content( OpenILS::DomainObject::oilsScalar->new($a) ); + return $a; $client->respond($result); return 1; } @@ -55,9 +61,13 @@ sub sub_1 { my $n1 = shift; my $n2 = shift; $n1 =~ s/\s+//; $n2 =~ s/\s+//; my $a = $n1 - $n2; - my $result = new OpenSRF::DomainObject::oilsResult; - $result->content( OpenSRF::DomainObject::oilsScalar->new($a) ); - return $result; + return JSON::number::new($a); + + + + my $result = new OpenILS::DomainObject::oilsResult; + $result->content( OpenILS::DomainObject::oilsScalar->new($a) ); + return $a; $client->respond($result); return 1; } @@ -69,11 +79,15 @@ sub mult_1 { $log->debug("AppRequest is $client", INTERNAL); my $n1 = shift; my $n2 = shift; $n1 =~ s/\s+//; $n2 =~ s/\s+//; - my $a = $n1 * $n2; - my $result = new OpenSRF::DomainObject::oilsResult; - $result->content( OpenSRF::DomainObject::oilsScalar->new($a) ); + my $a = JSON::number::new($n1 * $n2); + return $a; + + + + my $result = new OpenILS::DomainObject::oilsResult; + $result->content( OpenILS::DomainObject::oilsScalar->new($a) ); # $client->respond($result); - return $result; + return $a; } sub div_1 { @@ -84,10 +98,13 @@ sub div_1 { my $n1 = shift; my $n2 = shift; $n1 =~ s/\s+//; $n2 =~ s/\s+//; my $a = $n1 / $n2; - my $result = new OpenSRF::DomainObject::oilsResult; - $result->content( OpenSRF::DomainObject::oilsScalar->new($a) ); + return JSON::number::new($a); + + + my $result = new OpenILS::DomainObject::oilsResult; + $result->content( JSON::number::new($a) ); return $result; - $client->respond($result); + $client->respond($a); return 1; } -- 2.11.0