RPC::XML::Procedure - Object encapsulation of server-side RPC procedures
require RPC::XML::Procedure;
... $method_1 = RPC::XML::Procedure->new({ name => 'system.identity', code => sub { ... }, signature => [ 'string' ] }); $method_2 = RPC::XML::Procedure->new('/path/to/status.xpl');
This package grew out of the increasing need to abstract the operations that related to the methods a given server instance was providing. Previously, methods were passed around simply as hash references. It was a small step then to move them into a package and allow for operations directly on the objects themselves. In the spirit of the original hashes, all the key data is kept in clear, intuitive hash keys (rather than obfuscated as the other classes do). Thus it is important to be clear on the interface here before sub-classing this package.
Note that all of these correspond to the values that can be changed via the accessor methods detailed later.
If any error occurs during object creation, an error message is returned in lieu of the object reference.
The lightweight DTD for the layout can be summarized as:
<!ELEMENT proceduredef (name, version?, hidden?, signature+, help?, code)> <!ELEMENT methoddef (name, version?, hidden?, signature+, help?, code)> <!ELEMENT name (#PCDATA)> <!ELEMENT version (#PCDATA)> <!ELEMENT hidden EMPTY> <!ELEMENT signature (#PCDATA)> <!ELEMENT help (#PCDATA)> <!ELEMENT code (#PCDATA)> <!ATTLIST code language (#PCDATA)>
The containing tag is always one of "<methoddef>" or "<proceduredef>". The tags that specify name, signatures and the code itself must always be present. Some optional information may also be supplied. The ``help'' text, or what an introspection API would expect to use to document the method, is also marked as optional. Having some degree of documentation for all the methods a server provides is a good rule of thumb, however.
The default methods that this package provides are turned into XPL files by the make_method tool (see make_method). The final forms of these may serve as direct examples of what the file should look like.
It is the hope behind this package that collections of RPC suites may one day be made available as separate entities from this specific software package. Given this hope, it is not unreasonable to suggest that such a suite of code might be implemented in more than one language (each of Perl, Python, Ruby and Tcl, for example). Languages which all support the means by which to take new code and add it to a running process on demand (usually through an ""eval"" keyword or something similar). If the file A.xpl is provided with implementations in all four of the above languages, the name, help text, signature and even hidden status would likely be identical. So, why not share the non-language-specific elements in the spirit of re-use?
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |