Hi All,
Inline::Java (as of 0.21), now has some of the features of Java.pm. You can
load up a precompiled Java class and bind all it's public members/methods to
Perl. You can also use AUTOSTUDY to learn about Java classes on-the-fly (as
they 'enter' the Perl world when they are returned by methods).
Ex (from Java.pod)
---------------------------------------------------------------------------
=head1 STUDYING
As of version 0.21, C<Inline::Java> can learn about other Java classes
and use them just like the Java code you write inside your Perl script.
In fact you are not even required to write Java code inside your Perl
script anymore. Here's how to use the 'studying' function:
use Inline {
Java => 'STUDY',
STUDY => ['java.lang.HashMap'],
) ;
my $hm = new java::lang::HashMap() ;
$hm->put("key", "value") ;
my $v = $hm->get("key") ;
If you do not wish to put any Java code inside you Perl script, you must
use the string 'STUDY' as your code. This will skip the build section.
You can also use the AUTOSTUDY option to tell C<Inline::Java> that you wish
to study all classes that it comes across:
use Inline {
Java => 'DATA',
AUTOSTUDY => 1,
) ;
my $obj = new Foo8() ;
my $hm = $obj->get_hm() ;
$hm->put("key", "value") ;
my $v = $hm->get("key") ;
__END__
__Java__
import java.util.* ;
class Foo8 {
public Foo8() {
}
public HashMap get_hm(){
HashMap hm = new HashMap() ;
return hm ;
}
}
In this case C<Inline::Java> intercepts the return value of the get_hm()
method, sees that it's of a type that it doesn't know about
(java.lang.HashMap),
and immediately studies the class. After that call the java::lang::HashMap
class is available to use through Perl.
---------------------------------------------------------------------------
About the client/server thing, you can almost already to that. Inline::Java
already sets up a Java server and connects to it to send requests. The code
could easily be configured to look up some host:port to get that server
instead of starting it locally.
As far as security is concerned, The way I would implement it would be
similar to Java.pm: All code is located and run on the server. So basically
the server provides the Java runtime and Java classes to the client.
The only security concern, IMOO, is with the client trusting the client. The
guy maintaining the module on the server side could change the classes and
make them do different things...
I'll take a look into implementing an "real" client/server mode later, right
now my priority is Inline 0.40.
Cheers,
Patrick