⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch01s12.html

📁 详细介绍了jboss3.0的配置等
💻 HTML
字号:
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>The deployment descriptor</title><link rel="stylesheet" href="styles.css" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/styles.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets Vimages/callouts/"><link rel="home" href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html" title="JBoss 3.0 Documentation"><link rel="up" href="ch01.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01.html" title="Chapter 1. First steps"><link rel="previous" href="ch01s11.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s11.html" title="Review the EJB Classes"><link rel="next" href="ch01s14.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s14.html" title="Packaging and deploying the bean"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="jboss.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/jboss.gif" border="0"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch01.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch01s11.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s11.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch01s14.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s14.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table><div class="section"><a name="d0e300"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e300"></a>The deployment descriptor</h2></div></div><p>Now it's time to view the deployment descriptor. As a reminder, this 
file tells the EJB server which classes make up the bean implementation, the home interface and 
the remote interface. If there is more than one EJB in the package, it 
indicates also how the EJBs interact with one another. In this simple 
example, there is only one EJB so we won't need to worry about that 
part.</p><p>Most commercial EJB servers are supplied with graphical tools for 
constructing the deployment descriptor. JBoss does have an XML editor, but 
it's just as easy to construct the deployment descriptor manually. Here it 
is:</p><div class="figure"><p><a name="d0e307"></a><b>Figure 1.6. Deployment descriptor for the Interest Bean</b></p><div class="literallayout"><br>
&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"?&gt;<br>
<br>
&lt;ejb-jar&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;description&gt;JBoss&nbsp;Interest&nbsp;Sample&nbsp;Application&lt;/description&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;display-name&gt;Interest&nbsp;EJB&lt;/display-name&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;enterprise-beans&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;session&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ejb-name&gt;Interest&lt;/ejb-name&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;home&gt;org.jboss.docs.interest.InterestHome&lt;/home&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;remote&gt;org.jboss.docs.interest.Interest&lt;/remote&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ejb-class&gt;org.jboss.docs.interest.InterestBean&lt;/ejb-class&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;session-type&gt;Stateless&lt;/session-type&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;transaction-type&gt;Bean&lt;/transaction-type&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/session&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/enterprise-beans&gt;<br>
&lt;/ejb-jar&gt;<br>
</div></div><p>The deployment descriptor must be called ejb-jar.xml and it must be in 
the directory ./META-INF. A common mistake is to name this directory 
`META_INF' (with an underscore, rather than a dash) or meta-inf 
which won't work.</p><p>In principle what we deploy on the server is an application, not a 
single EJB. In this example our application consists of only one EJB. In the deployment
descriptor, the section &lt;ejb-name&gt;Interest&lt;/ejb-name&gt; assigns a name to the
EJB. JBoss by default will put the bean's home interface under the ejb-name 
moniker in the JNDI namespace if you don't override this default behavior.</p><p>In practice client applications are not forced to use this name. 
Typically a developer will not bother with specifying a different name for the 
JNDI namespace. However a production installation of a complete application 
comprising many beans, will usually use a different name rather than the one 
specified by the developer. Typically this would be something like "[application name]/[bean 
name]", which is what we shall use later.</p><p>Although the deployment descriptor format of the ejb-jar.xml file is 
common to all EJB servers, and precisely defined by a DTD you can get from 
Sun, it doesn't specify everything necessary for a particular EJB server.
Specifically it does not indicate how to map ejb-name to a deployment JNDI name
such as "[application name]/[bean name]".</p><p>The approach taken by JBoss is to provide a default behaviour that 
works from the ejb-jar.xml file in most cases. In case of advanced configurations
you need to define JBoss specific behavior using a jboss.xml deployment descriptor.
Refer to the advanced configuration section for the complete details of jboss.xml
descriptor. The only item we will configure via the jboss.xml descriptor is the JNDI
name used to access the Interest EJB home interface.</p><p>By default the JNDI name used to access an EJB's home interface is
the same as the ejb-name value from ejb-jar.xml. For this example that
means that the Interest bean would be located under the JNDI InitialContext
as "Interest". We want to have the home interface available using "interest/Interest"
so we need to specifiy this using the jboss.xml descriptor.</p><div class="section"><a name="d0e324"></a><div class="titlepage"><div><h3 class="title"><a name="d0e324"></a>Overriding the default JNDI name in jboss.xml</h3></div></div><p>To override the default behavior of using the ejb-jar.xml ejb-name element
value as the JNDI name of a bean's home interface, you need to specify
what JNDI name should be used using a jboss.xml descriptor like the following:</p><div class="figure"><p><a name="d0e329"></a><b>Figure 1.7. The JBoss XML descriptor.</b></p><div class="literallayout"><br>
&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"?&gt;<br>
&lt;jboss&gt;<br>
&nbsp;&nbsp;&lt;enterprise-beans&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;session&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ejb-name&gt;Interest&lt;/ejb-name&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;jndi-name&gt;interest/Interest&lt;/jndi-name&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/session&gt;<br>
&nbsp;&nbsp;&lt;/enterprise-beans&gt;<br>
&lt;/jboss&gt;<br>
</div></div><p>All this file says is that the Bean called Interest is to be bound under the JNDI 
name of interest/Interest.</p><p>So now we've created the standard ejb-jar.xml deployment descriptor as well as
the JBoss specific jboss.xml to set the JNDI name of the Interest EJB home
interface to "interest/Interest". We also have the EJB classes and so we have
all that we need to create the EJB jar package.</p></div></div><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="432" height="79"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch01.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch01s11.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s11.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch01s14.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s14.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -