-
1. Re: What does a home and remote interface really represent?
jwkaltz May 3, 2002 3:30 AM (in response to cs710)Yes you can cache the home interfaces; but not the beans because the methods on the home interfaces may have different permissions depending on which user is making the call.
home.create() is not very expensive anyway.
On your second question jboss by default also starts a naming service. So if you don't change anything, in your example you would have 2 servers and you might configure their names in a properties file leaving near your servlets. In a more elaborate system you could of course imagine the server settings (I mean naming-hostname & port) coming from some dynamic source such as an ldap repository. -
2. Re: What does a home and remote interface really represent?
cs710 May 3, 2002 10:26 AM (in response to cs710)Thanks for your reply. I am not sure what you mean in the second paragraph. Are you saying that JSP pages get one of the naming service running on Machine C and D from either a property file or from a central ldap and then look up the beans it needs to access? If this is the case, you can't really cache home interface. In addition, if you deploy HelloBean on machine C and AnotherBean on machine D, do you have to put this info in the property file or ldap that you have to look up HelloBean from Machine C naming service? Is it possible to configure a central naming service which has all the beans' info in JBoss? If we have to use an external naming server, how do we register ejbs with it? Thanks.
-
3. Re: What does a home and remote interface really represent?
davidjencks May 3, 2002 1:21 PM (in response to cs710)Get and read the jboss 3 clustering docs. It has clustered jndi.
-
4. Re: What does a home and remote interface really represent?
sgturner May 3, 2002 2:15 PM (in response to cs710)A couple of points. Hello is not a proxy to your bean, but technically is a proxy to the EJBObject. You could write a neat class that caches the context and home objects for you. Then your code becomes something like:
Hello bean = (Hello)MyCache.getBean ("Hello", Hello.class)
If you are using JBoss, then such a class is very easy to write. But if you use some other app server, then you may have to write more code, to handle what happens if the connection to Jndi goes down. -
5. Re: What does a home and remote interface really represent?
cs710 May 3, 2002 3:51 PM (in response to cs710)Interesting. Are you saying that you don't need to handle the case for JBoss? Is it because bean and jndi lives in the same JVM? How do you know the connection with jndi is dropped anyway? Can you simply determine simply based on you catch some exception when doing any of the following:
ctx.lookup()
home.create()
What should you do in this case? Do another lookup? -
6. Re: What does a home and remote interface really represent?
sgturner May 3, 2002 4:28 PM (in response to cs710)First of all, follow David's advice and read docs on Jboss clustering and all will become clear. In JBoss, the reference to the context is a lot more than a simple reference to some remote object. In JBoss, there is a lot of intelligence built into that proxy that will reestablish connections. Read the docs !! Absent using a JBoss server, a simple procedure to follow would be:
ask home for EJBObject ref
if failure, then ask context for new ref to home and go to top
if failure, then get new context and recycle
Of course, build in logic to avoid infinite loop.
There is more you could do based on type of exceptions thrown, but hey, use the superior JBoss, and its all handled for you.