[libinline-java-perl] 110/398: *** empty log message ***
Jonas Smedegaard
dr at jones.dk
Thu Feb 26 11:42:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.55
in repository libinline-java-perl.
commit 0f6aac8da9c14ef0586dbf51de6a019d7247f05d
Author: Patrick LeBoutillier <patl at cpan.org>
Date: Mon Sep 17 20:03:34 2001 +0000
*** empty log message ***
---
Java.pm | 45 +++++++++---
Java.pod | 60 ++++++++++++++--
Java/Class.pm | 9 +--
Java/Init.pm | 202 ++++++++++++++++++++++++++++++++++++++++++++++--------
Java/JVM.pm | 98 +++++++++++++++++++-------
Java/Protocol.pm | 62 ++++++++---------
MANIFEST | 2 +
README | 15 +++-
README.JNI | 9 +++
t/02_primitives.t | 2 +-
10 files changed, 397 insertions(+), 107 deletions(-)
diff --git a/Java.pm b/Java.pm
index 69cee11..c517ef3 100644
--- a/Java.pm
+++ b/Java.pm
@@ -7,7 +7,7 @@ package Inline::Java ;
use strict ;
-$Inline::Java::VERSION = '0.23' ;
+$Inline::Java::VERSION = '0.30' ;
# DEBUG is set via the DEBUG config
@@ -46,9 +46,11 @@ my $DONE = 0 ;
# This is set when at least one JVM is loaded.
my $JVM = undef ;
+
# This hash will store the $o objects...
my $INLINES = {} ;
+
# Here is some code to figure out if we are running on command.com
# shell under Windows.
my $COMMAND_COM =
@@ -82,9 +84,7 @@ sub done {
Inline::Java::debug("killed by signal SIG$signal.") ;
}
- if ($JVM){
- undef $JVM ;
- }
+ shutdown_JVM() ;
Inline::Java::debug("exiting with $ec") ;
@@ -150,16 +150,15 @@ sub _validate {
my $o = shift ;
my $ignore_other_configs = shift ;
- # if ($o->get_INLINE_nb() == 1){
- # croak "Inline::Java does not currently support multiple Inline sections" ;
- # }
-
if (! exists($o->{ILSM}->{PORT})){
$o->{ILSM}->{PORT} = 7890 ;
}
if (! exists($o->{ILSM}->{STARTUP_DELAY})){
$o->{ILSM}->{STARTUP_DELAY} = 15 ;
}
+ if (! exists($o->{ILSM}->{SHARED_JVM})){
+ $o->{ILSM}->{SHARED_JVM} = 0 ;
+ }
if (! exists($o->{ILSM}->{DEBUG})){
$o->{ILSM}->{DEBUG} = 0 ;
}
@@ -199,6 +198,9 @@ sub _validate {
}
$o->{ILSM}->{$key} = $value ;
}
+ elsif ($key eq 'SHARED_JVM'){
+ $o->{ILSM}->{$key} = $value ;
+ }
elsif ($key eq 'DEBUG'){
$o->{ILSM}->{$key} = $value ;
$Inline::Java::DEBUG = $value ;
@@ -221,10 +223,22 @@ sub _validate {
}
}
+ if (defined($ENV{PERL_INLINE_JAVA_DEBUG})){
+ $Inline::Java::DEBUG = $ENV{PERL_INLINE_JAVA_DEBUG} ;
+ }
+
if (defined($ENV{PERL_INLINE_JAVA_JNI})){
$o->{ILSM}->{JNI} = $ENV{PERL_INLINE_JAVA_JNI} ;
}
+ if (defined($ENV{PERL_INLINE_JAVA_SHARED_JVM})){
+ $o->{ILSM}->{SHARED_JVM} = $ENV{PERL_INLINE_JAVA_SHARED_JVM} ;
+ }
+
+ if (($o->{ILSM}->{JNI})&&($o->{ILSM}->{SHARED_JVM})){
+ croak("You can't use the 'SHARED_JVM' option in 'JNI' mode") ;
+ }
+
$o->set_java_bin() ;
Inline::Java::debug("validate done.") ;
@@ -1080,6 +1094,20 @@ sub get_JVM {
}
+sub shutdown_JVM {
+ if ($JVM){
+ undef $JVM ;
+ }
+}
+
+
+sub reconnect_JVM {
+ if ($JVM){
+ $JVM->reconnect() ;
+ }
+}
+
+
sub get_INLINE {
my $module = shift ;
@@ -1088,7 +1116,6 @@ sub get_INLINE {
sub get_INLINE_nb {
-
return scalar(keys %{$INLINES}) ;
}
diff --git a/Java.pod b/Java.pod
index 280eb88..8e4c34a 100644
--- a/Java.pod
+++ b/Java.pod
@@ -138,6 +138,14 @@ behavior of C<Inline::Java>:
'use Inline Java' call inside a Perl script, since all other calls
make use of the same JVM.
+ SHARED_JVM:
+ This mode enables mutiple processes to share the same JVM. It was
+ created mainly in order to be able to use C<Inline::Java> under mod_perl.
+ Ex: SHARED_JVM => 1
+ Note: This configuration option only has an effect on the first
+ 'use Inline Java' call inside a Perl script, since all other calls
+ make use of the same JVM.
+
DEBUG:
Enables debugging info
Ex: DEBUG => 1
@@ -446,7 +454,7 @@ 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 {
+ use Inline (
Java => 'STUDY',
STUDY => ['java.lang.HashMap'],
) ;
@@ -461,7 +469,7 @@ 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 {
+ use Inline (
Java => 'DATA',
AUTOSTUDY => 1,
) ;
@@ -501,7 +509,7 @@ configuration option) to tell what Inline::Java modules it will need to load
at runtime:
package Foo ;
- use Inline {
+ use Inline (
Java => '<<END',
class Foo {
public Foo() {
@@ -513,7 +521,7 @@ at runtime:
) ;
package Bar ;
- use Inline {
+ use Inline (
Java => '<<END',
class Bar {
public Bar() {
@@ -521,7 +529,7 @@ at runtime:
}
END
NAME => "Bar",
- )
+ ) ;
package main ;
my $f = new Foo() ;
@@ -551,6 +559,48 @@ you can't use JNI for some sections and client/server for others. The first
section determines the execution mode.
+=head1 SHARED_JVM
+
+Starting with version 0.30, the C<Inline::Java> JVM can now be shared between
+multiple processes. The first process to start the JVM is considered the JVM owner
+and will shutdown the JVM on exit. All other processes can connect as needed to
+the JVM. If any of these other processes where created by forking the parent process,
+the Inline::Java->reconnect_JVM() function must be called in the child to get a fresh
+connection to the JVM. Ex:
+
+ use Inline (
+ Java => '<<END',
+ import java.util.* ;
+ class t {
+ public t(){
+ }
+ }
+ END
+ SHARED_JVM => 1,
+ ) ;
+
+ my $t = new t() ;
+
+ my $nb = 5 ;
+ for (my $i = 0 ; $i < $nb ; $i++){
+ if (! fork()){
+ Inline::Java::reconnect_JVM() ;
+ $t = new $t() ;
+ }
+ }
+
+Once this code was run, each of the 6 processes will have created a different instance
+of the t class. Data can be shared between the processes by using static members in the
+Java code.
+
+If processes not forked off the parent are connecting to the shared JVM, please remember
+to set the CLASSPATH for the classes in the other processes before starting the parent,
+or else the parent will not see these classes. See USING MULTIPLE SECTIONS for more
+details.
+
+Please note that the SHARED_JVM feature does not work in JNI mode.
+
+
=head1 SUPPORTED PLATFORMS
This is an ALPHA release of Inline::Java. Further testing and
diff --git a/Java/Class.pm b/Java/Class.pm
index 4c59c95..abf9c15 100644
--- a/Java/Class.pm
+++ b/Java/Class.pm
@@ -3,7 +3,7 @@ package Inline::Java::Class ;
use strict ;
-$Inline::Java::Class::VERSION = '0.22' ;
+$Inline::Java::Class::VERSION = '0.30' ;
$Inline::Java::Class::MAX_SCORE = 10 ;
@@ -667,11 +667,8 @@ class InlineJavaClass {
if (DoesExtend(c, p) > -1){
ijs.debug(" " + c.getName() + " is a kind of " + p.getName()) ;
// get the object from the hash table
- Integer oid = new Integer(objid) ;
- Object o = ijs.objects.get(oid) ;
- if (o == null){
- throw new InlineJavaException("Object " + oid.toString() + " of type " + c_name + " is not in object table ") ;
- }
+ int id = Integer.parseInt(objid) ;
+ Object o = ijs.GetObject(id) ;
ret = o ;
}
else{
diff --git a/Java/Init.pm b/Java/Init.pm
index bc97ae5..e22cd7b 100644
--- a/Java/Init.pm
+++ b/Java/Init.pm
@@ -3,7 +3,7 @@ package Inline::Java::Init ;
use strict ;
-$Inline::Java::Init::VERSION = '0.20' ;
+$Inline::Java::Init::VERSION = '0.30' ;
my $DATA = join('', <DATA>) ;
my $OBJECT_DATA = join('', <Inline::Java::Object::DATA>) ;
@@ -57,50 +57,63 @@ import java.lang.reflect.* ;
objects.
*/
public class InlineJavaServer {
- public ServerSocket ss ;
- public Socket client ;
- boolean debug = false ;
+ boolean debug ;
+ int port = 0 ;
+ boolean shared_jvm = false ;
- public HashMap objects = new HashMap() ;
+ public HashMap thread_objects = new HashMap() ;
public int objid = 1 ;
// This constructor is used in JNI mode
InlineJavaServer(boolean d) {
debug = d ;
+
+ thread_objects.put(Thread.currentThread().getName(), new HashMap()) ;
}
// This constructor is used in server mode
InlineJavaServer(String[] argv) {
debug = new Boolean(argv[0]).booleanValue() ;
+ port = Integer.parseInt(argv[1]) ;
+ shared_jvm = new Boolean(argv[2]).booleanValue() ;
- int port = Integer.parseInt(argv[1]) ;
-
+ ServerSocket ss = null ;
try {
- ss = new ServerSocket(port) ;
- client = ss.accept() ;
-
- BufferedReader br = new BufferedReader(
- new InputStreamReader(client.getInputStream())) ;
- BufferedWriter bw = new BufferedWriter(
- new OutputStreamWriter(client.getOutputStream())) ;
-
- while (true){
- String cmd = br.readLine() ;
-
- String resp = ProcessCommand(cmd) ;
- bw.write(resp) ;
- bw.flush() ;
- }
+ ss = new ServerSocket(port) ;
}
catch (IOException e){
System.err.println("Can't open server socket on port " + String.valueOf(port)) ;
+ System.exit(1) ;
+ }
+
+ while (true){
+ try {
+ InlineJavaThread ijt = new InlineJavaThread(this, ss.accept()) ;
+ ijt.start() ;
+ if (! shared_jvm){
+ try {
+ ijt.join() ;
+ }
+ catch (InterruptedException e){
+ }
+ break ;
+ }
+ }
+ catch (IOException e){
+ System.err.println("IO error: " + e.getMessage()) ;
+ }
}
+
System.exit(1) ;
}
- public String ProcessCommand(String cmd){
+ /*
+ Since this function is also called from the JNI XS extension,
+ it's best if it doesn't throw any exceptions.
+ */
+ public String ProcessCommand(String cmd) {
debug(" packet recv is " + cmd) ;
String resp = null ;
@@ -118,14 +131,98 @@ public class InlineJavaServer {
}
}
else{
- // Probably connection dropped...
- debug(" Lost connection with client") ;
- System.exit(1) ;
+ if (! shared_jvm){
+ // Probably connection dropped...
+ debug(" Lost connection with client in single client mode. Exiting.") ;
+ System.exit(1) ;
+ }
+ else{
+ debug(" Lost connection with client in shared JVM mode.") ;
+ return null ;
+ }
}
return resp ;
}
+
+ public Object GetObject(int id) throws InlineJavaException {
+ Object o = null ;
+ String name = Thread.currentThread().getName() ;
+ HashMap h = (HashMap)thread_objects.get(name) ;
+
+ if (h == null){
+ throw new InlineJavaException("Can't find thread " + name + "!") ;
+ }
+ else{
+ o = h.get(new Integer(id)) ;
+ if (o == null){
+ throw new InlineJavaException("Can't find object " + id + " for thread " + name) ;
+ }
+ }
+
+ return o ;
+ }
+
+
+ synchronized public void PutObject(int id, Object o) throws InlineJavaException {
+ String name = Thread.currentThread().getName() ;
+ HashMap h = (HashMap)thread_objects.get(name) ;
+
+ if (h == null){
+ throw new InlineJavaException("Can't find thread " + name + "!") ;
+ }
+ else{
+ h.put(new Integer(id), o) ;
+ objid++ ;
+ }
+ }
+
+
+ public Object DeleteObject(int id) {
+ Object o = null ;
+ try {
+ String name = Thread.currentThread().getName() ;
+ HashMap h = (HashMap)thread_objects.get(name) ;
+
+ if (h == null){
+ throw new InlineJavaException("Can't find thread " + name + "!") ;
+ }
+ else{
+ o = h.remove(new Integer(id)) ;
+ if (o == null){
+ throw new InlineJavaException("Can't find object " + id + " for thread " + name) ;
+ }
+ }
+ }
+ catch (InlineJavaException e){
+ debug(e.getMessage()) ;
+ }
+
+ return o ;
+ }
+
+
+ public int ObjectCount() {
+ int i = -1 ;
+ try {
+ String name = Thread.currentThread().getName() ;
+ HashMap h = (HashMap)thread_objects.get(name) ;
+
+ if (h == null){
+ throw new InlineJavaException("Can't find thread " + name + "!") ;
+ }
+ else{
+ i = h.values().size() ;
+ }
+ }
+ catch (InlineJavaException e){
+ debug(e.getMessage()) ;
+ }
+
+ return i ;
+ }
+
/*
Creates a string representing a method signature
@@ -148,7 +245,7 @@ public class InlineJavaServer {
}
- public void debug(String s) {
+ synchronized public void debug(String s) {
if (debug){
System.err.println("java: " + s) ;
System.err.flush() ;
@@ -168,7 +265,6 @@ public class InlineJavaServer {
return new InlineJavaServer(debug) ;
}
-
<INLINE_JAVA_OBJECT>
<INLINE_JAVA_ARRAY>
@@ -195,4 +291,54 @@ public class InlineJavaServer {
super(m) ;
}
}
+
+
+ class InlineJavaIOException extends IOException {
+ InlineJavaIOException(String m){
+ super(m) ;
+ }
+ }
+
+
+ class InlineJavaThread extends Thread {
+ InlineJavaServer ijs ;
+ Socket client ;
+
+ InlineJavaThread(InlineJavaServer _ijs, Socket _client){
+ super() ;
+ client = _client ;
+ ijs = _ijs ;
+ }
+
+
+ public void run(){
+ try {
+ ijs.thread_objects.put(getName(), new HashMap()) ;
+
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader(client.getInputStream())) ;
+ BufferedWriter bw = new BufferedWriter(
+ new OutputStreamWriter(client.getOutputStream())) ;
+
+ while (true){
+ String cmd = br.readLine() ;
+
+ String resp = ijs.ProcessCommand(cmd) ;
+ if (resp != null){
+ bw.write(resp) ;
+ bw.flush() ;
+ }
+ else {
+ break ;
+ }
+ }
+ }
+ catch (IOException e){
+ System.err.println("IO error: " + e.getMessage()) ;
+ }
+ finally {
+ ijs.thread_objects.remove(getName()) ;
+ }
+ }
+ }
}
diff --git a/Java/JVM.pm b/Java/JVM.pm
index 930c477..8fc5182 100644
--- a/Java/JVM.pm
+++ b/Java/JVM.pm
@@ -3,7 +3,7 @@ package Inline::Java::JVM ;
use strict ;
-$Inline::Java::JVM::VERSION = '0.22' ;
+$Inline::Java::JVM::VERSION = '0.30' ;
use Carp ;
use IPC::Open3 ;
@@ -18,6 +18,7 @@ sub new {
$this->{socket} = undef ;
$this->{JNI} = undef ;
+ $this->{owner} = 1 ;
Inline::Java::debug("Starting JVM...") ;
@@ -36,14 +37,29 @@ sub new {
}
else{
Inline::Java::debug(" Client/Server mode") ;
-
+
my $debug = (Inline::Java::get_DEBUG() ? "true" : "false") ;
+ my $shared_jvm = ($o->get_java_config('SHARED_JVM') ? "true" : "false") ;
my $port = $o->get_java_config('PORT') ;
+
+ $this->{port} = $port ;
+
+ # Check if JVM is already running
+ if ($shared_jvm){
+ eval {
+ $this->reconnect() ;
+ } ;
+ if (! $@){
+ Inline::Java::debug(" Connected to already running JVM!") ;
+ return $this ;
+ }
+ }
+
my $java = $o->get_java_config('BIN') . "/java" . Inline::Java::portable("EXE_EXTENSION") ;
my $pjava = Inline::Java::portable("RE_FILE", $java) ;
- my $cmd = "\"$pjava\" InlineJavaServer $debug $port" ;
+ my $cmd = "\"$pjava\" InlineJavaServer $debug $port $shared_jvm" ;
Inline::Java::debug($cmd) ;
if ($o->get_config('UNTAINT')){
@@ -62,7 +78,8 @@ sub new {
$this->{pid} = $pid ;
$this->{socket} = $this->setup_socket(
$port,
- $o->get_java_config('STARTUP_DELAY')
+ $o->get_java_config('STARTUP_DELAY'),
+ 0
) ;
}
@@ -73,26 +90,35 @@ sub new {
sub DESTROY {
my $this = shift ;
- if ($this->{socket}){
- # This asks the Java server to stop and die.
- my $sock = $this->{socket} ;
- if ($sock->connected()){
- print $sock "die\n" ;
- }
- else{
- carp "Lost connection with Java virtual machine" ;
+ if ($this->{owner}){
+ if ($this->{socket}){
+ # This asks the Java server to stop and die.
+ my $sock = $this->{socket} ;
+ if ($sock->connected()){
+ print $sock "die\n" ;
+ }
+ else{
+ carp "Lost connection with Java virtual machine" ;
+ }
+ close($sock) ;
+
+ if ($this->{pid}){
+ # Here we go ahead and send the signals anyway to be very
+ # sure it's dead...
+ # Always be polite first, and then insist.
+ kill(15, $this->{pid}) ;
+ kill(9, $this->{pid}) ;
+
+ # Reap the child...
+ waitpid($this->{pid}, 0) ;
+ }
}
- close($sock) ;
-
- if ($this->{pid}){
- # Here we go ahead and send the signals anyway to be very
- # sure it's dead...
- # Always be polite first, and then insist.
- kill(15, $this->{pid}) ;
- kill(9, $this->{pid}) ;
-
- # Reap the child...
- waitpid($this->{pid}, 0) ;
+ }
+ else{
+ # We are not the JVM owner, so we simply politely disconnect
+ if ($this->{socket}){
+ close($this->{socket}) ;
+ $this->{socket} = undef ;
}
}
@@ -105,6 +131,7 @@ sub setup_socket {
my $this = shift ;
my $port = shift ;
my $timeout = shift ;
+ my $one_shot = shift ;
my $socket = undef ;
my $last_words = "timeout\n" ;
@@ -128,7 +155,7 @@ sub setup_socket {
PeerAddr => 'localhost',
PeerPort => $port,
Proto => 'tcp') ;
- if ($socket){
+ if (($socket)||($one_shot)){
last ;
}
}
@@ -155,6 +182,29 @@ sub setup_socket {
}
+sub reconnect {
+ my $this = shift ;
+
+ if ($this->{JNI}){
+ return ;
+ }
+
+ if ($this->{socket}){
+ # Close the previous socket
+ close($this->{socket}) ;
+ $this->{socket} = undef ;
+ }
+
+ my $socket = $this->setup_socket(
+ $this->{port},
+ 0,
+ 1
+ ) ;
+ $this->{socket} = $socket ;
+ $this->{owner} = 0 ;
+}
+
+
sub process_command {
my $this = shift ;
my $data = shift ;
diff --git a/Java/Protocol.pm b/Java/Protocol.pm
index 335f56f..1ecf930 100644
--- a/Java/Protocol.pm
+++ b/Java/Protocol.pm
@@ -3,7 +3,7 @@ package Inline::Java::Protocol ;
use strict ;
-$Inline::Java::Protocol::VERSION = '0.22' ;
+$Inline::Java::Protocol::VERSION = '0.30' ;
use Inline::Java::Object ;
use Inline::Java::Array ;
@@ -43,14 +43,12 @@ sub ISA {
my $this = shift ;
my $proto = shift ;
- my $id = $this->{obj_priv}->{id} ;
my $class = $this->{obj_priv}->{java_class} ;
Inline::Java::debug("checking if $class is a $proto") ;
my $data = join(" ",
"isa",
- $id,
Inline::Java::Class::ValidateClass($class),
Inline::Java::Class::ValidateClass($proto),
) ;
@@ -59,6 +57,19 @@ sub ISA {
}
+sub ObjectCount {
+ my $this = shift ;
+
+ Inline::Java::debug("getting object count") ;
+
+ my $data = join(" ",
+ "obj_cnt",
+ ) ;
+
+ return $this->Send($data, 1) ;
+}
+
+
# Called to create a Java object
sub CreateJavaObject {
my $this = shift ;
@@ -382,6 +393,9 @@ class InlineJavaProtocol {
else if (c.equals("delete_object")){
DeleteJavaObject(st) ;
}
+ else if (c.equals("obj_cnt")){
+ ObjectCount(st) ;
+ }
else if (c.equals("die")){
ijs.debug(" received a request to die...") ;
System.exit(0) ;
@@ -459,24 +473,21 @@ class InlineJavaProtocol {
void ISA(StringTokenizer st) throws InlineJavaException {
- int id = Integer.parseInt(st.nextToken()) ;
-
String class_name = st.nextToken() ;
Class c = ijc.ValidateClass(class_name) ;
String is_it_a = st.nextToken() ;
Class d = ijc.ValidateClass(is_it_a) ;
- Integer oid = new Integer(id) ;
- Object o = ijs.objects.get(oid) ;
- if (o == null){
- throw new InlineJavaException("Object " + oid.toString() + " is not in HashMap!") ;
- }
-
SetResponse(new Integer(ijc.DoesExtend(c, d))) ;
}
+ void ObjectCount(StringTokenizer st) throws InlineJavaException {
+ SetResponse(new Integer(ijs.ObjectCount())) ;
+ }
+
+
/*
Creates a Java Object with the specified arguments.
*/
@@ -524,11 +535,7 @@ class InlineJavaProtocol {
String class_name = st.nextToken() ;
Object o = null ;
if (id > 0){
- Integer oid = new Integer(id) ;
- o = ijs.objects.get(oid) ;
- if (o == null){
- throw new InlineJavaException("Object " + oid.toString() + " is not in HashMap!") ;
- }
+ o = ijs.GetObject(id) ;
// Use the class of the object
class_name = o.getClass().getName() ;
@@ -577,11 +584,7 @@ class InlineJavaProtocol {
String class_name = st.nextToken() ;
Object o = null ;
if (id > 0){
- Integer oid = new Integer(id) ;
- o = ijs.objects.get(oid) ;
- if (o == null){
- throw new InlineJavaException("Object " + oid.toString() + " is not in HashMap!") ;
- }
+ o = ijs.GetObject(id) ;
// Use the class of the object
class_name = o.getClass().getName() ;
@@ -637,11 +640,7 @@ class InlineJavaProtocol {
String class_name = st.nextToken() ;
Object o = null ;
if (id > 0){
- Integer oid = new Integer(id) ;
- o = ijs.objects.get(oid) ;
- if (o == null){
- throw new InlineJavaException("Object " + oid.toString() + " is not in HashMap!") ;
- }
+ o = ijs.GetObject(id) ;
// Use the class of the object
class_name = o.getClass().getName() ;
@@ -679,8 +678,7 @@ class InlineJavaProtocol {
void DeleteJavaObject(StringTokenizer st) throws InlineJavaException {
int id = Integer.parseInt(st.nextToken()) ;
- Integer oid = new Integer(id) ;
- Object o = ijs.objects.remove(oid) ;
+ Object o = ijs.DeleteObject(id) ;
SetResponse(null) ;
}
@@ -882,7 +880,7 @@ class InlineJavaProtocol {
This sets the response that will be returned to the Perl
script
*/
- void SetResponse (Object o){
+ void SetResponse (Object o) throws InlineJavaException {
if (o == null){
response = "ok undef:" ;
}
@@ -896,10 +894,10 @@ class InlineJavaProtocol {
else {
// Here we need to register the object in order to send
// it back to the Perl script.
- ijs.objects.put(new Integer(ijs.objid), o) ;
- response = "ok object:" + String.valueOf(ijs.objid) +
+ int id = ijs.objid ;
+ ijs.PutObject(id, o) ;
+ response = "ok object:" + String.valueOf(id) +
":" + o.getClass().getName() ;
- ijs.objid++ ;
}
}
diff --git a/MANIFEST b/MANIFEST
index 4c7e691..d3989b6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4,6 +4,8 @@ README
README.JNI
TODO
Makefile.PL
+shared_jvm_test.pl
+shared_jvm_server.pl
Java.pm
Java.pod
Java/Init.pm
diff --git a/README b/README
index 8e11418..c37d04f 100644
--- a/README
+++ b/README
@@ -45,8 +45,9 @@ INSTALLATION:
To install Inline::Java do this:
perl Makefile.PL
-make (see Note 2)
-make test (see Note 3, 4, 5)
+make (see Note 2)
+make test (see Note 3, 4, 5)
+perl shared_jvm_test.pl (see Note 6)
make install
You have to 'make install' before you can run it successfully.
@@ -75,6 +76,10 @@ Note 5: When testing Inline::Java, it's always a good idea to run 'make test'
twice. The first time you test the building and loading of a module, the second
time you test loading of an already built module.
+Note 6: If you plan to use Inline::Java under mod_perl or any other program thgat
+forks, you may wish to run 'perl shared_jvm_test.pl'. This will simulate a forking
+process that uses Inline::Java. Please keep in mind that this test does not work
+under Windows.
-------------------------------------------------------------------------------
FEATURES:
@@ -83,6 +88,12 @@ WARNING: THIS IS ALPHA SOFTWARE. It is incomplete and possibly unreliable.
It is also possible that some elements of the interface (API) will
change in future releases.
+Inline::Java version 0.30 is a major upgrade that includes:
++ Multi-threaded JVM
++ Shared JVM mode for forking programs, i.e. mod_perl
++ Optional test script to simulate forking programs
++ Fixed some memory leaks and made test suite 'leak aware'
+
Inline::Java version 0.23 is a minor upgrade that includes:
+ Support for multiple Inline::Java sections
+ Other minor bug fixes
diff --git a/README.JNI b/README.JNI
index fc0a31c..273305e 100644
--- a/README.JNI
+++ b/README.JNI
@@ -96,3 +96,12 @@ To run Inline::Java with the JNI extension, do one of the following:
- set the JNI configuration option to 1
- set the PERL_INLINE_JAVA_JNI environment variable to 1
+
+USING THE 'SHARED_JVM' MODE
+---------------------------
+
+Inline::Java 0.30 introduced a 'SHARED_JVM' mode that allows many clients to connect
+to the same Inline::Java Java server. The 'SHARED_JVM' mode is meant to be used with
+forking processes such as Apache with mod_perl. The 'SHARED_JVM' mode does NOT work
+along with the JNI mode. In fact the author was not able to successfully fork the Java
+Virtual Machine under any circumstances.
diff --git a/t/02_primitives.t b/t/02_primitives.t
index 11d04a2..c2d4040 100644
--- a/t/02_primitives.t
+++ b/t/02_primitives.t
@@ -160,7 +160,7 @@ ok($t->__get_private()->{proto}->ObjectCount(), 1) ;
-__DATA__
+__END__
__Java__
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libinline-java-perl.git
More information about the Pkg-perl-cvs-commits
mailing list