Jay, You need to use the Inline::Java::PerlInterpreter for that: http://search.cpan.org/~patl/Inline-Java-0.53/Java/PerlInterpreter/PerlInterpreter.pod
Once your interpreter is created you can call Callback methods on it: require, CallPerlSub, eval... Note: Keep in mind that Inline::Java::PerlInterpreter is experimental, so YMMV. Patrick On Wed, Jan 12, 2011 at 1:01 PM, Jay Strauss <m...@heyjay.com> wrote: > Hi, > > 2 questions: > > 1) why do call yourself Sisyphus? Is it really all for meaningless, endless > :) > > 2) I'd like to call some perl from a running Java process. I'm using a > vendor api and framework to build custom code. The way it works is I have > to write some java (see below), then compile within Eclipse using a supplied > Ant xml, which turns my code into a Jar that is deployed onto the server. > The vendor's Java app reads a DB that indicates where the Jar is located > and the class and method to call under various situations. > > I've written a Inline::Java callback in the past, but it was initiated via > Perl. That is, I launched a perl process, that then instantiated some Java > that in turn called back into the perl. > > In reading the callback docs I can't seem to grok how to make it all happen > from Java and my Jar correctly. > > Below is the code. > > Any guidance would be hugely appreciated. > > Thanks > Jay > > // this is just some test code > // that doesn't really do anything but write to a file > > package com.my.stuff; > import java.io.*; > import vendorapi.mpi.*; > import vendorapi.handler.*; > import java.util.Map; > import java.util.Date; > import java.text.SimpleDateFormat; > > public class FileHandler extends HandlerExtBase > { > // Class-specific members used as keys in the handlerArgs to identify > // the pre and post-ixn filename(s) > > private static final String ARG_PREFILENAME = "preFileName"; > private static final String ARG_POSTFILENAME = "postFileName"; > // Instance-specific members initialized during the overridden init() > method > > private String preFileName = null; > private String postFileName = null; > public void init(Context ctx, String handlerArgs) > { > Map<?, ?> argsMap = parseArgs(handlerArgs); > String madHomeDir = System.getenv("MAD_HOMEDIR"); > > // Create the pre- and post- files in the MAD_HOMEDIR directory > > if (argsMap.containsKey(ARG_PREFILENAME)) > { > preFileName = madHomeDir + File.separator + "log" + File.separator + > (String)argsMap.get(ARG_PREFILENAME); > } > > if (argsMap.containsKey(ARG_POSTFILENAME)) > { > postFileName = madHomeDir + File.separator + "log" + File.separator + > (String)argsMap.get(ARG_POSTFILENAME); > } > } > > protected void writeFile(String fileName, RowList rowList) > { > > Date todaysDate = new java.util.Date(); > SimpleDateFormat formatter = new SimpleDateFormat(); > String formattedDate = formatter.format(todaysDate); > > PrintWriter out = null; > try { > out = new PrintWriter(new BufferedWriter(new FileWriter("c:\\" + > formattedDate + ".txt"))); > out.println(formattedDate); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > // > // I'd like to call Perl at this point and have Perl be > // able to access the RowList instance, so Perl could walk > // the list. As opposed to flattening the list in someway > // and shelling out and passing in the flattened list > // > // > > public void preIxn(IService service) throws CallbackHandlerException > { > if (preFileName != null) > { > writeFile(preFileName, service.getInpMemRowList()); > } > > } > > public void postIxn(IService service) throws CallbackHandlerException > { > > if (postFileName != null) > { > writeFile(postFileName, service.getOutMemRowList()); > } > > } > } > -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada