Proxy vs. Stub

Discussion in 'Java' started by Dal Mon, Jun 8, 2005.

  1. Dal Mon

    Dal Mon Guest

    What is the difference between a proxy and a stub?
     
    Dal Mon, Jun 8, 2005
    #1
    1. Advertising

  2. Dal Mon

    IchBin Guest

    Dal Mon wrote:
    > What is the difference between a proxy and a stub?
    >

    stub

    A routine that doesn't actually do anything other than declare itself
    and the parameters it accepts. Stubs are used commonly as placeholders
    for routines that still need to be developed. The stub contains just
    enough code to allow it to be compiled and linked with the rest of the
    program.

    proxy

    A server that sits between a client application, such as a Web browser,
    and a real server. It intercepts all requests to the real server to see
    if it can fulfill the requests itself. If not, it forwards the request
    to the real server.

    Proxy servers have two main purposes:
    # Improve Performance: Proxy servers can dramatically improve
    performance for groups of users. This is because it saves the results of
    all requests for a certain amount of time. Consider the case where both
    user X and user Y access the World Wide Web through a proxy server.
    First user X requests a certain Web page, which we'll call Page 1.
    Sometime later, user Y requests the same page. Instead of forwarding the
    request to the Web server where Page 1 resides, which can be a
    time-consuming operation, the proxy server simply returns the Page 1
    that it already fetched for user X. Since the proxy server is often on
    the same network as the user, this is a much faster operation. Real
    proxy servers support hundreds or thousands of users. The major online
    services such as Compuserve and America Online, for example, employ an
    array of proxy servers.
    # Filter Requests: Proxy servers can also be used to filter requests.
    For example, a company might use a proxy server to prevent its employees
    from accessing a specific set of Web sites.

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    __________________________________________________________________________

    ' If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
     
    IchBin, Jun 8, 2005
    #2
    1. Advertising

  3. Dal Mon

    Dal Mon Guest

    Thanks for the response. Stub and Proxy are terms that are overloaded
    and mean many different things depending on context.

    I was thinking along the lines of distributed programming. It seems
    that in distributed programming, the terms stub and proxy seem to be
    used interchangeably. I was wondering if my basic understanding of
    these terms is somehow lacking or if they in fact refer to the same
    thing.
     
    Dal Mon, Jun 8, 2005
    #3
  4. Dal Mon

    Bjorn Abelli Guest

    "Dal Mon" wrote...

    > Thanks for the response. Stub and Proxy are terms that are overloaded
    > and mean many different things depending on context.
    >
    > I was thinking along the lines of distributed programming. It seems
    > that in distributed programming, the terms stub and proxy seem to be
    > used interchangeably. I was wondering if my basic understanding of
    > these terms is somehow lacking or if they in fact refer to the same
    > thing.


    Even in distributed programming, those terms can mean different things
    depending on the context... ;-)

    Anyway, when in doubt I usually make use of a thesaurus, where the etymology
    of the words can give more insight.

    proxy: (person with) authority or power to act for another

    Hence in distributed programming, this usually means a mechanism that
    recieves the function calls "as if" it was the real distributed object, and
    hence makes the call transparent to the calling object.

    stub: a short blunt part left after a larger part has been
    broken off or used up; something cut short or stunted

    Hence in distributed programming, a stub is an *end-part* of the whole
    chain, but has to be "glued" together with, or make use of, other pieces to
    make the whole chain work.

    In distributed programming in Java the stub in most cases is an interface,
    or an abstract class, which is seen by the calling object as the "front-end"
    to the "proxy mechanism".

    So in my vocabulary, there's a difference between the two terms.

    Just my 2c

    // Bjorn A
     
    Bjorn Abelli, Jun 8, 2005
    #4
  5. Dal Mon

    Dal Mon Guest

    Ok, I decompiled the classes auto-generated by IBM for a web services
    client. It looks like the class labelled as stub does the actual
    remote call, while the class labelled as proxy acts as a wrapper around
    the stub.

    The curious thing is that they both implement the same interface, so a
    client can call either the stub class or the proxy class. I suspect
    that for this case, the proxy class is simply a convenience class
    hiding the complexity of a lookup for the stub.
     
    Dal Mon, Jun 9, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arcadius A.

    Webservice: Stub vs. proxy

    Arcadius A., Jan 10, 2004, in forum: Java
    Replies:
    0
    Views:
    2,263
    Arcadius A.
    Jan 10, 2004
  2. Andoni
    Replies:
    0
    Views:
    347
    Andoni
    Apr 26, 2004
  3. insouciant

    RMI: Stub Not Found Exception

    insouciant, Aug 12, 2004, in forum: Java
    Replies:
    0
    Views:
    1,076
    insouciant
    Aug 12, 2004
  4. Replies:
    4
    Views:
    3,040
    Thomas Fritsch
    Mar 14, 2006
  5. George2

    Proxy/Stub issue

    George2, Feb 14, 2008, in forum: C Programming
    Replies:
    0
    Views:
    481
    George2
    Feb 14, 2008
Loading...

Share This Page