Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RAP to access outside Singleton class(Regarding RAP application to access the Singleton class)
RAP to access outside Singleton class [message #778242] Wed, 11 January 2012 22:10 Go to next message
Kaustubh Missing name is currently offline Kaustubh Missing nameFriend
Messages: 14
Registered: November 2011
Junior Member
Hi

I have a singleton class in $JAVA_HOME/jre/lib/ext/<filename>.jar file. I want it to be accessed from two different places and hence I stored it in ext directory.

One is a single Java program in lets say /user/temp directory and the other is my RAP application. I noticed that both these applications are able to access the Singleton class but it is "Singleton" in their own context. It looks like it has two separate instances in memory. One for /user/temp/HelloWorld.java and the another for RAP. And I think it could be because of different classloaders as the eclipse RAP does not use the system JVM classloader.

My question is, is there any way to have the single instance of singleton class across different classloaders? or may be some other solution to achieve this? I really need to solve this ASAP and not getting a clue.

thanks!
Kaustubh
Re: RAP to access outside Singleton class [message #778484 is a reply to message #778242] Thu, 12 January 2012 20:22 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
This isn't really a RAP issue. Its a plain old Java one. If the two pieces of Java code are not running in the same instance of the JVM then it will get complex and very, very slow. I won't go in to it for now. If they are in the same JVM instance you should be able to load the class using a specific classloader (the system one) with Class.forName(String, boolean, ClassLoader). If both pieces of code use the system class loader you should get the same "Singleton context" ie: the same class object and the same static fields.

To have it working between JVM instances you're better looking at some kind of EJB/RMI/OSGi Remote Services/etc
Re: RAP to access outside Singleton class [message #778485 is a reply to message #778242] Thu, 12 January 2012 20:22 Go to previous message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
This isn't really a RAP issue. Its a plain old Java one. If the two pieces of Java code are not running in the same instance of the JVM then it will get complex and very, very slow. I won't go in to it for now. If they are in the same JVM instance you should be able to load the class using a specific classloader (the system one) with Class.forName(String, boolean, ClassLoader). If both pieces of code use the system class loader you should get the same "Singleton context" ie: the same class object and the same static fields.

To have it working between JVM instances you're better looking at some kind of EJB/RMI/OSGi Remote Services/etc
Previous Topic:High CPU load in Safari and Chrome browsers
Next Topic:Add Servlet Filter
Goto Forum:
  


Current Time: Tue Dec 07 06:35:10 GMT 2021

Powered by FUDForum. Page generated in 0.02088 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top