[Opensrf-commits] r989 - in trunk: examples src/perlmods src/perlmods/OpenSRF src/perlmods/OpenSRF/Application src/perlmods/OpenSRF/Application/Demo src/perlmods/OpenSRF/DomainObject src/perlmods/OpenSRF/Utils

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jul 2 11:14:42 EDT 2007


Author: miker
Date: 2007-07-02 11:11:15 -0400 (Mon, 02 Jul 2007)
New Revision: 989

Modified:
   trunk/examples/fieldmapper2perl.xsl
   trunk/examples/multisession-test.pl
   trunk/src/perlmods/JSON.pm
   trunk/src/perlmods/OpenSRF/AppSession.pm
   trunk/src/perlmods/OpenSRF/Application.pm
   trunk/src/perlmods/OpenSRF/Application/Demo/MathDB.pm
   trunk/src/perlmods/OpenSRF/Application/Persist.pm
   trunk/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm
   trunk/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm
   trunk/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm
   trunk/src/perlmods/OpenSRF/System.pm
   trunk/src/perlmods/OpenSRF/Transport.pm
   trunk/src/perlmods/OpenSRF/UnixServer.pm
   trunk/src/perlmods/OpenSRF/Utils/Cache.pm
Log:
Patch from Dan Scott to move JSON to OpenSRF::Utils::JSON:

I noticed back when I was first installing OpenSRF that it includes a
module, JSON.pm, that exists at the root level of the package
directories. This would be fine, except it conflicts with a CPAN
module that is also named JSON, which confuses the CPAN installer when
you check for upgrades and conceivably could lead to a broken system.

I suggested to Mike that it would probably make sense to move the
OpenSRF version of the module into the OpenSRF/Utils/ package
namespace, and he agreed. Of course, there are ramifications
throughout the code, so I've tried to be extra-careful in catching and
correcting all of the places where the use of this module surfaces in
both OpenSRF and Evergreen.



Modified: trunk/examples/fieldmapper2perl.xsl
===================================================================
--- trunk/examples/fieldmapper2perl.xsl	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/examples/fieldmapper2perl.xsl	2007-07-02 15:11:15 UTC (rev 989)
@@ -13,7 +13,7 @@
 
 	<xsl:template match="/">
 package Fieldmapper;
-use JSON;
+use OpenSRF::Utils::JSON;
 use Data::Dumper;
 use base 'OpenSRF::Application';
 

Modified: trunk/examples/multisession-test.pl
===================================================================
--- trunk/examples/multisession-test.pl	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/examples/multisession-test.pl	2007-07-02 15:11:15 UTC (rev 989)
@@ -4,7 +4,7 @@
 use OpenILS::Application::AppUtils;
 use OpenILS::Event;
 use OpenSRF::EX qw/:try/;
-use JSON;
+use OpenSRF::Utils::JSON;
 use Data::Dumper;
 use OpenILS::Utils::Fieldmapper;
 use Digest::MD5 qw/md5_hex/;
@@ -12,7 +12,6 @@
 use OpenSRF::MultiSession;
 use OpenSRF::AppSession;
 use Time::HiRes qw/time/;
-use JSON;
 
 my $config = shift;
 
@@ -37,7 +36,7 @@
 	sub {
 		my $ses = shift;
 		my $req = shift;
-		print $req->{params}->[0] . "\t: " . JSON->perl2JSON($req->{response}->[0]->content)."\n";
+		print $req->{params}->[0] . "\t: " . OpenSRF::Utils::JSON->perl2JSON($req->{response}->[0]->content)."\n";
 	}
 );
 
@@ -45,7 +44,7 @@
 	sub {
 		my $ses = shift;
 		my $req = shift;
-		warn "record $req->{params}->[0] failed: ".JSON->perl2JSON($req->{response});
+		warn "record $req->{params}->[0] failed: " . OpenSRF::Utils::JSON->perl2JSON($req->{response});
 	}
 );
 

Modified: trunk/src/perlmods/JSON.pm
===================================================================
--- trunk/src/perlmods/JSON.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/JSON.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -1,5 +1,5 @@
 
-package JSON::number;
+package OpenSRF::Utils::JSON::number;
 sub new {
 	my $class = shift;
 	my $x = shift || $class;
@@ -10,7 +10,7 @@
 
 sub toString { defined($_[1]) ? ${$_[1]} : ${$_[0]} }
 
-package JSON::bool::true;
+package OpenSRF::Utils::JSON::bool::true;
 sub new { return bless {} => __PACKAGE__ }
 use overload ( '""' => \&toString );
 use overload ( 'bool' => sub { 1 } );
@@ -18,7 +18,7 @@
 
 sub toString { 'true' }
 
-package JSON::bool::false;
+package OpenSRF::Utils::JSON::bool::false;
 sub new { return bless {} => __PACKAGE__ }
 use overload ( '""' => \&toString );
 use overload ( 'bool' => sub { 0 } );
@@ -26,7 +26,7 @@
 
 sub toString { 'false' }
 
-package JSON;
+package OpenSRF::Utils::JSON;
 use Unicode::Normalize;
 use vars qw/%_class_map/;
 
@@ -80,7 +80,7 @@
 	$type = 'hash' if ($type eq '}');
 	$type = 'array' if ($type eq ']');
 
-	JSON->register_class_hint(name => $hint, hint => $hint, type => $type);
+	OpenSRF::Utils::JSON->register_class_hint(name => $hint, hint => $hint, type => $type);
 
 	return $hint;
 }
@@ -112,12 +112,12 @@
 	s/:/ => /sog;
 
 	# Do numbers...
-	#s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog;
+	#s/\b(-?\d+\.?\d*)\b/ OpenSRF::Utils::JSON::number::new($1) /sog;
 
 	# Change javascript stuff to perl...
 	s/null/ undef /sog;
-	s/true/ bless( {}, "JSON::bool::true") /sog;
-	s/false/ bless( {}, "JSON::bool::false") /sog;
+	s/true/ bless( {}, "OpenSRF::Utils::JSON::bool::true") /sog;
+	s/false/ bless( {}, "OpenSRF::Utils::JSON::bool::false") /sog;
 
 	my $ret;
 	return eval '$ret = '.$_;
@@ -638,7 +638,7 @@
 		} elsif ($element =~ /^\/\*/) {
 			next;
 		} elsif ($element =~ /^\d/) {
-			$output .= "do { JSON::number::new($element) }";
+			$output .= "do { OpenSRF::Utils::JSON::number::new($element) }";
 			next;
 		} elsif ($element eq '{' or $element eq '[') {
 			$casting_depth++;
@@ -654,10 +654,10 @@
 			$output .= ' => ';
 			next;
 		} elsif ($element eq 'true') {
-			$output .= 'bless( {}, "JSON::bool::true")';
+			$output .= 'bless( {}, "OpenSRF::Utils::JSON::bool::true")';
 			next;
 		} elsif ($element eq 'false') {
-			$output .= 'bless( {}, "JSON::bool::false")';
+			$output .= 'bless( {}, "OpenSRF::Utils::JSON::bool::false")';
 			next;
 		}
 		
@@ -674,7 +674,7 @@
 	if (!defined($perl)) {
 		$output = '' if $strict;
 		$output = 'null' unless $strict;
-	} elsif (ref($perl) and ref($perl) =~ /^JSON/) {
+	} elsif (ref($perl) and ref($perl) =~ /^OpenSRF::Utils::JSON/) {
 		$output .= $perl;
 	} elsif ( ref($perl) && exists($_class_map{classes}{ref($perl)}) ) {
 		$output .= '/*--S '.$_class_map{classes}{ref($perl)}{hint}.'--*/';
@@ -720,7 +720,7 @@
 	} elsif (ref($perl) and ("$perl" =~ /^([^=]+)=(\w+)/o)) {
 		my $type = $2;
 		my $name = $1;
-		JSON->register_class_hint(name => $name, hint => $name, type => lc($type));
+		OpenSRF::Utils::JSON->register_class_hint(name => $name, hint => $name, type => lc($type));
 		$output .= perl2JSON(undef,$perl, $strict);
 	} else {
 		$perl = NFC($perl);
@@ -750,7 +750,7 @@
 	if (!defined($perl)) {
 		$output = "   "x$depth unless($nospace);
 		$output .= 'null';
-	} elsif (ref($perl) and ref($perl) =~ /^JSON/) {
+	} elsif (ref($perl) and ref($perl) =~ /^OpenSRF::Utils::JSON/) {
 		$output = "   "x$depth unless($nospace);
 		$output .= $perl;
 	} elsif ( ref($perl) && exists($_class_map{classes}{ref($perl)}) ) {

Modified: trunk/src/perlmods/OpenSRF/AppSession.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/AppSession.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/AppSession.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -5,6 +5,7 @@
 use OpenSRF::DomainObject::oilsMethod;
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use OpenSRF::Transport::PeerHandle;
+use OpenSRF::Utils::JSON;
 use OpenSRF::Utils::Logger qw(:level);
 use OpenSRF::Utils::SettingsClient;
 use OpenSRF::Utils::Config;
@@ -531,7 +532,7 @@
 		}
 
 	} 
-	my $json = JSON->perl2JSON(\@doc);
+	my $json = OpenSRF::Utils::JSON->perl2JSON(\@doc);
 	$logger->internal("AppSession sending doc: $json");
 
 	$self->{peer_handle}->send( 

Modified: trunk/src/perlmods/OpenSRF/Application/Demo/MathDB.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/Application/Demo/MathDB.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/Application/Demo/MathDB.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -1,5 +1,5 @@
 package OpenSRF::Application::Demo::MathDB;
-use JSON;
+use OpenSRF::Utils::JSON;
 use base qw/OpenSRF::Application/;
 use OpenSRF::Application;
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
@@ -20,7 +20,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 + $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 __PACKAGE__->register_method( method => 'sub_1', api_name => 'dbmath.sub' );
@@ -31,7 +31,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 - $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 __PACKAGE__->register_method( method => 'mult_1', api_name => 'dbmath.mult' );
@@ -42,7 +42,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 * $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 __PACKAGE__->register_method( method => 'div_1', api_name => 'dbmath.div' );
@@ -53,7 +53,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 / $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 1;

Modified: trunk/src/perlmods/OpenSRF/Application/Persist.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/Application/Persist.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/Application/Persist.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -6,7 +6,7 @@
 use OpenSRF::EX qw/:try/;
 use OpenSRF::Utils qw/:common/;
 use OpenSRF::Utils::Logger;
-use JSON;
+use OpenSRF::Utils::JSON;
 use DBI;
 
 use vars qw/$dbh $log $default_expire_time/;
@@ -227,7 +227,7 @@
 			$dbh->do('DELETE FROM storage WHERE name_id = ?;', {}, $name_id);
 		}
 
-		$dbh->do('INSERT INTO storage (name_id,value) VALUES (?,?);', {}, $name_id, JSON->perl2JSON($value));
+		$dbh->do('INSERT INTO storage (name_id,value) VALUES (?,?);', {}, $name_id, OpenSRF::Utils::JSON->perl2JSON($value));
 
 		_flush_by_name($name);
 
@@ -344,7 +344,7 @@
 
 		_flush_by_name($name);
 
-		return JSON->JSON2perl( $value->[1] );
+		return OpenSRF::Utils::JSON->JSON2perl( $value->[1] );
 	} catch Error with {
 		#my $e = shift;
 		#return $e;
@@ -377,7 +377,7 @@
 	
 	my $values = $dbh->selectall_arrayref("SELECT value FROM storage WHERE name_id = ? ORDER BY id $order;", {}, $name_id);
 
-	$client->respond( JSON->JSON2perl( $_->[0] ) ) for (@$values);
+	$client->respond( OpenSRF::Utils::JSON->JSON2perl( $_->[0] ) ) for (@$values);
 
 	_flush_by_name($name);
 	return undef;
@@ -407,7 +407,7 @@
 
 	my $value = $dbh->selectcol_arrayref('SELECT SUM(LENGTH(value)) FROM storage WHERE name_id = ?;', {}, $name_id);
 
-	return JSON->JSON2perl( $value->[0] );
+	return OpenSRF::Utils::JSON->JSON2perl( $value->[0] );
 }
 __PACKAGE__->register_method(
 	api_name => 'opensrf.persist.queue.size',
@@ -436,7 +436,7 @@
 
 	my $value = $dbh->selectcol_arrayref('SELECT COUNT(*) FROM storage WHERE name_id = ?;', {}, $name_id);
 
-	return JSON->JSON2perl( $value->[0] );
+	return OpenSRF::Utils::JSON->JSON2perl( $value->[0] );
 }
 __PACKAGE__->register_method(
 	api_name => 'opensrf.persist.queue.length',
@@ -465,7 +465,7 @@
 
 		_flush_by_name($name);
 
-		return JSON->JSON2perl( $value->[1] );
+		return OpenSRF::Utils::JSON->JSON2perl( $value->[1] );
 	} catch Error with {
 		my $e = shift;
 		return undef;
@@ -498,7 +498,7 @@
 
 		_flush_by_name($name);
 
-		return JSON->JSON2perl( $value->[1] );
+		return OpenSRF::Utils::JSON->JSON2perl( $value->[1] );
 	} catch Error with {
 		return undef;
 	};

Modified: trunk/src/perlmods/OpenSRF/Application.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/Application.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/Application.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -10,7 +10,7 @@
 use Time::HiRes qw/time/;
 use OpenSRF::EX qw/:try/;
 use Carp;
-use JSON;
+use OpenSRF::Utils::JSON;
 #use OpenSRF::UnixServer;  # to get the server class from UnixServer::App
 
 sub DESTROY{};
@@ -148,7 +148,7 @@
 							for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) {
 								my $s = $sig->{params}->[$p];
 								my $a = $args[$p];
-								if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) {
+								if ($s->{class} && OpenSRF::Utils::JSON->lookup_hint(ref $a) ne $s->{class}) {
 									die "Incorrect param class at position $p : should be a '$$s{class}'";
 								} elsif ($s->{type}) {
 									if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) {
@@ -225,7 +225,7 @@
 								for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) {
 									my $s = $sig->{params}->[$p];
 									my $a = $args[$p];
-									if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) {
+									if ($s->{class} && OpenSRF::Utils::JSON->lookup_hint(ref $a) ne $s->{class}) {
 										die "Incorrect param class at position $p : should be a '$$s{class}'";
 									} elsif ($s->{type}) {
 										if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) {
@@ -393,7 +393,7 @@
 		($args{object_hint} = $args{package}) =~ s/::/_/go;
 	}
 
-	JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" );
+	OpenSRF::Utils::JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" );
 
 	$_METHODS[$args{api_level}]{$args{api_name}} = bless \%args => $app;
 

Modified: trunk/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -1,18 +1,18 @@
 package OpenSRF::DomainObject::oilsMessage;
-use JSON;
+use OpenSRF::Utils::JSON;
 use OpenSRF::AppSession;
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use OpenSRF::Utils::Logger qw/:level/;
 use warnings; use strict;
 use OpenSRF::EX qw/:try/;
 
-JSON->register_class_hint(hint => 'osrfMessage', name => 'OpenSRF::DomainObject::oilsMessage', type => 'hash');
+OpenSRF::Utils::JSON->register_class_hint(hint => 'osrfMessage', name => 'OpenSRF::DomainObject::oilsMessage', type => 'hash');
 
 sub toString {
 	my $self = shift;
 	my $pretty = shift;
-	return JSON->perl2prettyJSON($self) if ($pretty);
-	return JSON->perl2JSON($self);
+	return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty);
+	return OpenSRF::Utils::JSON->perl2JSON($self);
 }
 
 sub new {

Modified: trunk/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -1,13 +1,13 @@
 package OpenSRF::DomainObject::oilsMethod;
 
-use JSON;
-JSON->register_class_hint(hint => 'osrfMethod', name => 'OpenSRF::DomainObject::oilsMethod', type => 'hash');
+use OpenSRF::Utils::JSON;
+OpenSRF::Utils::JSON->register_class_hint(hint => 'osrfMethod', name => 'OpenSRF::DomainObject::oilsMethod', type => 'hash');
 
 sub toString {
 	my $self = shift;
 	my $pretty = shift;
-	return JSON->perl2prettyJSON($self) if ($pretty);
-	return JSON->perl2JSON($self);
+	return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty);
+	return OpenSRF::Utils::JSON->perl2JSON($self);
 }
 
 sub new {

Modified: trunk/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -1,11 +1,11 @@
 package OpenSRF::DomainObject::oilsResponse;
 use vars qw/@EXPORT_OK %EXPORT_TAGS/;
 use Exporter;
-use JSON;
+use OpenSRF::Utils::JSON;
 use base qw/Exporter/;
 use OpenSRF::Utils::Logger qw/:level/;
 
-JSON->register_class_hint( hint => 'osrfResponse', name => 'OpenSRF::DomainObject::oilsResponse', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfResponse', name => 'OpenSRF::DomainObject::oilsResponse', type => 'hash' );
 
 BEGIN {
 @EXPORT_OK = qw/STATUS_CONTINUE STATUS_OK STATUS_ACCEPTED
@@ -74,8 +74,8 @@
 sub toString {
 	my $self = shift;
 	my $pretty = shift;
-	return JSON->perl2prettyJSON($self) if ($pretty);
-	return JSON->perl2JSON($self);
+	return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty);
+	return OpenSRF::Utils::JSON->perl2JSON($self);
 }
 
 sub new {
@@ -115,7 +115,7 @@
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use base 'OpenSRF::DomainObject::oilsResponse';
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfStatus', name => 'OpenSRF::DomainObject::oilsStatus', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfStatus', name => 'OpenSRF::DomainObject::oilsStatus', type => 'hash' );
 
 =head1 NAME
 
@@ -146,7 +146,7 @@
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use base 'OpenSRF::DomainObject::oilsStatus';
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfConnectStatus', name => 'OpenSRF::DomainObject::oilsConnectStatus', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfConnectStatus', name => 'OpenSRF::DomainObject::oilsConnectStatus', type => 'hash' );
 
 =head1 NAME
 
@@ -184,7 +184,7 @@
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use base 'OpenSRF::DomainObject::oilsStatus';
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfContinueStatus', name => 'OpenSRF::DomainObject::oilsContinueStatus', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfContinueStatus', name => 'OpenSRF::DomainObject::oilsContinueStatus', type => 'hash' );
 
 =head1 NAME
 
@@ -227,7 +227,7 @@
 use OpenSRF::DomainObject::oilsPrimitive;
 use base 'OpenSRF::DomainObject::oilsResponse';
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfResult', name => 'OpenSRF::DomainObject::oilsResult', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfResult', name => 'OpenSRF::DomainObject::oilsResult', type => 'hash' );
 
 
 $status = 'OK';
@@ -296,7 +296,7 @@
 use base qw/OpenSRF::EX OpenSRF::DomainObject::oilsResponse/;
 use vars qw/$status $statusCode/;
 use Error;
-JSON->register_class_hint( hint => 'osrfException', name => 'OpenSRF::DomainObject::oilsException', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfException', name => 'OpenSRF::DomainObject::oilsException', type => 'hash' );
 
 sub message {
 	my $self = shift;
@@ -339,7 +339,7 @@
 use OpenSRF::EX;
 use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/;
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfConnectException', name => 'OpenSRF::DomainObject::oilsConnectException', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfConnectException', name => 'OpenSRF::DomainObject::oilsConnectException', type => 'hash' );
 
 =head1 NAME
 
@@ -375,7 +375,7 @@
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use base 'OpenSRF::DomainObject::oilsException';
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfMethodException', name => 'OpenSRF::DomainObject::oilsMethodException', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfMethodException', name => 'OpenSRF::DomainObject::oilsMethodException', type => 'hash' );
 
 =head1 NAME
 
@@ -414,7 +414,7 @@
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use base 'OpenSRF::DomainObject::oilsException';
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfServerError', name => 'OpenSRF::DomainObject::oilsServerError', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfServerError', name => 'OpenSRF::DomainObject::oilsServerError', type => 'hash' );
 
 $status = 'Internal Server Error';
 $statusCode = STATUS_INTERNALSERVERERROR;
@@ -430,7 +430,7 @@
 use OpenSRF::EX;
 use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/;
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfBrokenSession', name => 'OpenSRF::DomainObject::oilsBrokenSession', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfBrokenSession', name => 'OpenSRF::DomainObject::oilsBrokenSession', type => 'hash' );
 $status = "Request on Disconnected Session";
 $statusCode = STATUS_EXPFAILED;
 
@@ -439,7 +439,7 @@
 use OpenSRF::EX;
 use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/;
 use vars qw/$status $statusCode/;
-JSON->register_class_hint( hint => 'osrfXMLParseError', name => 'OpenSRF::DomainObject::oilsXMLParseError', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfXMLParseError', name => 'OpenSRF::DomainObject::oilsXMLParseError', type => 'hash' );
 $status = "XML Parse Error";
 $statusCode = STATUS_EXPFAILED;
 
@@ -447,7 +447,7 @@
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use OpenSRF::EX;
 use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/;
-JSON->register_class_hint( hint => 'osrfAuthException', name => 'OpenSRF::DomainObject::oilsAuthException', type => 'hash' );
+OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfAuthException', name => 'OpenSRF::DomainObject::oilsAuthException', type => 'hash' );
 use vars qw/$status $statusCode/;
 $status = "Authentication Failure";
 $statusCode = STATUS_FORBIDDEN;

Modified: trunk/src/perlmods/OpenSRF/System.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/System.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/System.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -111,7 +111,7 @@
 
 	OpenSRF::Utils::Config->load( config_file => $bootstrap_config_file );
 
-	JSON->register_class_hint( name => "OpenSRF::Application", hint => "method", type => "hash" );
+	OpenSRF::Utils::JSON->register_class_hint( name => "OpenSRF::Application", hint => "method", type => "hash" );
 
 	OpenSRF::Transport->message_envelope(  "OpenSRF::Transport::SlimJabber::MessageWrapper" );
 	OpenSRF::Transport::PeerHandle->set_peer_client(  "OpenSRF::Transport::SlimJabber::PeerConnection" );

Modified: trunk/src/perlmods/OpenSRF/Transport.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/Transport.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/Transport.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -3,6 +3,7 @@
 use base 'OpenSRF';
 use Time::HiRes qw/time/;
 use OpenSRF::AppSession;
+use OpenSRF::Utils::JSON;
 use OpenSRF::Utils::Logger qw(:level);
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use OpenSRF::EX qw/:try/;
@@ -118,7 +119,7 @@
 
 	# Create a document from the JSON contained within the message 
 	my $doc; 
-	eval { $doc = JSON->JSON2perl($body); };
+	eval { $doc = OpenSRF::Utils::JSON->JSON2perl($body); };
 	if( $@ ) {
 
 		$logger->transport( "Received bogus JSON: $@", INFO );

Modified: trunk/src/perlmods/OpenSRF/UnixServer.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/UnixServer.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/UnixServer.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -10,7 +10,7 @@
 use OpenSRF::System;
 use OpenSRF::Utils::SettingsClient;
 use Time::HiRes qw(time);
-use JSON;
+use OpenSRF::Utils::JSON;
 use vars qw/@ISA $app/;
 use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
 use Carp;
@@ -208,7 +208,7 @@
 	my $imp = $client->config_value("apps", $app, "implementation");
 	OpenSRF::Application::server_class($app);
 	OpenSRF::Application->application_implementation( $imp );
-	JSON->register_class_hint( name => $imp, hint => $app, type => "hash" );
+	OpenSRF::Utils::JSON->register_class_hint( name => $imp, hint => $app, type => "hash" );
 	OpenSRF::Application->application_implementation->initialize()
 		if (OpenSRF::Application->application_implementation->can('initialize'));
 

Modified: trunk/src/perlmods/OpenSRF/Utils/Cache.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/Utils/Cache.pm	2007-07-02 14:24:04 UTC (rev 988)
+++ trunk/src/perlmods/OpenSRF/Utils/Cache.pm	2007-07-02 15:11:15 UTC (rev 989)
@@ -6,7 +6,7 @@
 use OpenSRF::Utils::Config;
 use OpenSRF::Utils::SettingsClient;
 use OpenSRF::EX qw(:try);
-use JSON;
+use OpenSRF::Utils::JSON;
 
 my $log = 'OpenSRF::Utils::Logger';
 
@@ -96,7 +96,7 @@
 	my($self, $key, $value, $expiretime ) = @_;
 	return undef unless( defined $key and defined $value );
 
-	$value = JSON->perl2JSON($value);
+	$value = OpenSRF::Utils::JSON->perl2JSON($value);
 
 	if($self->{persist}){ _load_methods(); }
 
@@ -148,7 +148,7 @@
 	my($self, $key ) = @_;
 
 	my $val = $self->{memcache}->get( $key );
-	return JSON->JSON2perl($val) if defined($val);
+	return OpenSRF::Utils::JSON->JSON2perl($val) if defined($val);
 
 	if($self->{persist}){ _load_methods(); }
 
@@ -162,7 +162,7 @@
 			} else {
 				$self->{memcache}->set( $key, $val, $max_persist_time);
 			}
-			return JSON->JSON2perl($val);
+			return OpenSRF::Utils::JSON->JSON2perl($val);
 		} 
 	}
 	return undef;



More information about the opensrf-commits mailing list