• Post Reply Bookmark Topic Watch Topic
  • New Topic

This might be a hard question. on EJB

 
Vladas Razas
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The question itself might look simple at first glance. But I found out that people even with EJB experience has a trouble answering that. So I want to answer those people that really know this answer. It is basic question everybody should know the answer:
I have remote client R which has the references to _remote_ component interfaces for both beans A and B. Let's say R runs on one JVM and A,B on the other. Now the A bean has a method which takes remote component interface to bean B as parameter. We know we can pass reference to remote interface.
1) The main question: can A use that reference to B to invoke B business methods?
2) Sub-question: can stub created on one JVM be passed to another JVM AND be _used_ to invoke methods on the other JVM? (the sample is the same).
My best regards,
I am eagerly awaiting answer. I can't sleep without it.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you answered your own question in 1). If you can pass the stub without serialization errors, why wouldn't you be able to invoke its methods?
If you really can't sleep without the answer, you probably should try and see whether it works or not
 
Vladas Razas
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hehe, not that fast! I said that we can pass it. But can we use it? The problem might be because the stub is made for Remote client... So I am not sure if this stub is valid for use on another computer. Like I believe Kathy wrote in her book that stub might be network connection oriented. And even if I would try that. If it works it's not a proof, it's only 1 working container. I want to be sure that this works with every container.
Thanks for replying! I thought everybody ignores me.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought everybody ignores me.

You have become famous in JavaRanch already.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that stubs are not guaranteed to be Serializable (why? I dont have a answer for this) so you can use Handle as a persistent reference to EJB.
 
Vinod John
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vladas Razas:
The problem might be because the stub is made for Remote client... So I am not sure if this stub is valid for use on another computer. Like I believe Kathy wrote in her book that stub might be network connection oriented.

Do you mean stubs are client specific ? ... Stubs need only server specific information "hard coded", they don't have to be tied up to a client.
 
Vladas Razas
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep, Vinod,
I dont have a firm knowledge of this That's why I am asking. You right about handle but we need to know if we really need handle in this case. We need to know if such thing is allowed by EJB specification and thus is valid. I believe that stubs are guaranteed to serialize. Remember you can pass stub to bean. The question is may it be used. Let me roll simple pseudo example:
MyStub
{
SpecialOpenedSerializableSocket remoteConnection;
}
Now you see while it is guaranteed to be serializable (otherwise you can't pass it to remote component interface). But as you see this object itself while might be serializable is probably not valid on another computer. Of course stub class is universal for every client. After all that is why container at deployment time generates one class for everyone. But the problem is the instance of that class, the real stub object, universal?
As we know can be serialized. You would ask what is the purpose if we are not going to use it? Well you can give it to the bean to store it for you in some list or something until connection expires of course.
Oh, I would wish someone just come and say: It works this way, or the other way! But no everybody says, well it might be...
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that stubs are guaranteed to serialize

If it were the case then why do we need Handle?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need handles because Handles can be persisted.
Kyle
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need handles because Handles can be persisted.

They can be persisted because they are Serializable, right?
This bring me to the question - Why are stubs not Serializable?
[ December 08, 2003: Message edited by: Pradeep Bhat ]
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
They can be persisted because they are Serializable, right?

No, they can be persistend because the contain the information necessary to find the bean after being rematerialized. That an object is serializable simply means that it can be converted into a byte array and back again. It does not mean that the rematerialized object is useful.
Here's an metaphor, as that's the method I find best for explaining things like this. If I give you the address of my home you can drive there and talk to me. If I move, however, you won't be able to find me with just my address (assuming I leave no forwarding information, which beans do not do either). Now, if instead I had given you my full name and social security number, then you'd be able to find me after I move by looking up my address using the other information you have.
This, as far as my understanding of EJBs goes, is the same with a stub versus
a handle. The stub tells you the "current address" of the bean in question whereas the handle gives you a permanent name with which to find it once it's moved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!