[libinline-java-perl] 332/398: ok

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:43:20 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 fc9fa61151e87d30f87f872647d4ae0d9c2fbc88
Author: patrick_leb <>
Date:   Mon Jun 21 12:59:48 2004 +0000

    ok
---
 Java/Server.pm | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 128 insertions(+)

diff --git a/Java/Server.pm b/Java/Server.pm
new file mode 100644
index 0000000..87921b9
--- /dev/null
+++ b/Java/Server.pm
@@ -0,0 +1,128 @@
+package Inline::Java::Server ;
+ at Inline::Java::Server::ISA = qw(Exporter) ;
+
+# Export the cast function if wanted
+ at EXPORT_OK = qw(start stop status) ;
+
+
+use strict ;
+use Exporter ;
+use Carp ;
+require Inline ;
+require Inline::Java ;
+use File::Spec ;
+
+
+$Inline::Java::Server::VERSION = '0.48_95' ;
+
+
+# Create a dummy Inline::Java object in order to 
+# get the default options.
+my $IJ = bless({}, "Inline::Java") ;
+$IJ->validate(
+	SHARED_JVM => 1
+) ;
+
+
+
+sub import {
+	my $class = shift ;
+	my $a = shift ;
+
+	my @actions = () ;
+	if ($a eq 'restart'){
+		push @actions, 'stop', 'sleep', 'start' ;
+	}
+	else{
+		push @actions, $a ;
+	}
+
+	my $port = $IJ->get_java_config("PORT") ;
+	foreach $a (@actions){
+		if ($a eq 'sleep'){
+			sleep(5) ;
+			next ;
+		}
+
+		my $status = Inline::Java::Server::status() ;
+
+		if ($a eq 'start'){
+			if ($status){
+				print "SHARED_JVM server on port $port is already running\n" ;
+			}
+			else{
+				Inline::Java::Server::start() ;
+				my $pid = Inline::Java::__get_JVM()->{pid} ;
+				print "SHARED_JVM server on port $port started with pid $pid\n" ;
+			}
+		}
+		elsif ($a eq 'stop'){
+			if (! $status){
+				print "SHARED_JVM server on port $port is not running\n" ;
+			}
+			else {
+				Inline::Java::Server::stop() ;
+				print "SHARED_JVM server on port $port stopped\n" ;
+			}
+		}
+		elsif ($a eq 'status'){
+			if ($status){
+				print "SHARED_JVM on port $port is running\n" ;
+			}
+			else {
+				print "SHARED_JVM on port $port is not running\n" ;
+			}
+		}
+		else{
+			croak("Usage: perl -MInline::Java::Server=(start|stop|restart|status)\n") ;
+		}
+	}
+
+	exit() ;
+}
+
+
+
+sub status {
+	my $socket = undef ;
+
+	eval {
+	    $socket = Inline::Java::JVM::setup_socket(
+	        "localhost",
+			$IJ->get_java_config("PORT"),
+			0,
+			1
+	    ) ;
+	} ;
+	if ($@){
+		return 0 ;
+	}
+	else {
+		close($socket) ;
+		return 1 ;
+	}
+}
+
+
+sub start {
+	my $dir = $ENV{PERL_INLINE_JAVA_DIRECTORY} ;
+
+	Inline->bind(
+		Java => 'STUDY',
+		SHARED_JVM => 1,
+		($dir ? (DIRECTORY => $dir) : ()),
+	) ;
+}
+
+
+sub stop {
+	# This will connect us to the running JVM
+	Inline::Java::Server::start() ; 
+	Inline::Java::capture_JVM() ; 
+	Inline::Java::shutdown_JVM() ; 
+}
+
+
+
+1 ;
+

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