[libinline-java-perl] 321/398: v0.48_92
Jonas Smedegaard
dr at jones.dk
Thu Feb 26 11:43:19 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 170fc1bbc760f77b3c987f46306aa729a2449ed5
Author: patrick_leb <>
Date: Wed May 5 20:30:39 2004 +0000
v0.48_92
---
CHANGES | 1 +
Java.pm | 1 +
Java.pod | 39 +++++++++++++++++++++++++++++++++++++++
Java/JVM.pm | 25 ++++++++++++++++++-------
README | 1 +
5 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/CHANGES b/CHANGES
index 526930b..ec43065 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@ Revision history for Perl extension Inline::Java
- Renamed PerlNatives stuff
- Split and updated documentation
- Applied JNI memory leak patch by Jeff Janes
+ - Added external command line tool to start/stop a SHARED_JVM server
0.47 Sat Feb 14 10:00:00 EST 2004
- Fixed bugs in portability code and added HPUX, AIX and Solaris specifics
diff --git a/Java.pm b/Java.pm
index eb7372a..9aa4b64 100644
--- a/Java.pm
+++ b/Java.pm
@@ -138,6 +138,7 @@ sub validate {
$o->set_option('PORT', -1, 'i', 1, \%opts) ;
$o->set_option('STARTUP_DELAY', 15, 'i', 1, \%opts) ;
$o->set_option('SHARED_JVM', 0, 'b', 1, \%opts) ;
+ $o->set_option('START_JVM', 1, 'b', 1, \%opts) ;
$o->set_option('JNI', 0, 'b', 1, \%opts) ;
$o->set_option('EMBEDDED_JNI', 0, 'b', 1, \%opts) ;
diff --git a/Java.pod b/Java.pod
index 4593306..0ae582b 100644
--- a/Java.pod
+++ b/Java.pod
@@ -218,6 +218,19 @@ 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.
+=item START_JVM
+
+When used with SHARED_JVM, tells C<Inline::Java> that JVM should
+already be running and that it should not attempt to start a new
+one. This option is useful in combination with command line interface
+described in the BUGS AND DEFICIENCIES section. Default is 1.
+
+ Ex: START_JVM => 0
+
+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.
+
=item PRIVATE
In SHARED_JVM mode, makes every connection to the JVM use a different
@@ -863,6 +876,9 @@ option enabled, will try to connect to the already existing JVM before
trying to start a new one. Therefore if the JVM happens to crash or is
killed, the next CGI that runs will start a new one. The JVM will be
killed when Apache is shut down.
+
+See the BUGS AND DEFICIENCIES section if you have problems starting
+the SHARED_JVM server in a CGI.
Z<>
@@ -899,6 +915,9 @@ Here is an example of how to use C<Inline::Java> under mod_perl:
}
See USING Inline::Java IN A CGI for more details.
+
+See the BUGS AND DEFICIENCIES section if you have problems starting
+the SHARED_JVM server under MOD_PERL.
Z<>
@@ -927,6 +946,26 @@ If you upgrade C<Inline::Java> from a previous version, be sure to delete
your _Inline directory so that C<Inline::Java>'s own Java classes get
rebuilt to match the Perl code.
+=item 3
+
+Under certain environments, i.e. CGI or mod_perl, the JVM cannot start
+properly because of the way these environments set up STDIN and STDOUT.
+In these cases, you maybe wish to control the JVM (in shared mode) manually
+using the following commands:
+
+ % perl -MInline::Java::Server=status
+ % perl -MInline::Java::Server=start
+ % perl -MInline::Java::Server=stop
+ % perl -MInline::Java::Server=restat
+
+You can't specify C<Inline::Java> options by setting the proper
+environment variables. You can also set the _Inline directory by setting
+the PERL_INLINE_JAVA_DIRECTORY environment variable.
+
+In addition, you may also wish to set the START_JVM option to 0 in your scripts
+to prevent them from trying to start their own JVM if they can't find one,
+thereby causing problems.
+
=back
diff --git a/Java/JVM.pm b/Java/JVM.pm
index ec15187..07aff53 100644
--- a/Java/JVM.pm
+++ b/Java/JVM.pm
@@ -3,11 +3,11 @@ package Inline::Java::JVM ;
use strict ;
use Carp ;
-use IPC::Open3 ;
use IO::File ;
+use IPC::Open3 ;
use IO::Socket ;
-$Inline::Java::JVM::VERSION = '0.48_91' ;
+$Inline::Java::JVM::VERSION = '0.48_92' ;
my %SIGS = () ;
@@ -62,6 +62,7 @@ sub new {
my $debug = Inline::Java::get_DEBUG() ;
$this->{shared} = $o->get_java_config('SHARED_JVM') ;
+ $this->{start_jvm} = $o->get_java_config('START_JVM') ;
$this->{port} = $o->get_java_config('PORT') ;
$this->{host} = "localhost" ;
@@ -101,6 +102,10 @@ sub new {
Inline::Java::debug(1, "connected to already running JVM!") ;
return $this ;
}
+
+ if (! $this->{start_jvm}){
+ croak("Can't find running JVM and START_JVM = 0") ;
+ }
}
my $java = File::Spec->catfile($o->get_java_config('J2SDK'), 'bin',
@@ -117,7 +122,7 @@ sub new {
my $pid = 0 ;
eval {
- $pid = $this->launch($cmd) ;
+ $pid = $this->launch($o, $cmd) ;
} ;
croak "Can't exec JVM: $@" if $@ ;
@@ -130,7 +135,7 @@ sub new {
}
$this->{pid} = $pid ;
- $this->{socket} = $this->setup_socket(
+ $this->{socket} = setup_socket(
$this->{host},
$this->{port},
# Give the user an extra hour's time set breakpoints and the like...
@@ -145,6 +150,7 @@ sub new {
sub launch {
my $this = shift ;
+ my $o = shift ;
my $cmd = shift ;
local $SIG{__WARN__} = sub {} ;
@@ -154,6 +160,7 @@ sub launch {
if (! defined($in)){
croak "Can't open $dn for reading" ;
}
+
my $out = ">&STDOUT" ;
if ($this->{shared}){
$out = new IO::File(">$dn") ;
@@ -161,7 +168,10 @@ sub launch {
croak "Can't open $dn for writing" ;
}
}
- my $pid = open3($in, $out, ">&STDERR", $cmd) ;
+
+ my $err = ">&STDERR" ;
+
+ my $pid = open3($in, $out, $err, $cmd) ;
if (! $this->{debugger}){
close($in) ;
@@ -240,8 +250,9 @@ sub shutdown {
}
+# This cannot be a member function because it can be used
+# elsewhere to connect to the JVM.
sub setup_socket {
- my $this = shift ;
my $host = shift ;
my $port = shift ;
my $timeout = shift ;
@@ -315,7 +326,7 @@ sub reconnect {
$this->{socket} = undef ;
}
- my $socket = $this->setup_socket(
+ my $socket = setup_socket(
$this->{host},
$this->{port},
0,
diff --git a/README b/README
index c96dd05..857a363 100644
--- a/README
+++ b/README
@@ -71,6 +71,7 @@ Inline::Java version 0.49 is a major upgrade that includes:
- Renamed PerlNatives stuff
- Split and updated documentation
- Applied JNI memory leak patch by Jeff Janes
+ - Added external command line tool to start/stop a SHARED_JVM server
See CHANGES for a full change list.
--
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