| |
Sistemi distribuiti: design
-
Forum del Corso
Messaggi del Thread
|
| Autore |
Messaggio |
gianni.costanzi
|
Thread
Postato:
27 dicembre 2004
Titolo:
JNDI Lookup Question and Naming Conventions
|
|
|
I have a question about the JNDI lookup method: there is an example given during some lesson which shows the difference between a local and a remote interface. The remote home is retrieved with jndiContext.lookup("CabinHomeRemote") while the local home is retrieved with jndiContext.lookup("java:comp/env/ejb/CabinHomeLocal").. Then, it is said that "java:comp/env/ejb" is the location that EJB specification reccomends.. What does this mean? Does it simply mean that java:comp/env/ejb/CabinHomeLocal is the JNDI name to which we should bind the Local Home in the jboss.xml descriptor? In the jboss.xml file we said that the jndi-name CabinHandle is bound to the CabinEJB bean, so we can run jndiContext.lookup("CabinHandle") and cast the resulting object on a CabinRemoteHome object (using portableRemoteObject.narrow(...)). What I want to say is that in jboss.xml we specified a bind between a jndi-name and a been and NOT between a jndi-name and a Local or Remote Home interface... Where should be specified the bind between the jndi-name "java:comp/env/ejb/CabinHomeLocal" and the local interface? Perhaps there is something i'm missing...
Then I have another question: the last lesson you (Angela) talk about some naming conventions for beans and for other things such as the java:comp/env/ejb/ I mentioned above.. Could you give us a short list of these conventions, in order to organize better our project (I know that it is not necessary to respect that conventions for our project, but is only to know about them in case we want to try to respect them..)?
Thank you very much! Merry Christmas and Happy New Year
|
|
|
afogarolli
|
Postato:
28 dicembre 2004
Titolo:
Re: JNDI Lookup Question and Naming Conventions
|
|
|
JNDI names look like URLs. A typical name for a database pool is java:comp/env/jdbc/test. The java: scheme is a memory-based tree. comp/env is the standard location for Java configuration objects and jdbc is the standard location for database pools.
Other URL schemes are allowed as well, including RMI (rmi://localhost:1099) (ex.CabinHandle, remote calls) and LDAP. Many applications, though will stick to the java:comp/env tree.
In your jboss.xml file you have to specified local and remote jndi names. Ex. <session> <ejb-name>PermissionManager</ejb-name> <jndi-name>PermissionManager</jndi-name> <local-jndi-name>PermissionManager_permissionEJB_permission</local-jndi-name> ...
The ejb-name is the same as in ejb-jar.xml.
From the client prospective if your client is remote you lookup your bean using rmi so you can use the jndi-name, as in CabinHandle example. For local clients (stand-alone or other beans) you can lookup the reference in jndi-tree using this string: ex."java:comp/env/ejb/PermissionManagerLocalHome". Why? Because in jboss.xml for each client I have specified an alias (the ejb-ref-name)for the PermissionManager jndi name, in this way: <ejb-local-ref> <ejb-ref-name>ejb/PermissionManagerLocalHome</ejb-ref-name> <jndi-name>PermissionManager_permissionEJB_permission</jndi-name> </ejb-local-ref>
...as you can notice I didn't have to specified the jndi base directory in jboss.xml . ... if I change the jndi-name, I don't have to recompile the code.
For the naming convention question, I put the links to JNDI Resource in the note field of the 20th diary activity. http://browserinsight2.lunaimaging.com:8090/ref/jndi.xtp
Best wishes for the new year.
|
|
|
gianni.costanzi
|
Postato:
28 dicembre 2004
Titolo:
Re: JNDI Lookup Question and Naming Conventions
|
|
|
Thank you for the answer.. Perhaps I'm starting to understand.. The problem is that we have never seen descriptors that contains the lines related to local references (or perhaps I do not remember).. So, in the example you mentioned above, in jboss.xml we should have something like this (putting together the two parts of descriptor code you have shown):
<session> <ejb-name>PermissionManager</ejb-name> <jndi-name>PermissionManager</jndi-name> <local-jndi-name>PermissionManager_permissionEJB_permission</local-jndi-name> <ejb-local-ref> <ejb-ref-name>ejb/PermissionManagerLocalHome</ejb-ref-name> <jndi-name>PermissionManager_permissionEJB_permission</jndi-name> </ejb-local-ref> [...]
The lines above sound quite strange for me.. We have <local-jndi-name>PermissionManager_permissionEJB_permission</local-jndi-name> and also <jndi-name>PermissionManager_permissionEJB_permission</jndi-name>, with the same content "PermissionManager_permissionEJB_permission".. It seems that some information is repeated more than once in a slightly different way... I will have a look at the Petstore example to see if I can understand something about these local interfaces..
Thank you
|
|
|
afogarolli
|
Postato:
30 dicembre 2004
Titolo:
Re: JNDI Lookup Question and Naming Conventions
|
|
|
Hi! The ejb-ref parameter is specified only for client beans not for the bean itself. Example. In the ejb-jar.xml you have a session BoardManager that calls PermissionManager:
<session> <display-name>BoardManager</display-name> <ejb-name>BoardManager</ejb-name> <home>it.unitn.eLeaf.board.BoardManagerHome</home> <remote>it.unitn.eLeaf.board.BoardManager</remote> <local-home>it.unitn.eLeaf.board.BoardManagerLocalHome</local-home> <local>it.unitn.eLeaf.board.BoardManagerLocal</local> <ejb-class>it.unitn.eLeaf.board.BoardManagerBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <ejb-local-ref> <ejb-ref-name>ejb/PermissionManagerLocalHome</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>it.unitn.eLeaf.permission.permission.PermissionManagerLocalHome</local-home> <local>it.unitn.eLeaf.permission.permission.PermissionManagerLocal</local> <ejb-link>PermissionManager</ejb-link> </ejb-local-ref>
The jboss.xml :
<session> <ejb-name>BoardManager</ejb-name> <jndi-name>BoardManager</jndi-name> <local-jndi-name>BoardManager_ePlatformEJB_ePlatform</local-jndi-name> <ejb-local-ref> <ejb-ref-name>ejb/PermissionManagerLocalHome</ejb-ref-name> <jndi-name>PermissionManager_permissionEJB_permission</jndi-name> </ejb-local-ref>
Bye
|
|
|
|
|