• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about ConnectionFactory implementation

 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Ranchers:
I will bind ConnectionFactory object to RMI. I already have a remote object called RemoteDataAccess. ConnectionFactory has a method
getConnection to create a remote connection for every client. Here is what bafling me: RemoteDataAccess extends UnicastRemoteObject and implements DataInterface, if I have to create another remote object ConnectionFactory, should I do the same thing like: create a ConnectionInterface which extends Remote, and shared by both server and client like DataInterface, then define ConnectionFactory object to extend UnicastRemoteObject and implement ConnectionInterface?
The following code just give me a strange error message:

LINE A just gives me this strange error message:

unreported exception java.rmi.RemoteException; must be caught or declared to be thrown
public class ConnectionGateway extends UnicastRemoteObject

Any help appreciated.
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple guesses:
1. The interface needs to extend remote
2. The factory constructor needs to throw Remote Exception
 
Jason Boutwell
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both remote objects should be implemented the same way. The only difference between them is that the factory object will be bound to the registry, and the code for that is outside of the implementation. So, define an interface for both, make sure it extends Remote, and throw RemoteExceptions on your implementation methods.
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for your replies, guys. The above is what exactly I did. All interfaces extend Remote, and
all methods throw RemoteExceptions. Still wondering what's hapening....
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your constructor throw Remote exception?
public ConnectionGateway() throws RemoteException{
super();
}
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Robin Underwood:
Does your constructor throw Remote exception?
public ConnectionGateway() throws RemoteException{
super();
}

Thanks Robin, you are right, I missed that one.
Just fixed the problem. I just feel blind sometimes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic