I am looking for a solution (best example code) how to implement an register a Java Program as (D)COM Server/Service. More concise I have the following issue:
Initially situation is:
(a) I have a Java Webservice (Axis) pulling in Data from the Web.
(b) I have a 3rd Party service (written in Delphi) which wants the
data from a COM-Object and is periodically calling this (the
interface, which methods of the COM Object are called, is specified).
In order to get the data from (a) to (b), I need to implement a COM-Server which provids the needed methods for (b) to retrieve its data.
The main Question I have is:
How can I make and register the Java Service as a COM-Object and provide the needed methods so that (b) get its data when calling.
I know Java, but I am no expert to (D)COM. So, forgive me possible technical error concerning COM.
Searching the Web I found several tools/frameworks (e.g. JInterop) that allow a Java Program to interact with a COM-Object, but I did not found code etc. how to make a Java Program accessible via (D)COM.
First, take a look on using Java Servers and DCOM. An example is idl server. Also, you can see services tutorial.
Related
Update: Jun 10, 2022
I have successfully been able to create a demo application with AspectJ integration that could extract variables from the demo application. It was quite a hassle since there's a bit of trouble going on with Eclipse AJDT integration.
I was able to use CLI Java and ajc (AspectJ compiler) to achieve binary weaving into my demo application.
Original Question:
I am trying to retrieve real-time data from a running Java application and push it into an API I have on a server.|
I have no access to the source code of the running application; I only have the Jar file. I have tried decompilation into .java files; however, due to the scale of the app, I was not able to fix all of the missing access$000 function calls.
Is there a certain approach I should use when retrieving real-time data from an existing Java application? Has that been done before? Am I missing something that I am not aware of?
Any help is appreciated.
This is big challenge obviously. If you can glean enough understanding of how the program works from decompiling and reading log files to target some methods where you suspect there's data of interest to your API, then I would read up about Aspect Oriented Programming [AOP] and use those tools.
With AOP you can modify the classes in the jar file at runtime as its loaded by the JVM and access the classes.
For example: You can gather data from:
fields within the class that owns a method
parameters passed to a method
value returned from a method
Once you gather the data, you can also insert calls to your API.
Here's a place to start - https://www.baeldung.com/aspectj .
So I have written a few Java classes that take input via the main method as passed arguments and then print to the screen. Is there any way I can 'port' this to something I can include in the HTML of a web document? There are multiple classes that work together so I would need some way of including all of these and forcing one specific file to run. For example, if I have Class1.java and Class2.java I would want to run Class1.java but somehow the second class must be included as the first relies on it.
I understand that this is probably not as simple as I'm making it, for example there may be complications with changing stdout to use the application screen etc, but anything that can get me started would be helpful.
Thanks!
The closest fit to what you are asking for is something called CGI, which is a technology that was popular 15 years ago, but is rarely used now. The next best fit would be to wrap your classes in something that can run in a java servlet container.
Simply put, instead of taking arguments in on the main method, you would accept them as URL parameters. Instead of printing to stdout, you would print to a special stream that sends the content over a socket to a web browser. There are many fine tutorials on the web for creating servlets. I like this one: http://helloworldprograms.blogspot.com/2010/08/servlet-hello-world.html
I have an embedded system using a python interface. Currently the system is using a (system-local) XML-file to persist data in case the system gets turned off. But normally the system is running the entire time. When the system starts, the XML-file is read in and information is stored in python-objects. The information then is used for processing. My aim is to edit this information remotely (over TCP/IP) even during process. I would like to use JAVA to get this done, and i have been thinking about something to share the objects. The problem is, that I'm missing some keywords to find the right technologies to get this done. What i found is SOAP, but i think it is not the right thing for this case, is that true? I'm grateful for any tips.
As I understand, you are using XML file to store start up configuration
And my assumptions on your interface between Java & Python apps
You want your Java application to retrieve objects over Python interface
And process them locally and send it back to Python interface to reload config ?
So, depending on your circumstances, you can workout something with the following
Jython
Pickle (if you have no restriction on startup config file format or can afford to do conversion)
https://pypi.python.org/pypi/Pyro4
Also you can get some ideas from here:
Sharing a complex object between Python processes?
You should ask your python application to open a XML-RPC socket which clients can connect on. This could let an outside application to execute an endpoint, which would manipulate your python object values in someway. There are several good choices for Java XML-RPC libraries, including the amazing org.apache.xmlrpc library.
Friends,
I'm working on a requirement where I need to call a Java API from Apex.
The solution I put forward was to create a Java class, store it the database and add a PL/SQL wrapper and then use it. Which is pretty much what is described here.
Whilst I am happy with this, I am interested to know if this is the only method? are there other options that I could explore?
Thanks in advance
From what I've seen, APEX doesn't have anything special for calling Java Stored Procedures.
So it's the same thing as calling a Java SP from within PL/SQL.
As can be seen here there is no other way of doing it beside the one you use now.
I would just add that what you actually call a wrapper is in fact the way a Java SP is published to the data dictionary(it makes it available to the SQL/PLSQL contexts). In your case you do it by defining a top-level call specification. Alternatively you can publish it by defining either a package or an object type call specification. For more details see this link.
I'm not an experienced java developer so any comment will be welcomed ...
I've written a web service using c# and I wanted to consume this service from java - used Netbeans for this task.
All methods works well beside one: the method expecting a type called BusinessDataField2 - this type contains 2 fields: name(string) and value(object)
Those fields are filled using get,set methods - this works easily at the .NET environment.
However ...
I can see that Java requires different parameters for the get and set methods - the parameter is :
JAXBElement
JAXBElement
The question is: how do I instantiate this object? I tried many different ways but nothing worked...
Thanks,
ofer
You should not use the "object" type. It could be any actual type, but you're not telling the Java side what to expect. The best it can do, then, is process the actual XML of the value.
Consider: the object could be an int, or it could be some complex structure. How would the Java side know what to do with it? The Java side wouldn't even have a proxy classs for the complex structure, because you never told it that you could ever return the complex structure.
I'd recommend using the CXF web service framework to consume your web service. It can look at your wsdl file and generate java objects that correspond to your .net objects.
They have a HOWTO on their site as well.