Browse DevX
Sign up for e-mail newsletters from DevX


Intrinsyc's Ja.NET—Extending the Reach of .NET Remoting  : Page 3

Java/.NET communication just got easier. Intrinsyc's Ja.NET tool lets you make remote bi-directional calls between Java and .NET applications, either through HTTP/SOAP or the faster TCP/binary channel. Even in this initial version, you can pass objects both by reference and by value. It's a great start, and with a little work, the next version will be killer.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

You configure Ja.NET using XML files just as you do with .NET Remoting. The difference is that you shouldn't modify these files manually—you should use the Janetor tool instead. To start this tool, run the following command line from the directory where your .class files are located:

java -jar c:\JaNET\lib\janetor.jar

The Janetor is a sophisticated (but underdocumented) tool. To make the sample above run as expected, you must first import the license file I mentioned earlier—the one you receive via email after downloading and installing Ja.NET. You do this by right-clicking on "Licensing" and choosing "Install license …" after which you'll have to select the license file from wherever you saved it on disk.

Next, you must register the classes to which you will allow your clients to connect. First, right-click on "Local Objects" and add the class MyFactory.

The Janetor is a sophisticated (but underdocumented) tool.
In the configuration screen for this class you will then have to specify the mode. Ja.NET supports both server-activated objects (SAO) and client-activated objects (CAO). SAOs can be compared to classic Web services. When a client calls a method on the specified objects, they can either be handled by the same instance (Singleton) or by a new object created and destroyed for each request (SingleCall). In contrast, client-activated objects are like "conventional" objects, in that a client creates them on request. The clients hold distinct references that are bound to certain server-side instances.

In this example, publish MyFactory in "Server-singleton" mode. You then have to specify a URL used to send requests to this object. I chose tcp://localhost:3456/MyFactory.rem for this. The last setting—and for a casual user probably the most confusing one—is the "Assembly Name." Here you have to specify the assembly which will contain the .NET proxies. Note that you must not specify a .DLL extension here. If you're following the example code, you should set the Assembly Name to "FirstDotNetProxies".

Another difference between Ja.NET and classic .NET Remoting is that in Remoting, you don't have to register client-activated objects returned from methods. But with Ja.NET you must do this—otherwise you'll end up with a somewhat uncooperative NullReferenceException. Therefore the next step is to add the class CustomerManager with the mode "Client". Use the URI tcp://localhost:3456/CustomerMgr and the same assembly name you used before, (FirstDotNetProxies in the sample code).

Yet another major difference between .NET Remoting and Ja.NET is that in the latter you have to specify information for a "default" class. Here you should set the mode to "Server-singleton", do not provide an URI, and set the assembly name to "FirstDotNetProxies" again. The reason for this is that Ja.NET uses this assembly name to transfer objects by value. Without it, you won't be able to pass objects of type Customer or Address from Java to .NET.

able 1 shows the complete list of settings for this application.

NameMode URI Assembly Name
default Server-singleton   FirstDotNetProxies
MyFactory Server-singleton tcp://localhost:3456/MyFactory.rem FirstDotNetProxies
CustomerManager Client tcp://localhost:3456/CustomerMgr FirstDotNetProxies

Starting the application
If you're about to use the Ja.NET standalone server (as opposed to hosting it in your favorite EJB container), you can start it with the following command-line:

java -classpath c:\janet\lib\janet.jar;. com.intrinsyc.janet.Main

Then you can compile and start the C# client which should produce the following output:

Customer: John Doe Street, City: One Microsoft Way, Redmond, WA

On the server console, you should now see the following:

Customer: John Doe No address yet. Customer: John Doe Address: 4150 Network Circle Santa Clara, CA

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date