File Coverage

blib/lib/JSORB.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package JSORB;
2 8     8   2236318 use Moose;
  0            
  0            
3              
4             our $VERSION = '0.04';
5             our $AUTHORITY = 'cpan:STEVAN';
6              
7             use JSORB::Namespace;
8             use JSORB::Interface;
9             use JSORB::Procedure;
10             use JSORB::Method;
11              
12             use JSORB::Types;
13              
14             no Moose; 1;
15              
16             __END__
17              
18             =pod
19              
20             =head1 NAME
21              
22             JSORB - Javascript Object Request Broker
23              
24             =head1 SYNOPSIS
25              
26             use JSORB;
27             use JSORB::Server::Simple;
28             use JSORB::Dispatcher::Path;
29             use JSORB::Reflector::Package;
30             use JSORB::Client::Compiler::Javascript;
31              
32             # create some code to expose over RPC
33             {
34             package Math::Simple;
35             use Moose;
36             sub add { $_[0] + $_[1] }
37             }
38              
39             # Set up a simple JSORB server
40             JSORB::Server::Simple->new(
41             port => 8080,
42             dispatcher => JSORB::Dispatcher::Path->new(
43             namespace => JSORB::Reflector::Package->new(
44             # tell JSORB to introspect the package
45             introspector => Math::Simple->meta,
46             # add some type information
47             # about the procedure
48             procedure_list => [
49             { name => 'add', spec => [ ('Int', 'Int') => 'Int' ] }
50             ]
51             )->namespace
52             )
53             )->run;
54              
55             ## Now you can ...
56              
57             ## go to the URL directly
58              
59             http://localhost:8080/?method=/math/simple/add&params=[2,2]
60              
61             # and get back a response
62             { "jsonrpc" : "2.0", "result" : 2 }
63              
64             ## compile your own Javascript client
65             ## library for use in a web page ...
66              
67             my $c = JSORB::Client::Compiler::Javascript->new;
68             $c->compile(
69             namespace => $namespace,
70             to => [ 'webroot', 'js', 'MathSimple.js' ]
71             );
72              
73             # and in your JS
74              
75             var math = new Math.Simple ( 'http://localhost:8080' );
76             math.add( 2, 2, function (result) { alert(result) } );
77              
78             ## or use the more low level
79             ## JSORB client library directly
80              
81             var c = new JSORB.Client ({
82             base_url : 'http://localhost:8080/',
83             })
84              
85             c.call({
86             method : '/math/simple/add',
87             params : [ 2, 2 ]
88             }, function (result) {
89             alert(result)
90             });
91              
92             =head1 DESCRIPTION
93              
94             __
95             __ /\ \
96             /\_\ ____ ___ _ __ \ \ \____
97             \/\ \ /',__\ / __`\ /\`'__\ \ \ '__`\
98             \ \ \ /\__, `\/\ \L\ \\ \ \/ \ \ \L\ \
99             _\ \ \ \/\____/\ \____/ \ \_\ \ \_,__/
100             /\ \_\ \ \/___/ \/___/ \/_/ \/___/
101             \ \____/
102             \/___/
103              
104             =head2 DISCLAIMER
105              
106             This is a B<VERY VERY> early release of this module, and while
107             it is quite functional, this module should in no way be seen as
108             complete. You are more then welcome to experiment and play
109             around with this module, but don't come crying to me if it
110             accidently deletes your MP3 collection, kills the neighbors dog
111             and causes the large hadron collider to create a black hole that
112             swallows up all of existence tearing you molecule from molecule
113             along the event horizon for all eternity.
114              
115             =head2 GOAL
116              
117             The goal of this module is to provide a cleaner and more formalized
118             way to do AJAX programming using JSON-RPC in the flavor of Object
119             Request Brokers.
120              
121             =head2 FUTURE PLANS
122              
123             Currently this is more focused on RPC calls between Perl on the
124             server side and Javascript on the client side. Eventually we will
125             have a Perl client and possibly some servers written in other
126             languages as well.
127              
128             =head2 GETTING STARTED
129              
130             The documentation is very sparse and I apologize for that, but the
131             test suite has a lot of good stuff to read and there is a couple
132             neat things in the example directory. If you want to know more
133             about the Javascript end there are tests for that as well. As this
134             module matures more the docs will improve, but as mentioned above,
135             it is still pretty new and we have big plans for its future.
136              
137             =head1 BUGS
138              
139             All complex software has bugs lurking in it, and this module is no
140             exception. If you find a bug please either email me, or add the bug
141             to cpan-RT.
142              
143             =head1 AUTHOR
144              
145             Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
146              
147             =head1 COPYRIGHT AND LICENSE
148              
149             Copyright 2008-2010 Infinity Interactive, Inc.
150              
151             L<http://www.iinteractive.com>
152              
153             This library is free software; you can redistribute it and/or modify
154             it under the same terms as Perl itself.
155              
156             =cut