Hi, I dont really understand where I went wrong.. My question is how home class is not required in the Client. Ok. I understand that Client only deals with home class stub. BUT why then it says EJBObject interface is required for both Client and Server? I mean both EJBObject and Home are remote objects and both of them have stubs. Why is that Client side must have EJBObject and not it's stub? So to summarize: there are Component Interface, Component Interface stub, Home Interface and Home Interface stub. Which ones are required in Client. THank you!
Cowgirl and Author
Joined: Oct 10, 2002
Howdy -- this is kind of a confusing exercise, because not all pieces are shown in the picture. On the instructions on page 107, it says, "Note: not all the pieces are here, so when you're done, if you can think of other things that should into the picture (classes or objects) draw them in!" So you are RIGHT -- the client and server MUST have the EJB object stub class as well as the interface. We just didn't show the EJB object stub class in the diagram (so that you could figure that out The other thing that we did not show is the Home interface, which also must be on BOTH the client and server. Those are the things that you should draw into the picture yourself: * EJBObject stub class (put it on both the client and server) * Home interface (put it on both the cilent and server) So... the story is; CLIENT: Besides the client code, needs the home and component interfaces at both compile and runtime, and the home and component interface 'stub' classes at runtime. The cilent will also need the home and component interface stub OBJECTS at runtime (but that's why the stub classes have to be there, one way or another). SERVER: Needs everything that the client needs except the client class, BUT it will also have the implementation classes for the home and component interfaces (i.e. the *things* the stubs can communicate with). Remember, these diagrams and concepts are about how it *appears* to work. What the Container really does can be different. The most important thing to know is that without the home and component interfaces, the client cannot even compile, and that without the stub classes, the client will fail at runtime. However, some Containers provide this capability dynamically. So whether YOU as the Bean Provider must hand-deliver the stub classes to the client really depends on your Container. With the J2EE R.I., the client MUST have the stub classes *before* you try to run the client, while other servers can send the classes dynamically using one of several mechanisms (you don't have to know ANYTHING about dynamic proxies or dynamic code downloading for the exam!) cheers, Kathy
Joined: Dec 02, 2003
Thank you! Now I understand that there are actual container generated classes behind interfaces (of course the one can not instantiate an interface!). That is Home and EJBObject are not the classes but merely interfaces to classes that container generates. And Home class is the one of those classes. Those black and white photos are very stylish! I love this book.