We would like to give access to some of our EJBs from Excel. The goal is to give an API usable from VBA.
Our EJBs are mostly Stateless Session Beans that do simple CRUD operations with POJOs.
Some possible solutions:
Exposing the EJBs as WebServices and create a VB/C# dll wrapping them,
Using Corba to access the EJBs from C#,
Creating a COM Library that uses Java to access the EJBs,
Pointers to frameworks for these solution or other ideas are welcome.
You could take a look at IIOP.NET, which addresses this issue.
If you have a fairly recent ejb container, the cheapest and easiest should be to expose your beans as web services and call it from VB/C#. This doesn't require any extra tool or library.
I work on an open source project called XLLoop - this framework allows you to expose POJO functions as Excel functions.
It consists of:
An Excel add-in (XLL), which communicates over TCP to:
A Java server/library, which invokes java methods.
You could embed this java function server in an EJB and have it deployed as part of your app server.
Back in the VB6/COM/DCOM times we used the suite J-Integra to accomblish this task. I have no experience with the .NET version though.
I highly recommend IKVM. It is a java byte code to .NET assembly compiler (i.e. JAR --> DLL) and I have used it to create live JMX links and listeners in an Excel automation server. It should not be difficult for you to create a .NET assembly of your EJB client stubs and supporting libraries.
//Nicholas
You could try Obba (I work on this project):
Obba is a Java object handler for spreadsheet applications.
It provides a bridge between spreadsheets and Java classes, such that spreadsheets can be used as graphical user interface for Java libraries. Accessing your Java library form the spreadsheet requires no glue code (no VBA needed, no special Java code needed). Objects are instantiated by their original constructor. Constructors and methods are invoked using a "by name" reflection. A spreadsheet-specific factory method is not necessary. Obba provides the functions to handle objects in spreadsheets.
The Java virtual machine providing the add-in may run on the same computer or a remote computer - without any change to the spreadsheet, i.e., object referenced in the spreadsheet can reside on remote Java virtual machine.
Related
I'm using JACOB in order to write message to a COM interface.
Dispatch dispatch = new Dispatch("<Interface Name>");
Variant response = Dispatch.call(dispatch, <DISPID>, message);
This works perfectly on localhost. But how can I use JACOB api to call interface on some other Machine/IP Address
JACOB seems to be unable to remotely access (DCOM call).
JACOB Project mailing-list FAQ
Can I call COM component across machines or operating systems?
The answer to this question is No. The way jacob is implemented is using JNI and a c++ DLL designed for the windows platform. COM is a binary standard defined by Microsoft as it hasn’t been ported over (as far as I know) to any other platforms yet. Jacob is only a java bridge for COM which defines how components talk to each other when they are on the same machine. The DCOM standard defines how components communicate across networks, but Jacob has no support for DCOM.
Solutions:
Commercial products, like J-Integra support the DCOM protocol natively.
Use RMI. Make a wrapper for the Jacob classes, and RMI'ify it. It actually works, but the Jacob lead didn't want to make the classes implement serializable, making the whole operation slightly difficult.
Use Web Services. Expose the stuff you'd like to have as a Web Service, and use SOAP and snacks on the Java side to access it.
Alternatively, it may be useful if the locally working COM object supports remote access internally.
It seems like the following article.
Jacob connect to Remote Computer for WMI support
ADODB Recordset Example
The JACOB Project: A JAva-COM Bridge
Downloads
The JACOB binary distribution (jacobBin_XX.zip) includes:
jacob.jar: a JAR file for the java classes which you must add to your CLASSPATH. The package names replace com.ms with com.jacob (for example com.ms.com.Variant maps to com.jacob.com.Variant.
jacob.dll: a small Win32 DLL which you must add to your PATH.
samples: provided in Java source and compiled form to demonstrate various features of the product. In particular, a set of wrapper classes for Microsoft® ADO are provided as samples.
The source code is available in the JACOB source distribution (jacobSrc_XX.zip), which includes both the Java and C++ code. The source distribution is a superset of the binary one, so you don't need both.
Others seem to have other libraries, not JACOB.
A pure Java DCOM Bridge with j-interop
j-interop/j-interop/src/readme.htm
In Addition:
Similarly, it can not be called between computers connected via LAN.
Also, it is not possible to call local COM objects remotely with VC ++ or .NET language.
The workaround is to create a proxy application to call the local COM object on the remote computer.
Design the main application and the proxy application arbitrarily so that they can communicate with each other using a socket or other means.
I have a java based software and my client wants to load some data to the software using a different tool. I need to write a java module that can speak with both and acts as a mediator. How do I pass inputs from 3rd party tool to the my java based software?
If I could invoke any class(in java based software) from eclipse using the remote invocation then it would suffice my need.
I have never worked on remote invocation.
Well, you could look into using Java RMI.
However, this is usually done with Web Service http calls now.
I think most people would recommend using a RESTful solution and passing JSON representations of your objects back and forth between the two distributed systems.
I'm debating whether I should use java RMI or standard Java networking for an application i'm working on.
The app will be a networked system that has heartbeat sensors and failsafe-features. So it's a 3-tiered system, with at least a DB and java application.
So if my Database fails on one machine, I'd like the 2nd machine to "sense" this.
I'm a bit confused about Java RMI, whether it's worth it to learn it.
Or if I use standard Java networking , I can do the same as RMI? I mean, if I really know the Java networking well.
Thanks!
These days it is pretty easy to set up web services using SOAP or REST. With REST you can use XML or JSON messages without really having to know all about it. All these types of services can be accessed from .NET code or PHP or Javascript. (Well ... SOAP is sort of a pain except in .NET and Java. //personal opinion )
Spring can help you set up a service and a client interface to it is pretty easy. Fairly close to standard Annotations on bean classes and business methods define the interfaces and Spring does the heavy lifting. (I'm talking about Spring Web Services and not the Spring Remoting, though that would work as well. Spring Remoting isn't much better than RMI IMHO.)
You can also use Jersey (JAX-WS) or Jackson (Parse JSON) to do the remoting. Standard Annotations on bean classes and what-not build the interfaces. CXF will do JAX-WS and JAX-RS as well. Those are Java standards for building services and clients that communicate via remote messages.
Alternatively there are eclipse tools for generating both sides of the remote interface. All are tied to some framework (Axis-2 or CXS are some). Its sort of a code generation thing.
You might want to look into these a bit and see which one resonates with the way you look at things.
I know that I prefer all of these over using RMI. But I haven't used RMI directly in a long time.
RMI is higher level protocol compared to the bare TCP/IP support in Java via Socket class that you seem to refer to as "Java networking". If the only thing your system does is sending heartbeats and there are just few nodes you should choose RMI for simplicity reasons. As all of the participants are JVMs there is no need for any interop and extra libraries to support that and as the number of participants is limited there is no need to consider anything fancy.
I have a java server with a BlazeDS interface to handle Adobe AIR clients. I also have a bunch of legacy stand alone java apps that I'll need to integrate with the server. The java apps need all the same methods and remote calls that the AIR clients needs. So it would save tons of work if I could call the remote object methods from the java apps.
Anyone know if this can be done?
You can use the BlazeDS Java AMF libraries directly over HTTP. But interacting with the BlazeDS MessageBrokerServlet will require some extra work. Probably an easier path is to just expose the same Java services through another protocol that the Java code can more easily use.
Take a look on this library, it allows you to connect Java with a server running BlazeDS. On the other hand if you are interested in pure performance you can investigate another protocols..there are plenty of them.
G'day,
I have a project where I need to build a "live" java application (server) to hold state about domain objects (it's a private auction system). The java server will be communicating to and from PHP classes that hold the main back-end business functionality. The PHP classes will be stateless.
I need to communicate domain objects up to the java server (from PHP) so their state can be managed over time. Changes to the domain objects need to be saved back to the data store via calls to PHP classes on a web server.
I was thinking of wrapping my PHP classes using a XML-RPC class (e.g. Zend_Xmlrpc_Server) as they will be stateless. If/when the java application needs to write to the data store (by calling the correct PHP class method) it's a matter of using a XML-RPC client library class.
However, I'm not sure how I expose functionality in the java application so it can be reached by PHP method calls. Can anyone tell me the easiest way to do this in java ... do I just write a multi-threaded application and expose a socket? I'm after the right library classes to use to structure the java application with.
Cheers,
Paul
Expose your server-side Java code as a webservice.
There's countless ways to do this in Java but two that spring to mind are the EJB3 WS Annotations and Apache Axis.
As an aside, whichever technology you choose make sure you see it as a transport and keep the actual processing logic separate from it.
Have you already experiment the PHP Java Bridge tool ?