• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

interview questions?

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
1)I have a stateless Session Bean where I want to do some database manupulations . I use a dataSource for this . Where do I place the code for looking up and getting the DataSource so that my code is most efficient? In which method will u place this piece of code ?
2)A remote method addUserInfo is added to a Session Bean. Size of aLList initialized at the client side before the invocation is 0. public void AddUserInfo(aLList : linkedlist) { UserInfo lUserInfo = new UserInfo(); aLList.add(lUserInfo); } What will be the size of this List after the method is invoked in the client side?
give me detailed explaination?
bye
chaitanya
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.setSessionContext() method because this method is called only once for stateless session bean.
2.size will be remain at 0

Originally posted by kesava chaitanya:
hi
1)I have a stateless Session Bean where I want to do some database manupulations . I use a dataSource for this . Where do I place the code for looking up and getting the DataSource so that my code is most efficient? In which method will u place this piece of code ?
2)A remote method addUserInfo is added to a Session Bean. Size of aLList initialized at the client side before the invocation is 0. public void AddUserInfo(aLList : linkedlist) { UserInfo lUserInfo = new UserInfo(); aLList.add(lUserInfo); } What will be the size of this List after the method is invoked in the client side?
give me detailed explaination?
bye
chaitanya

 
kesava chaitanya
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pradeep bhat:
1.setSessionContext() method because this method is called only once for stateless session bean.
2.size will be remain at 0


why the size will remain 0
[ May 10, 2002: Message edited by: kesava chaitanya ]
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 cases here:
Ur business methods are defined in local i/f and another case is remote i/f..
case (1)
Local i/f
Objects reference are passed by value. In the method the reference will point to a new object (becoz of key word new) and then u r adding an element to the list..but this object is different from the one present in caller side.. so the size at the client will remain 0..
case 2
..in remote i/f objects are passed by value..
A copy of the list object is made and passed to the remote i/f ..so any changes made in server side will not get reflected in client side

Originally posted by kesava chaitanya:

why the size will remain 0
[ May 10, 2002: Message edited by: kesava chaitanya ]


[ May 10, 2002: Message edited by: pradeep bhat ]
[ May 10, 2002: Message edited by: pradeep bhat ]
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there guys,
I think that i understood the problem correctly but still do correct me if i am wrong. Mr. Bhat, wrong when u say that objects are passed by value in the remote and home i/f. It is actually the reference or the handle(pointer in c++) to THE Object that is tossed around(passed by val) and not the object itself. So when u add to a List or whatever that was, the count should increase and after the addmethod is done, if u want to say getCount, it should give u the count++.
Thanks
Sahil
 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why the answer to the first question is not ejbCreate? In Cavaness's "Special Edition, EJB2.0, it says that "we can optionally implement the ejbCreate method; for example, reference to a common resource such as a connection factory object."
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a must to implement ejbCreate method in stateless session bean. U can do the lookup in ejbCreate.
I guess ejbCreate is the right place rather than setSessionContext().

Originally posted by JiaPei Jen:
Why the answer to the first question is not ejbCreate?In Cavaness's "Special Edition, EJB2.0, it says that "we can optionally implement the ejbCreate method; for example, reference to a common resource such as a connection factory object."

 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

In RMI, objects can be passed by value or by reference(when u say by reference, this means ur class implements java.rmi.Remote.. and here comes the concepts of stubs and skeletons..)
1. I/f is remote.
In the problem that we are dealing with the object is a passed by value.. a copy of the list object is made and passed to the remote class..the object at the client and server are no longer same (The object recd at the server side is a copy of the object at the client) so any changes made to the copy will not be reflected at the client simply becuase it is a different object all together ..So size will remain 0(assuming that nothing was added to the list before calling the method)
I hope u understood this.
2.Local i/f
Here when the method is called the reference to the object is passed by value(now both of them refer to the same object.
The number of elements is now 1.
Sorry for my mistake !

QUOTE]Originally posted by sandy ind:
Hi there guys,
I think that i understood the problem correctly but still do correct me if i am wrong. Mr. Bhat, wrong when u say that objects are passed by value in the remote and home i/f. It is actually the reference or the handle(pointer in c++) to THE Object that is tossed around(passed by val) and not the object itself. So when u add to a List or whatever that was, the count should increase and after the addmethod is done, if u want to say getCount, it should give u the count++.
Thanks
Sahil
 
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic