Java macros with Axis tools are sooooo slow...

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Psycrow
Posts: 9
Joined: Tue Jul 29, 2008 10:43 am
Location: South of France

Java macros with Axis tools are sooooo slow...

Post by Psycrow »

Hi there,

I am currently writing some Java macros for Writer. Those macros are using the Axis API to access some web services (locally right now for test purpose). All the required dependencies are packed in the .odt file.

The matter is that when I execute a macro (one of those using some web services) it takes about 50 seconds to display a result (the expected result, at least...), while OOo is completely stunned.

On the other side, the same macro code completes in less that 1 second when executed outside OOo (under Eclipse for instance).
Some tests showed me that all the calls to the Axis library take about 20 seconds to complete when ran under OOo :/

a code sample :

Code: Select all

public static void tryWS(XScriptContext xScriptContext) throws Exception, ServiceException, RemoteException {

      String output = "";

// Using Axis generated classes (taking about 20secs under OOo)
      BureautiqueService bs = new BureautiqueServiceLocator();
      BureautiqueServicePortType port = bs.getBureautiqueServiceHttpPort();

// WebService call (taking about 30secs under OOo)
      String[] res = port.lireSections();

// Packing results in a single string
      for (String elem : res) {
         output += elem + "\n";
      }

// Now printing the result in a Writer opened document
      XModel xDocModel = xScriptContext.getDocument();
// getting the text document object
      XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xDocModel);
      XText xText = xtextdocument.getText();
      XTextRange xTextRange = xText.getEnd();
      xTextRange.setString("\nRésultat de l'appel de 'lireSections()' :" + "\n" + output);
   }
Do I miss something obvious ? Does Axis and OOo refuse to cooperate ?
Can anyone help me on that trick ? :?

Thanks by advance.
OOo 3.0.X on Mac OSx Leopard + M$WindowsXP @work
Psycrow
Posts: 9
Joined: Tue Jul 29, 2008 10:43 am
Location: South of France

Different execution times depending how I launch a macro

Post by Psycrow »

UP !

I still have the same problem with OOo running macros which depends on Web Services access libraries.

I have profiled the OOo JVM running the slow macros, and something strange appeared when I use the BeanShell langage :
A new thread is created each time I run the macro the usual way (using a toolbar shortcut or the Tools>>Macros>>Run macros... item), but if I run the macros via the run button of the BeanShell editor, then no new thread is created but the AWT eventQueue thread is used instead.

As a consequence, the execution time is about 1 minute the first time I launch the macro, but all the next times, no matter how I try to launch the macro , it takes only 1 second to execute !

I still don't understand why, so I can't use that trick yet to have a decent execution time.

It's my last try to catch some help around this topic on that forum, so please if anyone has an idea, post it as a reply !
Thanks by advance for your help.
OOo 3.0.X on Mac OSx Leopard + M$WindowsXP @work
Post Reply