NAME

Prim - Perl Remote Invocation of Methods (RMI and EJB's for Perl, sort of)

SYNOPSIS

use Prim;

my $hello_obj = Prim->Prim_constructor($service_name, $optional_server_name);
my @response = $hello_obj->remote_method("arg1", "arg2");

DESCRIPTION

This module provides the following deception to the caller. The caller makes a Prim object giving only the registered name of a service (and possibly a server name). With the returned object, the caller calls functions on the remote service through the local object. The remote_method can be any method the server exposes in its API. The arguments can be anything except references (the server wouldn't be able to dereference them).

The constructor has a long name to avoid a conflicts with remote method names. Remote servers cannot use the names Prim_constructor or _Prim_discover for remote calls. Other methods which perl invokes magically are also unavailable as remote methods.

SUMMARY of INTERNALS

Prim uses AUTOLOAD to pretend to provide the caller's requested method. Inside AUTOLOAD it calls the call method of its PrimClient object, which in turn packs the call in xml, connects to the server, delivers the message, waits for the xml reply, unpacks it into a perl list, and finally hands it back to AUTOLOAD. AUTOLOAD delivers that list to the caller as if it were locally produced.

EXPORT

This is currently an object oriented module with no exports.

BUGS

There are no timeouts.

AUTHOR

Phil Crow, philcrow2000@yahoo.com

SEE ALSO

The files called client and objectclient in the distribution are examples of using this and its cousin PrimObject.pm.

new

This constructor takes the name of a service and optionally a server (at some point in the future, leaving out the server will cause discovery across the network, currently the server ignores the server name and uses localhost in all cases). It then locates the port number of the needed service. (At present it looks for a file in the /tmp directory called name.prim where name is the one passed in. This is handled by the _discover method which can and should be replaced with a more sophisticated scheme.)

Having located the machine and port number for the service, new builds a PrimClient object, stores it in a typical hash, blesses a reference to that hash, and returns the reference to the caller.