• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local Adapter Class

 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please comment.

In my design I use the adpater design pattern (server-side). The adpater class has two important roles, firstly its has all the server-side business logic in it and is used in both remote and local mode.

My question about my design is. 'in local mode, the adpater class methods are invoked directly by-passing the uneccessary overhead or RMI marshalling. But this class 'X' doesn't implement any interface, is this acceptable?

If it did implement an interface it would be the business services, but in that particular interface the method declarations throw RemoteException. I know I could get round this by throwing a generic Exception but it then seems like I'm trying to fudge it.

Let me know what you think?

thanks.



 
Hu Yong Jun
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The LocalXxx and RemoteXxx share the same interface named as Xxx. The methods in the Xxx interface all throw RemoteExceptioon so the LocalXxx's methods throw RemoteException in local mode. This is because the subclass RemoteXxx is remote and must throw RemoteException. In local mode, the system is in local invoking manner and does not throw RemoteException at all so that it could do nothing with RemoteException.

In the view from client, the system is always a client/server application and is remote. It is the system that shelds or hides or bypasses the network when it is in local mode.

Anyone has other opinions?
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For now I'm using the Adapter pattern and I have decided that the adaptee (class with all business logic which is used for local mode also) will NOT implement the Remote Interface because I dont see the advantage. plus this saves me adding the unthrown RemoteExcpetion which is not needed:

[ throws 'RemoteException', OtherException, etcException ]

Do you not agree this is a better way Hu?

James
 
Hu Yong Jun
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the adatper adds the network function in remote mode while the adaptee is used in local mode. So there must be a difference between the adapter and the adaptee: the adapter throws RemoteException but the adaptee not. You would write 2 client programs, one for adapter in remote mode and the other for adaptee in local mode.

In my understanding, the adapter can not be used in both remote and local mode if this difference exists.


In my design I use the adpater design pattern (server-side). The adpater class has two important roles, firstly its has all the server-side business logic in it and is used in both remote and local mode.


[ October 12, 2004: Message edited by: Hu Yong Jun ]
[ October 12, 2004: Message edited by: Hu Yong Jun ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic