This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Product and Other Certifications and the fly likes Studying for 484 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Studying for 484" Watch "Studying for 484" New topic
Author

Studying for 484

garth schneider
Ranch Hand

Joined: Mar 20, 2002
Posts: 95
I am reading Howard Kushners great book on Developing J2EE applications and having problems on page 401. He is using the PortableRemoteObject.narrow on the appHome.create(). Example:
AppHome = (AppHome) PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/ejb/App"),AppHome.class);
App app = (App) PortableRemoteObject.narrow(appHome.create(),App.class):
I am wondering why you need to do that. I have never seen this done before. It is being returned from a java object and would not need this narrow method called on it. Can someone explain what I am missing here.
Thanks
[ April 27, 2004: Message edited by: garth schneider ]
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Hi Garth,
There are 2 cases when you get a Home interface (stub) from the container to the client.
Case 1: The client is of the same machine of the server (request for Local Home interface)
In this case, you dont need to do anything on casting, because the 2 pieces of bytecode are in the same heap (Same JVM). The Local Home interface can be directly cast.
Case 2: The client is on a remote machine (request for Remote Home interface)
In this case, it is recommend that we perform a transformation explictly. We need to narrow the return stub:

It is because, we may not always interact with Java objects. Thus, if we simply cast the return object, we cannot sure that the return object is really what we expected. The narrow method is to make sure that the conversion can be performed.
Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
garth schneider
Ranch Hand

Joined: Mar 20, 2002
Posts: 95
Hi Nicholas,
Thank you very much. I get it now. I always used Java objects so this was not a issue. I can see that this is a good standard to follow.
Thanks Again
Garth
SCJP
Serge Adzinets
Ranch Hand

Joined: Nov 26, 2002
Posts: 166
Actually, using PortableRemoteObject.narrow() in the second part of the given example is not needed. This is because AppHome's create() method is declared to return App. You should only use narrowing when the method is declared to return supertype of your class (like Object).
Thus, you should use narrowing when your remote object returns a collection or when looking it up from JNDI.
And you don't need to when calling create(), findByPrimaryKey() or any other method of an EJB object that returns exactly the type you need.
Hope this helps.


Best Regards,<br />Serge
Serge Adzinets
Ranch Hand

Joined: Nov 26, 2002
Posts: 166
BTW Garth,
why are you using this book for 484? It is the best for 287 but does not cover all the topics of 484 in detail.
garth schneider
Ranch Hand

Joined: Mar 20, 2002
Posts: 95
Hi Serge,
I am using Enterprise JavaBeans by Monson-Haefel and SCWCD Exam Study Kit by Hanumant as well. I have also read some of the other books from the IBM site. I did feel that Kushner's book covered a lot of the points for exam. But I have not taken the test yet so I will surely find out the answer to the proper resources after taking the test. You feel that the level of detail is lacking in the Kushner book for the 484. My thought was that if you understood the concepts well in reading this book after you have read Monson-Haefel 3 or 4 times that it showed that you really understood it. I am also using EJB's everyday.
I appreciate your answer to question. It appears that Kushner's book is in error. I am siding with your answer.
Garth
[ April 29, 2004: Message edited by: garth schneider ]
[ April 29, 2004: Message edited by: garth schneider ]
garth schneider
Ranch Hand

Joined: Mar 20, 2002
Posts: 95
How useful is using the Howard Kushner book for the 484? "Design Enterprise Applications with the J2EE" is good but rather a beginning document. I would think that the areas that are covered would be best taken from Kushner's book. I have not heard many comments on using the Kushner book for 484. Anyone have any comments.
Best Regards,
Garth
SCJP
IBM Solution Develper WSAD
#486 OO Analysis and Design with UML
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

It appears that Kushner's book is in error.

I think it may not be an error, but just something interesting.

Client programs that want to interoperate with other EJB container implementations must perform type narrowing of the client-side representations of the home and remote interfaces

The statement is half correct, as the remote interfaces are not require to be narrow. However, I remember somewhere in HF EJB stated that, performing such narrowing did no harm to the object.
As Serge said, since we already know what the interface is, thus, we dont need to perform the narrowing on Remote interface. Thanks for clarifying.
Nick
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

How useful is using the Howard Kushner book for the 484?
I would think that the areas that are covered would be best taken from Kushner's book. I have not heard many comments on using the Kushner book for 484. Anyone have any comments.

I think Howard's book is not quite useful for 484. Howard's book focus on how we use WSAD to write J2EE applications, however, 484 focus on in depth knowledge on J2EE as well as EAI. As Serge said, since the coverage of 484 is too board, there is no single book that is suitable for this test.
For JSP and Servlets related topics, I refer to SCWCD Exam Study Kit.
For EJB related topics, I refer to HF EJB.
For the rest topics, like JDBC, JCA, JAXP, etc, I refer to the corrsponding online documents recommended by IBM.

"Design Enterprise Applications with the J2EE" is good but rather a beginning document.

I have scanned some of the chapters before, it is helpful for JCA, but it is not for beginner definitely.
Nick
garth schneider
Ranch Hand

Joined: Mar 20, 2002
Posts: 95
Hi Nicholas,
Thank you for your reply. I am going to spend more time with "Designing Enterprise Applications with the J2EE Platform". It really is not an intro text. The other sources you mentioned are also sources that I have been using. This thread has been very helpful to me.
Best Regards,
Garth
SCJP 1.2
IBM Solution Developer VisualAge for Java
IBM Solution Developer WSAD
#486 OO Analysis and Design with UML
[ April 30, 2004: Message edited by: garth schneider ]
 
Don't get me started about those stupid light bulbs.
 
subject: Studying for 484
 
Similar Threads
Got ClassCastException with EJB3, please help!
t3s://localhost:7411: Destination unreachable
Need more detail of PortableRemoteObject.narrow
Login user automatically
Displaying an Image on a thick-client