General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Calling Java classes from XMetaL
-
paul_cpwr December 11, 2008 at 11:36 pm
Calling Java classes from XMetaL
December 11, 2008 at 11:36 pmParticipants 7Replies 8Last Activity 14 years, 3 months agoWe 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 Corporationgihyunlee December 12, 2008 at 11:11 pm
Reply to: Calling Java classes from XMetaL
December 12, 2008 at 11:11 pmIf 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.
paul_cpwr December 13, 2008 at 12:11 am
Reply to: Calling Java classes from XMetaL
December 13, 2008 at 12:11 amMy 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 CorporationDerek Read January 16, 2009 at 1:39 am
Reply to: Calling Java classes from XMetaL
January 16, 2009 at 1:39 amGoing 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.
paul_cpwr January 16, 2009 at 5:02 pm
Reply to: Calling Java classes from XMetaL
January 16, 2009 at 5:02 pmThe 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.
Derek Read January 16, 2009 at 7:28 pm
Reply to: Calling Java classes from XMetaL
January 16, 2009 at 7:28 pmSounds like a really smart (and inexpensive) idea to me if you can get it working.
jsmart February 12, 2009 at 11:57 pm
Reply to: Calling Java classes from XMetaL
February 12, 2009 at 11:57 pmForget 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].Ying_Wu January 12, 2010 at 1:39 pm
Reply to: Calling Java classes from XMetaL
January 12, 2010 at 1:39 pmWe 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
Derek Read January 12, 2010 at 11:44 pm
Reply to: Calling Java classes from XMetaL
January 12, 2010 at 11:44 pmIt 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.” -
AuthorPosts
- You must be logged in to reply to this topic.