Imagine what else you might want to do with your EJB object reference...

You’re a client. You have a reference to the AdviceBean’s component interface. You know you can call getAdvice(). But now that you’ve gone to all the trouble of getting the stub, are there other things you might want to do?

image with no caption

What YOU write:

image with no caption

EJBObject (the bean’s bodyguard for business methods)

What the CLIENT sees:

image with no caption

Remember, the container implements your component interface and matching stub.

The container must implement EVERYTHING from Advice and EJBObject.

Note

You better know these other methods inside and out.

The exam expects you to know all five of the methods in EJBObject. You have to know that they’re available to Remote clients, and exactly how they’re used!

If you’re a client, and you want to...

  1. get the primary key of an entity bean

    We won’t go into this now, since we have 10 million pages on entity beans coming up. Just know that this does not apply to session beans, which don’t have a unique identity exposed to the client. But if the client somehow gets a reference to an entity bean (maybe by searching on a customer’s name) and wants the actual primary key, this is the method to call. Try it on a session bean, and ...

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.