• Post Reply Bookmark Topic Watch Topic
  • New Topic

Proxy design pattern  RSS feed

 
atguva kohen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I have jar that run in different enviroments (client,server,partners).

In my jar i have some method that in case they called the action that executed is depend on the implementor.

For example let say that i have method "updateXXX(long id,String name){
....
Notify.notify(...)
}"

if this called in the client than it need to lookup to this service and send the class name, method name and the method parameters to the service.

if it run in the server than it need to run XXX with the same parameters (this infrastrcture need to server some method with different parameters).

Is the proxy design patterns is the solution for this?

I thought to demand from each imlementor that want to use those kind of methods to implement a plugin with a given class name and in notify to load this class with class.forName, what are you say about this soultion?

any other ideas will be more than welcome.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i got from your post:

You have certain type of classes, the instances of which can be invoked from either a client or a server.
If it is called on the client, you want to send the call to the server whereas if it is called on the server, you do not do anything but just execute the called method.
Is the above your requirement? If yes, then definetly Proxy pattern is the way to go. Infact there is already a class java.lang.reflect.Proxy that may suit your requirement.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!