-
Making a global RMI connection
Hi there,
I am wondering is there anyway to make a RMI connection in such a manor as to allow the remote methods to be called from anywhere in the application, without re initializing the original connection.
For example say I have a client with the class classmain.java -the main class with the main method and classgui.java and classloginscreen.java
Then a server with the interface class and the main implementation class.
Now in the client main I have
public RemoteServerInterface remote;
then in classmain I make a call to a method setup connection,
the method is as follows
try {
remote = (RemoteServerInterface)Naming.lookup("rmi://127.0.0.1/servername");
}
catch (RemoteException ee) {
System.out.println("RemoteException: " + ee.getMessage());
ee.printStackTrace();
}
ok now I make an instance of clientgui from clientmain, and from clientgui i make an instance of classloginscreen. here I want to call for example
remote.test();
But I get a null pointer exception because remote is not defined. If I make a new variable as like the one in clientmain inside classloginscreen hence [public RemoteServerInterface remote; ] and
if I make a method inside classloginscreen which dose the code above, all works fine but I want to have one global connection so once I run classmain after that inside any other class I can just go remote.methodname();. is this possible or do I need to make a connection every time I am inside a different class.
any suggestions would be great.
Thanks
Cuspblue
Similar Threads
-
By lwinn213 in forum Java
Replies: 2
Last Post: 10-23-2008, 01:14 PM
-
By Daniel Teufert in forum VB Classic
Replies: 2
Last Post: 04-24-2002, 02:34 PM
-
By Chris P. in forum Java
Replies: 0
Last Post: 12-04-2000, 07:55 PM
-
By Chris P. in forum Java
Replies: 0
Last Post: 12-04-2000, 07:52 PM
-
By Darta in forum VB Classic
Replies: 1
Last Post: 10-24-2000, 04:48 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks