Jamila - Perl extension for JSON Approach to Make Integration Linking Applications
1. Receive Mode: 1.1 Perl sample(testJamila.pl) #!/usr/bin/perl use strict; package Smp; sub echo($$) { my($sClass, $sPrm) = @_; return "Welcome to Jamila! ( $sPrm )"; } package main; use Jamila; Jamila->proc('Smp'); 1.2 Call from JavaScript var oJmR = new Jamila( '/cgi-bin/jamila/testJamila.pl', null, null, function(sMsg) { alert("ERROR:" + sMsg);}); alert(oJmR.call('echo', 'Call FROM JavaScript' )); var oLocal = { echo: function (sPrm) { return "LOCAL CALL:" + sPrm;}, }; var oJmL = new Jamila(oLocal, null, null, function(sMsg) { alert("ERROR:" + sMsg);}); alert(oJmL.call('echo', 'Call FROM JavaScript(LOCAL)' )); 2. Call Mode: use strict; package SmpLocal; sub echo($$) { my($sClass, $sPrm) = @_; return "LOCAL: Welcome to Jamila! ( $sPrm )"; } package main; use Jamila; use Data::Dumper; #(1) Call Remote my $oJm = Jamila->new( 'http://hippo2000.atnifty.com/cgi-bin/jamila/testJamila.pl'); print $oJm->call('echo', 'Test for Remote') . "\n"; #(2) Call Local my $oJmL = Jamila->new(bless {}, 'SmpLocal'); print $oJmL->call('echo', 'How is local?') . "\n";
Jamila is yet another RPC using JSON and HTTP(CGI). Jamila stands for JSON Approach to Make Integration Linking Applications.
Jamila has 2 modes; recieve and call.
Jamila->proc(I<$sModule>);
In receive mode, this is the only method to call. When this method is called, Jamila will get parameters from CGI parameters. And it will call the function specified in a parameter.
I<$oJml> = Jamila->new(I<$sUrl>);
Constructor for call mode. You can set $sUrl as a URL or a local object.
I<$oJml>->call(I<$sUrl>);
If you set a URL in "new" method, "call" will POST to that URL. If you set a local object in "new" method, "call" will perform a function of the specified object.
This distribution has sample HTML + JavaScript and perl script.
- 1. Put jamila.html and Jamila.js into a htdocs/jamila directory. - 2. Put testJamila.pl into a cgi-bin/jamila directory. And set to run that script. - 3. Run perl function from jamila.html
KAWAI,Takanori <kwitknr@cpan.org>
Copyright (C) 2009 by KAWAI,Takanori
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
To install Jamila, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jamila
CPAN shell
perl -MCPAN -e shell install Jamila
For more information on module installation, please visit the detailed CPAN module installation guide.