NAME

CGI::JSONRPC::Dispatcher - Dispatch JSONRPC requests to objects

SYNOPSIS

package Hello;

sub jsonrpc_new { my($class, $id) = @_; my $self = bless { id => $id }, $class; }

sub hi { return "hey"; }

DESCRIPTION

Apache2::JSONRPC::Dispatcher receives JSONRPC class method calls and translates them into perl object method calls. Here's how it works:

FUNCTION

AUTOLOAD($my_class, $id, $desired_class, @args)

When any function is called in Apache2::JSONRPC::Dispatcher, the AUTOLOAD sub runs.

  • $desired_class has all of it's dots (.) converted to double-colons (::) to translate JavaScript class names into perl.

  • The jsonrpc_new method in the resulting class is called with $id passed in as the first argument. An object should be returned from jsonrpc_new in your code.

  • The returned object has the desired method invoked, with any remaining arguments to AUTOLOAD passed in.

If jsonrpc_new does not exist in the requested package, a fatal error will occur. This both provides you with a handy state mechanism, and ensures that packages that aren't supposed to be accessed from the web aren't.

Apache2::JSONRPC attempts to call dispatchers with this set of arguments, and then takes any return values, serializes them to JSON, and sends a response back to the client.

AUTHOR

Tyler "Crackerjack" MacDonald <japh@crackerjack.net> and David Labatte <buggyd@justanotherperlhacker.com>

LICENSE

Copyright 2006 Tyler "Crackerjack" MacDonald <japh@crackerjack.net>

This is free software; You may distribute it under the same terms as perl itself.

SEE ALSO

The "examples/httpd.conf" file bundled with the distribution shows how to create a new JSONRPC::Dispatcher-compatible class, and also shows a rather hacky method for making an existing class accessable from JSON.

Apache2::JSONRPC

1 POD Error

The following errors were encountered while parsing the POD:

Around line 80:

You forgot a '=back' before '=head1'