川合 孝典 > Jamila-0.03 > Jamila

Download:
Jamila-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Jamila - Perl extension for JSON Approach to Make Integration Linking Applications

SYNOPSIS ^

 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";

DESCRIPTION ^

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.

proc

 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.

new

 I<$oJml> = Jamila->new(I<$sUrl>);

Constructor for call mode. You can set $sUrl as a URL or a local object.

call

 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.

SEE ALSO ^

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

AUTHOR ^

KAWAI,Takanori <kwitknr@cpan.org>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: