| 1 |
<?xml version="1.0"?> |
| 2 |
<!DOCTYPE methoddef SYSTEM "rpc-method.dtd"> |
| 3 |
<!-- |
| 4 |
Generated automatically by etc\make_method v1.09, Fri May 31 04:39:51 2002 |
| 5 |
|
| 6 |
Any changes made here will be lost. |
| 7 |
--> |
| 8 |
<methoddef> |
| 9 |
<name>system.introspection</name> |
| 10 |
<version>1.1</version> |
| 11 |
<signature>array</signature> |
| 12 |
<signature>array array</signature> |
| 13 |
<signature>struct string</signature> |
| 14 |
<help> |
| 15 |
Return the name, signatures and help text for the registered methods on |
| 16 |
the server. With no parameters, returns an ARRAY of STRUCTs. With an ARRAY |
| 17 |
parameter, expects all elements to be of type STRING and specify method |
| 18 |
names, with the return value being an ARRAY of STRUCT for the named methods |
| 19 |
(in order). If the parameter is a single STRING type, the return value is |
| 20 |
a STRUCT for the named method. |
| 21 |
|
| 22 |
Each STRUCT will have the following members: |
| 23 |
|
| 24 |
name A STRING containing the method name |
| 25 |
version A STRING version stamp. Empty if none was specified. |
| 26 |
signature An ARRAY containing the signatures, each an ARRAY of STRING |
| 27 |
help A STRING containing the help text for the method |
| 28 |
|
| 29 |
Note that an ARRAY is returned for the signatures even when there is only one |
| 30 |
signature. |
| 31 |
</help> |
| 32 |
<code language="perl"> |
| 33 |
<![CDATA[ |
| 34 |
#!perl |
| 35 |
############################################################################### |
| 36 |
# |
| 37 |
# Sub Name: introspection |
| 38 |
# |
| 39 |
# Description: Collates the data from listMethods, methodHelp and |
| 40 |
# methodSignature into a single array |
| 41 |
# |
| 42 |
# Arguments: NAME IN/OUT TYPE DESCRIPTION |
| 43 |
# $srv in ref Server object instance |
| 44 |
# $list in listref If passed, limit methods listed |
| 45 |
# or scalar to these. |
| 46 |
# |
| 47 |
# Globals: None. |
| 48 |
# |
| 49 |
# Environment: None. |
| 50 |
# |
| 51 |
# Returns: Success: string or listref |
| 52 |
# Failure: fault object |
| 53 |
# |
| 54 |
############################################################################### |
| 55 |
sub introspection |
| 56 |
{ |
| 57 |
use strict; |
| 58 |
|
| 59 |
my $srv = shift; |
| 60 |
my $list = shift; |
| 61 |
|
| 62 |
my (@methods, @all_methods, %all_methods, @bad, @results, $scalar, $meth); |
| 63 |
|
| 64 |
my $name = $srv->{method_name}; |
| 65 |
$scalar = ($list and (! ref($list))) ? 1 : 0; |
| 66 |
@all_methods = sort $srv->list_methods; |
| 67 |
|
| 68 |
if ($list) |
| 69 |
{ |
| 70 |
# This is an expensive-enough operation that I don't want to do it |
| 71 |
# if I don't have to |
| 72 |
@methods = ($scalar) ? ($list) : @$list; |
| 73 |
@all_methods{@all_methods} = (1) x scalar(@all_methods); |
| 74 |
if (@bad = grep(! $all_methods{$_}, @methods)) |
| 75 |
{ |
| 76 |
local $" = ', '; |
| 77 |
return RPC::XML::fault->new(302, "$name: Method(s) @bad unknown"); |
| 78 |
} |
| 79 |
} |
| 80 |
else |
| 81 |
{ |
| 82 |
@methods = @all_methods; |
| 83 |
} |
| 84 |
|
| 85 |
# Convert in-place to their objects |
| 86 |
for (@methods) { $_ = $srv->get_method($_); } |
| 87 |
# Since that list came from the server object, we know alls calls were OK |
| 88 |
|
| 89 |
for (@methods) |
| 90 |
{ |
| 91 |
push(@results, { name => $_->name, |
| 92 |
help => $_->help, |
| 93 |
signature => $_->signature, |
| 94 |
version => RPC::XML::string->new($_->version) }); |
| 95 |
} |
| 96 |
|
| 97 |
return $scalar ? $results[0] : \@results; |
| 98 |
} |
| 99 |
|
| 100 |
__END__ |
| 101 |
]]></code> |
| 102 |
</methoddef> |