Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Is it possible to register non-Java objects with the RMI Registry?

Thread view: 
mshetty@mail.com - 29 Sep 2006 11:49 GMT
Hi,

I have read that RMI Registry is a name server wherein Java Objects can
be registered.

I have a query.. Is it possible to register non-Java objects with the
RMI Registry?

Non-Java as-in say CORBA Objects developed using C++.

Thanks and Regards,
M Shetty
Thomas Fritsch - 29 Sep 2006 13:23 GMT
> I have read that RMI Registry is a name server wherein Java Objects can
> be registered.
[quoted text clipped - 3 lines]
>
> Non-Java as-in say CORBA Objects developed using C++.

The RMI registry can register Java objects only (or to be more exact:
implementations of java.rmi.Remote).
However, you can create simple Java wrapper objects for carrying any
native data, like in the following *incomplete* example:

  public class WrapperObject implements Remote {
      private int pData;
      WrapperObject(....) { init(); }
      private native void init();
      private native void free();
      protected void finalize() { free(); }
  }

The pData variable can contain a C/C++ pointer. The native methods,
which you can implement in C/C++ via JNI, do the real stuff.
The init() method allocates the C/C++ object and stores the pointer in
pData. The free() method is called when the Java object is
garbage-collected and frees the C/C++ object.
(BTW: Java itself uses sort of this technique in many places, for
example in class java.awt.Font)

Complications will arise because RMI objects are usually intended to be
transported through the net. Hence you'll have to implement the
semantics of the Serializable interface somehow. How much effort this
will be, depends on what kind of non-Java objects you have.

Signature

Thomas



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.