O'Reilly logo

Head First EJB by Bert Bates, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What really gets passed when you pass an object to a remote method?

image with no caption

If your remote method has an argument that’s an object type, the argument is passed as a full copy of the object itself!

For remote calls, Java passes objects by object copy, not reference copy.

A serialized copy of the object is shipped to the Remote object.

image with no caption

Getting the object argument from the client to the server

  1. Client invokes trainPet(myDog) on the stub, passing a copy of the reference to the Dog object.

    image with no caption
  2. The stub makes a serialized copy of the object and sends that copy over the wire to the skeleton.

    image with no caption

Unpacking (deserializing) the object on the server

  1. The skeleton deserializes the passed argument, creating a new Dog object in the Remote object’s heap.

    image with no caption
  2. The skeleton invokes the method on the Remote object, passing a plain old Java reference to the new Dog object.

    image with no caption

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required