-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 {
#
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 );
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;
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");
}
}
-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 {
#
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;
}
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;
}
$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 {
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;
}