5 Replies Latest reply: Aug 2, 2010 5:00 AM by 843853 RSS

    proxy design pattern help

    652628
      Hi,

      Could please clarify my below doubts on proxy design pattern?


      There are several cases where a Proxy can be useful:

      *1. If the object is on a remote machine and loading it over the network may*
      be slow, especially during peak network load periods.


      so In this case how do we get the object which is in remote? By copying the jar files from the server to client
      is that right?So we will get the object which is in the remote.

      *2. If the object has limited access rights, the proxy can validate the access*
      permissions for that user.

      This how do we do?


      Thanks
      Bhanu
        • 1. Re: proxy design pattern help
          843853
          No you wont copy the jar file. Instead you will need to have the proxy class in your class path. And you will be invoking methods on the proxy, which in turn will have information to invoke the corresponding method on the remote object (for which this object is proxy).
          • 2. Re: proxy design pattern help
            652628
            Thanks Mithun.. I cleared that doubt. But one doubt,That proxy class will again have remote access isnt?
            For example I have one ServiceManager class which is in the server and one method getEmployeeDetails() in the ServiceManager class. So whenever I invoke the getEmployeeDetails class in the proxy class will it automatically call the ServiceManager class in the server side?


            thanks
            Bhanu..
            • 3. Re: proxy design pattern help
              843853
              Hi bhanu,

              The approach I am familiar with (if you are not using a remoting framework) is to make ServiceManager an interface and have two implementations; one that resides on your server (this is the full implementation) and one that resides on the client. The client side implementaton (called the proxy) has a very lightlight implementation which delegates all calls to it to the server side object using whatever remoting technnology you are using.

              Hope this helps.
              Rich
              • 4. Re: proxy design pattern help
                652628
                Hi Paratheosis ,

                I almost got the point. But what I have heard about proxy pattern is, we use proxy to reduce the traffic between
                client and server. In this case whenever we need any method on the server side we call isnt?..how trafic is being reduced here? Or is it storing somewhere client when we first time access the Object in Server side? for example
                In Servicemanager getEmployeedetails.. So in client do we store the ServiceManager object so that next time we can access the that ServiceManager object in the client side.. Is it in this way? I dont think because any updation on the ServiceManager will not be able to get in the client side? I totally confused the implements for proxy.. :(


                Thanks
                Bhanu.
                • 5. Re: proxy design pattern help
                  843853
                  Hi bhanu,

                  The Proxy pattern isn't primarily used to reduce traffic, but to hide from the client the messy technical details of calling the remote (server) side implementation.

                  I think you are confusing the Proxy pattern with the more involved Half Object Protocol Pattern (HOPP ref: Applied Java Patterns (Stelting & Maasen) pp189.

                  Take a look the reference or google it, it may help.

                  Regards
                  Rich