| 1 | package Froody::Invoker; | ||
| 2 | 27 | ▶ | use base qw(Froody::Base); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | 27 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 27 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 27 | our $VERSION = "0.01"; | |
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Froody::Invoker - provide a way to run a Froody::Method | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | # create a new invoker (for local implementations) | ||
| 16 | use Froody::Invoker::Implementation; | ||
| 17 | my $inv = Froody::Invoker::Implementation->new() | ||
| 18 | ->dispatch_class($class); | ||
| 19 | |||
| 20 | # create a method, and assign it an invoker | ||
| 21 | my $method = Froody::Method->new() | ||
| 22 | ->full_name("fred.bar.baz") | ||
| 23 | ->invoker($inv); | ||
| 24 | |||
| 25 | =head1 DESCRIPTION | ||
| 26 | |||
| 27 | If you just want to write a simple Froody server, you don't need to worry about | ||
| 28 | this class. Go read the documentation for Froody::Implementation instead. | ||
| 29 | |||
| 30 | A Froody::Invoker is the counterpart to a Froody::Method. It's essentially | ||
| 31 | responsible for doing whatever task the Froody::Method is describing and | ||
| 32 | generating the Froody::Response. It's called an 'Invoker' because in most cases | ||
| 33 | the classes don't actually contain the implementation code itself, they just | ||
| 34 | know enough to call out to the actual code, or to another server, or | ||
| 35 | I<somewhere> to get the job done. | ||
| 36 | |||
| 37 | For this reason, most users of Froody don't ever need to write their own | ||
| 38 | Invoker. They just need to implement the code whatever Invoker they're relying | ||
| 39 | on calls. | ||
| 40 | |||
| 41 | =head2 Standard Invokers | ||
| 42 | |||
| 43 | Froody::Invoker itself is an abstract superclass. There are four concrete | ||
| 44 | Invoker subclasses that ship in the Froody distribution: | ||
| 45 | |||
| 46 | =over | ||
| 47 | |||
| 48 | =item Froody::Invoker::Implementation | ||
| 49 | |||
| 50 | Allows you to write local implementations with simple Perl methods. | ||
| 51 | |||
| 52 | =item Froody::Invoker::Remote | ||
| 53 | |||
| 54 | Dispatches calls to a remote Froody server | ||
| 55 | |||
| 56 | =back | ||
| 57 | |||
| 58 | See the module documentation for each Invoker for more details on how to use | ||
| 59 | them. | ||
| 60 | |||
| 61 | =head2 invoke - Writing Your Own Invokers | ||
| 62 | |||
| 63 | The one and only method you need to write for a given Invoker is C<invoke>. | ||
| 64 | This method takes two arguments, the Froody::Method that's being invoked and | ||
| 65 | the hashref containing the parameters that it's being called with. It has to | ||
| 66 | return a Froody::Response. | ||
| 67 | |||
| 68 | An Invoker is responsible for doing everything from checking the parameters | ||
| 69 | that have been passed in are correctly formatted to throwing errors if | ||
| 70 | something goes wrong. If you throw an error inside an Invoker that's been | ||
| 71 | called from a Froody::Server it'll be caught by the Dispatcher and turned into | ||
| 72 | a nice XML style error that'll be sent back to the user. | ||
| 73 | |||
| 74 | Here's an example module that simply returns an empty reponse for every | ||
| 75 | request: | ||
| 76 | |||
| 77 | package Froody::Invoker::Null; | ||
| 78 | use base qw(Froody::Invoker); | ||
| 79 | |||
| 80 | use Froody::Response; | ||
| 81 | |||
| 82 | sub invoke | ||
| 83 | { | ||
| 84 | my $self = shift; | ||
| 85 | my $method = shift; | ||
| 86 | my $params = shift; | ||
| 87 | |||
| 88 | return Froody::Response->new() | ||
| 89 | } | ||
| 90 | |||
| 91 | 1; | ||
| 92 | |||
| 93 | =head2 SUPPORT METHODS | ||
| 94 | |||
| 95 | =over | ||
| 96 | |||
| 97 | =cut | ||
| 98 | |||
| 99 | 0 | ▶ | sub invoke { |
|
Subroutine
invoke: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 100 | 0 | Froody::Error->throw("perl.methodcall.unimplemented", | |
| 101 | "This is an abstract base class. Please implement invoke"); | ||
| 102 | } | ||
| 103 | |||
| 104 | =item source | ||
| 105 | |||
| 106 | Provides a human readable description | ||
| 107 | of where the invocation is going to actually occur. | ||
| 108 | |||
| 109 | =cut | ||
| 110 | |||
| 111 | 0 | ▶ | sub source { |
|
Subroutine
source: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 112 | 0 | __PACKAGE__; | |
| 113 | } | ||
| 114 | |||
| 115 | =back | ||
| 116 | |||
| 117 | =head1 BUGS | ||
| 118 | |||
| 119 | None known. | ||
| 120 | |||
| 121 | Please report any bugs you find via the CPAN RT system. | ||
| 122 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody> | ||
| 123 | |||
| 124 | =head1 AUTHOR | ||
| 125 | |||
| 126 | Copyright Fotango 2005. All rights reserved. | ||
| 127 | |||
| 128 | Please see the main L<Froody> documentation for details of who has worked | ||
| 129 | on this project. | ||
| 130 | |||
| 131 | This module is free software; you can redistribute it and/or modify it under | ||
| 132 | the same terms as Perl itself. | ||
| 133 | |||
| 134 | =head1 SEE ALSO | ||
| 135 | |||
| 136 | =over | ||
| 137 | |||
| 138 | =item L<Froody::Method> | ||
| 139 | |||
| 140 | =item L<Froody::Implementation> | ||
| 141 | |||
| 142 | =item L<Froody::Invoker::Remote> | ||
| 143 | |||
| 144 | =back | ||
| 145 | |||
| 146 | =cut | ||
| 147 | |||
| 148 | 27 | 1; | |
| 149 | |||