General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Calling Java classes from XMetaL

  • paul_cpwr

    Calling Java classes from XMetaL

    Participants 7
    Replies 8
    Last Activity 13 years, 6 months ago

    We would like to leverage a Java program as a part of our XMetaL workflow. Specifically, we want a macro in XMetaL to invoke an external Java class and act on the return value. JScript and VBScript are not well suited to this task. Has anybody used the Python or Perl script support in XMetaL (according to the data sheet) to invoke external Java classes?

    Alternatively, is there some other better solution?

    Thank you for your help.

    Best regards,

    Paul Anderson
    Compuware Corporation

    Reply

    gihyunlee

    Reply to: Calling Java classes from XMetaL

    If you are set in using Java, I believe you can do this using the XMetaL Java API Toolkit.

    If you are open to options, you can create a ActiveX control (using say C#) which I integrates easily into XMetaL. 

    I'm mainly a Java developer but the C#/ActiveX route was much simpler to implement and integrate with our XMetaL customizations.

    Reply

    paul_cpwr

    Reply to: Calling Java classes from XMetaL

    My understanding is that the XMetaL Java API Toolkit is an API for using Java code to access XMetaL. I want the opposite. I need XMetaL customizations to call external Java methods and act on the returns from those methods.

    More specifically, we have an desktop Java application that we need to integrate with our XMetaL customizations. I'd prefer to access it directly via Java but this is impossible via VBScript and JScript. I'm looking into the possibility of embedding Java into Perl (Inline::Java module) and running the Perl script in XMetaL. The other possibility is using Python and JPype to access Java classes from a Python script that could be run from within XMetaL.

    Best regards,

    Paul Anderson
    Compuware Corporation

    Reply

    Derek Read

    Reply to: Calling Java classes from XMetaL

    Going from XMetaL (which is COM based) to Java requires the use of “COM to Java bridge” software. I believe there are several solutions available on the market.

    Reply

    paul_cpwr

    Reply to: Calling Java classes from XMetaL

    The Java-to-COM bridge is certainly a possibility. Unfortunately, the robust implementations of these tools are all commercial and some of them are rather expensive.

    Since we can control the code in the Java application that is the target of the integration, we have devised a new strategy. We will code a component in the Java application that will expose itself as a web service (or web container/servlet). Then we'll edit our XMetaL JScript use the Microsoft.XMLHTTP ActiveXObject, available in JScript, to call the webservice/servlet and act on the response.

    We have yet to implement this solution, though it appears that other JScript developers have been able to make this work.

    Reply

    Derek Read

    Reply to: Calling Java classes from XMetaL

    Sounds like a really smart (and inexpensive) idea to me if you can get it working.

    Reply

    jsmart

    Reply to: Calling Java classes from XMetaL

    Forget Java – the answer is in the Journalist COM sample. The
    COM allows developers to link to the Class Library.  Our
    team has done extensions with COM for Grammar Checks, Content tagging
    and Translations. Results in COM are very fast performance,
    Java is too slow.
    We are happy to share the simple COM tricks or custom development
    offline send mail to [email protected].

    Reply

    Ying_Wu

    Reply to: Calling Java classes from XMetaL

    We are trying to customize XMetaL to call Java methods.  The Java class Jar file and XMetaL are installed on the same computer.   

    Does anyone have experience calling Java in XMetaL with any script language?

    Thanks.  Ying Wu, LexisNexis

    Reply

    Derek Read

    Reply to: Calling Java classes from XMetaL

    It might be possible to use one of the browser-based methods that you will find if you search for “javascript to java communication” or “java to javascript communication”.

    From the XMetaL Author side you can use XMetaL Author's APIs to navigate to an HTML page in the Resource Manager (ResourceManager.Assets.WebBrowser), or embed IE in a new tab (ResourceManager.AddTab()) and then use IE's native Navigate() method to open an HTML page (effectively the same result but on a different tab than the Assets tab).

    Regardless of where the HTML page is, it could have a Java applet embedded in it, and the methods for communicating between Java and javascript (my first paragraph) might then be useful (though in the case of IE it is really actually JScript). In order to communicate between the HTML page itself and XMetaL Author you would then need to instantiate XMetaL Author using COM from the HTML page in order to pass messages to it (this is not handled automatically just because IE is embedded within the Resource Manager).

    I have not actually tried to do these things so I'm not sure how difficult it would be to actually implement this or that it could really work. However, perhaps others reading this forum have and can help out.

    The following projects may also help (keeping in mind that XMetaL Author is a COM server):

    com4j
    https://com4j.dev.java.net/
    “The goal of the project is to provide a better integration of Java and COM. “

    j-Interop
    http://sourceforge.net/projects/j-interop/
    “Implementation of DCOM wire protocol (MSRPC) to enable development of Pure Bi-Directional, Non-Native Java applications which can interoperate with any COM component. The implementation is itself purely in Java and does not use JNI to provide COM access.”

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support