1 /*
2  * See self_run.pl for how this gets called from Perl
3  *
4  * It gets compiled like:
5  *
6  *	javac -classpath .:/path/to/JavaServer/JavaServer.jar SelfRunning.java
7  *
8  * & JavaServer gets started like
9  *
10  *	java -cp /path/to/JavaServer/JavaServer.jar:/path/to/SelfRunning.class JavaServer
11  *
12  */
13 
14 public class SelfRunning {
15 
16     Callback p;
17     public String perl_code = "package SelfRunning; sub toUp { my $var = shift;  print \"In SelfRunning::toUp - got $var!\n\";  uc $var; } sub toLo { lc shift; } 1;";
18 
19 	/*
20 	 * This class gets instantiated by Perl
21 	 */
SelfRunning(Callback p)22     public SelfRunning(Callback p)
23    {
24         this.p=p;
25     }
26 
27 	/*
28 	 * Have at it
29 	 */
go()30     public void go()
31 	{
32 		// First load up our stuff
33 		p.eval(perl_code);
34 
35 		// Let's call 'em!
36 
37 		String test = "tEsT";
38 
39 		String up = p.eval("&SelfRunning::toUp("+test+")");
40 		String down = p.eval("&SelfRunning::toLo("+test+")");
41 
42 		System.out.println("Original: "+test);
43 		System.out.println("Upper Case: "+up);
44 		System.out.println("Lower Case: "+down);
45 
46       }
47 }
48 
49