• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejb-jar.xml

 
Syed Mahdi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
can anybody tell me if in the ejb-jar.xml in the tag <ejb-name> </ejb-name>
what is really supposed to come as i cna see the hgome inter face and the beana nd the remote interface in different online examples .. thanks
 
Gabriel Buheler
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here you have an example for a simple Stateless EJB. This is the ejb-jar.xml file that have to be inside the EJB-JAR file (inside the META-INF dir).

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

<ejb-jar>
<display-name>AdviceJar</display-name>
<enterprise-beans>
<session>
<display-name>AdviceBean</display-name>
<ejb-name>AdviceBean</ejb-name>
<home>headfirst.AdviceHome</home>
<remote>headfirst.Advice</remote>
<ejb-class>headfirst.AdviceBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<security-identity>
<description></description>
<use-caller-identity></use-caller-identity>
</security-identity>
</session>
</enterprise-beans>
</ejb-jar>
 
Syed Mahdi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well thanks for posting and reply : but my question was is it neccessary that the BEAN be the ejb-name i have seen examples with the home interface or the remote interface being the ejb-name orshould i ask : what does it depends on how do we choose the ejb-name.

thanks
 
Syed Mahdi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you have a sample of a BMP bean deployment decriptor like ejb-jar.xml
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there! The ejb-name is a name that does not *need* to match the bean name or interface. You could (although it would be bad idea) give each of your beans names like: Foo, Bar, etc. even though your actual component interfaces are Customer, Advice, etc.

It is generally good practice, though, to give your bean an ejb-name that represents the bean, not one of its interfaces, although many use this practice:

Remote:

Remote Component interface: Customer
Remote Home interface: CustomerHome
Local Component interface: CustomerLocal
Local Home interface: CustomerHomeLocal or CustomerLocalHome

Bean class name: CustomerBean
ejb-name in DD: CustomerBean (or Customer)

(So the ejb-name often matches the bean class name or remote component interface name, which is generally the bean class name *minus* the word "bean".)

Remember that the ejb-name is never used in code, or in JNDI lookups, etc. The ejb-name is used ONLY as a kind of "label" in the DD. It is a name that you can use in *other* parts of the DD to tell the DD which actual bean you are referring to, without having to redefine all the core info about the bean everywhere you need to refer to one. For example, an ejb-ref can use the ejb-link to specify WHICH bean you're *really* talking about, and value of the ejb-link tag must match the value of an ejb-name tag somewhere else in the DD.

cheers,
Kathy
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic