• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFEJB problem

 
Brenda Kwok
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain why the answer in Chapter 5-Question 3 and Question 5, the answer includes D

I don't understand why client can get a reference to an existing entity object's component interface by receiving the reference as a parameter in method call...

I don't know what it means actually.

Please clarify me if u know the answer. Thanks.

Brenda
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brenda Kwok:

I don't understand why client can get a reference to an existing entity object's component interface by receiving the reference as a parameter in method call...
I don't know what it means actually.


In EJB, bean is the one who has the business logic. We protect bean all the time. Even the acces to bean is through the component interface (which implements EJBObject so acts like a body guard in HF terms)

If this is the case, how will it be ok if we give the actual bean reference in method call arguments? so what we pass is the EJBObject/component interface reference in the method calls. Use it and reach to the bean in a secure way. But no direct bean reference handing out is allowed. This makes it very m uch possible to receive a local/remote component Interface reference as a method parameter.

Regards,
Leena
 
Brenda Kwok
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the method call in the business component interface?

Can you give sample code for passing the EJBObject/component interface reference in the method calls?
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The methods in the component Interface are for the end client to call. I do not think it would be proper to say that the end client recieves the component interface reference through the component interface methods. These are the methods she calls. So saying she receives it, means she is the one who passed it.

The thing is if one ejb calls another, it is said to be the client for the ejb called.

So if we had, changePin(), and withDrawMoney() and CheckLinkedAccount() in the component Interface of ManageAccount Session Bean class,


public void ManageAccount implements SessionBean
{
//Account will be implemented as an Entity Bean
AccountCompInterface = setcurrentAccount();

changePin()
{
//implementation
}

withDrawMoney()
{
//implementation
}

//Assume this lets you to do things for the linked Account to the current account
handleLinkedAccount(){
try{
//assuming ctx is globally available
Object obj = ctx.lookup("LinkedAccountsManagerSB");
LinkedAccountsHome LAhome = (LinkedAccountsHome)PortableRemoteObject.narrow(obj, LinkedAccountsHome.class);

//Here the LinkedAccountsManagerSB receives the Account Component Interface as a method parameter.
LAComp = LAhome.create(AccountCompInterface);
}
catch(){}
}

}



Regards,
Leena
 
Brenda Kwok
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leena,

Really thanks your explanation. I get it now.

However, now I am really afraid that I can't pass the exam. The book (in chapter 5) not many example linked entity bean and session bean together or say more real world example code.

I am planning to take the exam next Friday.

Brenda
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leena,

What is this ?

public void ManageAccount implements SessionBean
{ }

is it a class declaration ???

Sanju
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sanju, typo error. sorry for any confusions.

Brenda, do not be afraid. Being on Javaranch in itself is a learning process. Be on the site as much as you can. It will surely help you for the exam.

Regards,
Leena
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic