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

📄 3.mht

📁 Enterprise Java Bean的PPT文档,很好的东西.
💻 MHT
📖 第 1 页 / 共 5 页
字号:
interfaces and helper classes, so in the event that you have special =
needs then=20
you will have to customize this file. See ejbdoclet under the Xdoclet=20
documentation.</I></FONT></P>
<P><FONT color=3D#800000><I>'ejbGenerate.xml' file is generated only =
once when you=20
create your EJB module. So any changes made in this file will be =
reflected even=20
if you modify your bean class and generate your classes again and=20
again.</I></FONT></P>
<TABLE cellSpacing=3D2 cellPadding=3D2 width=3D"100%" border=3D0>
  <COLGROUP>
  <COL width=3D128>
  <COL width=3D128>
  <THEAD>
  <TR vAlign=3Dtop>
    <TD width=3D"50%">
      <P>As we can see from the code snippet of file shown in figure at =
right,=20
      there are following tags defined.</P>
      <P>&lt;dataobject/&gt; is defined for generating data Objects for =
holding=20
      values of EJB component's persistent fields, which correspond to =
columns=20
      in the associated table in the database. </P>
      <P><FONT color=3D#800000><I>Note: &lt;dataobject/&gt; has been =
deprecated in=20
      favour of Value Object which is more powerful in terms of =
relationships=20
      (1-1, 1-n and n-m). </I></FONT></P>
      <P>&lt;utilobject/&gt; Creates method for generating GUID and for=20
      accessing Remote and Local Home objects. </P>
      <P>&lt;remoteinterface/&gt; Generates remote interfaces for =
EJBs.</P>
      <P><FONT size=3D2><FONT face=3DSans>&lt;</FONT></FONT><FONT=20
      face=3D"Nimbus Roman No9 L">localinterface/&gt; Generates local =
interfaces=20
      for EJBs.</FONT></P>
      <P>&lt;homeinterface /&gt; Generates remote home interfaces for =
EJBs.</P>
      <P>&lt;localhomeinterface/&gt;Generates local home interfaces for=20
EJBs.</P>
      <P>&lt;entitypk/&gt;Generates primary key classes for entity =
EJBs.</P>
      <P>&lt;entitybmp/&gt;Creates entity bean classes for BMP entity =
EJBs.</P>
      <P>&lt;entitycmp/&gt;</P>
      <P>&lt;session/&gt; Generates session bean class.</P>
      <P style=3D"MARGIN-BOTTOM: 0in"><FONT color=3D#800000><FONT=20
      face=3D"Nimbus Roman No9 L"><FONT size=3D3><I>Note : There is no =
tag for=20
      generating a DAO.</I></FONT></FONT></FONT></P>
      <P style=3D"MARGIN-BOTTOM: 0in"><FONT color=3D#800000><FONT=20
      face=3D"Nimbus Roman No9 L"><FONT size=3D3><I>So, we have to =
include this=20
      &lt;dao/&gt; tag.</I></FONT></FONT></FONT></P>
      <P><FONT color=3D#800000><FONT face=3D"Nimbus Roman No9 L"><FONT =
size=3D3><I>For=20
      details, please refer ejbdoclet under Xdoclet=20
      documentation.</I></FONT></FONT></FONT></P></TD>
    <TD width=3D"50%">
      <P><IMG height=3D569=20
      =
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/ejbGenerateView.png=
"=20
      width=3D389 align=3Dleft border=3D0 name=3DGraphic38><BR=20
  clear=3Dleft><BR></P></TD></TR></THEAD>
  <TBODY></TBODY></TABLE>
<TABLE cellSpacing=3D4 cellPadding=3D2 width=3D"100%" border=3D0>
  <COLGROUP>
  <COL width=3D128>
  <COL width=3D128>
  <THEAD>
  <TR vAlign=3Dtop>
    <TD width=3D"50%">
      <P>As we can see from the code snippet from this file the =
following tags=20
      are defined.</P>
      <P>&lt;jboss/&gt; is a JBOSS specific tag required for JBOSS. You =
have to=20
      specify datasource, datasourcemapping and =
preferredrelationmapping. As it=20
      differs for different databases, so you may have to specify values =

      appropriate to your environment. If these tags are commented out =
in JBOSS=20
      they default to the correct values for the built-in Hypersonic SQL =

      database, but for the moment we'll set them anyway.</P></TD>
    <TD width=3D"50%">
      <P><IMG height=3D192=20
      =
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/ejbGenerateJbossVie=
w.png"=20
      width=3D379 align=3Dleft border=3D0 name=3DGraphic5><BR=20
  clear=3Dleft><BR></P></TD></TR></THEAD>
  <TBODY></TBODY></TABLE>
<P><BR><BR></P>
<P>The other two files which are of importance to us are ejb-jar.xml and =

jboss.xml. The file ejb-jar.xml has all the deployment descriptors for =
beans and=20
jboss.xml has the JBOSS specific deployment descriptors required by =
JBOSS.</P>
<P style=3D"MARGIN-BOTTOM: 0in"><FONT color=3D#800000><FONT=20
face=3D"Nimbus Roman No9 L"><FONT size=3D3><I>Note : ejb-jar.xml file is =
generated=20
every time you generate interface and helper classes for your bean. For =
the=20
first time, it is empty, and jboss.xml will be generated every time when =
you=20
will generate your classes for your bean.</I></FONT></FONT></FONT></P>
<P style=3D"MARGIN-BOTTOM: 0in"><BR></P>
<H3 style=3D"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in"><BR></H3>
<H3 style=3D"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in"><B>Setup DAO =
:</B></H3>
<P style=3D"MARGIN-BOTTOM: 0in"><BR></P>
<P>Now, let's customize ejbGenerate.xml for setting up a DAO. </P>
<P><B>We have included a &lt;dao&gt; tag specifying the destination =
directory=20
for the generated DAO interface and what pattern to be used.</B></P>
<P><IMG height=3D391=20
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/ejbGenerateWithDAOV=
iew.png"=20
width=3D368 align=3Dleft border=3D0 name=3DGraphic14><BR =
clear=3Dleft><FONT=20
color=3D#800000><FONT face=3D"Nimbus Roman No9 L"><FONT size=3D3><I>Note =
: For=20
details, please refer ejbdoclet under Xdoclet=20
documentation.</I></FONT></FONT></FONT></P>
<TABLE cellSpacing=3D4 cellPadding=3D4 width=3D"100%" border=3D0>
  <COLGROUP>
  <COL width=3D130>
  <COL width=3D126>
  <THEAD>
  <TR vAlign=3Dtop>
    <TD width=3D"51%">
      <P>We have included the datasource, datasoucremapping and=20
      preferredrelationmapping as shown in code snippet of =
ejbGenerate.xml file=20
      on right. </P>
      <P>datasource=3D"java:/DefaultDS" is a local JNDI name for data =
source to be=20
      used.</P>
      <P>datsourcemapping=3D"Hypersonic SQL" maps data object/value =
objects and=20
      their types to columns and data types associated with these =
columns.</P>
      <P>preferredrelationmapping=3D"foreign-key" defines type of =
database to be=20
      used. </P>
      <P><FONT color=3D#800000><FONT face=3D"Nimbus Roman No9 L"><FONT=20
      size=3D3><I>Note : For more details, please refer JBOSS=20
      documentation.</I></FONT></FONT></FONT></P>
      <P><BR><BR></P>
      <P>Since we are using the Hypersonic database, these parameters =
are=20
      appropriate to that. These parameters relate to the configuration =
file=20
      standardjbosscmp-jdbc.xml which controls the CMP-to-JDBC mappings =
for=20
      JBOSS. This resides in $JBOSS_HOME/server/conf/ , e.g.=20
      /opt/jboss/jboss-3.2.1/server/default/conf/.</P>
      <P>Code snippet from standardjbosscmp-jdbc.xml is shown in figure =
at=20
      right.</P></TD>
    <TD width=3D"49%">
      <P><IMG height=3D227=20
      =
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/ejbGenerateJbossDAO=
View.png"=20
      width=3D317 align=3Dleft border=3D0 name=3DGraphic39><BR =
clear=3Dleft><BR><BR></P>
      <P><IMG height=3D436=20
      =
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/standardbosscmp-jdb=
cView.png"=20
      width=3D460 align=3Dleft border=3D0 name=3DGraphic40><BR=20
  clear=3Dleft><BR></P></TD></TR></THEAD>
  <TBODY></TBODY></TABLE>
<P><BR><BR></P>
<P><FONT color=3D#800000><I>Note : The way Xdoclet works is bit =
different from=20
some conventional styles of programming, as the Xdoclet tags will =
generate these=20
(home and remote) interfaces along with necessary helper classes, which =
then=20
will used in Bean and DAO Implementation class. However, until these are =

generated, we cannot write any business methods in Bean and JDBC =
wrappers in the=20
DAO Implementation class. If this seems confusing then just follow the =
steps,=20
and hopefully it will become more clear. </I></FONT></P>
<H3 style=3D"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in"><BR></H3>
<H3 style=3D"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in"><B>Create DAO =
Interface=20
:</B></H3>
<P style=3D"MARGIN-BOTTOM: 0in"><BR></P>
<P>Since we are going to use a DAO to access the database for this =
Stateless=20
Bean, we have to create a DAOImpl class which will implement that =
generated DAO=20
interface.</P>
<P><B>Go to src &gt; add package named <SPAN=20
style=3D"TEXT-DECORATION: none">au.com.tusc.dao &gt; Add a class=20
</SPAN>StoreAccessDAOImpl in that package</B>.</P>
<P><IMG height=3D317=20
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/StoreAccessDAOImpl.=
png"=20
width=3D709 align=3Dleft border=3D0 name=3DGraphic12><BR =
clear=3Dleft><BR><BR></P>
<P><B>Now go to your Bean class and declare this tag at the class level =
(that is=20
at the top) as shown below to generate the DAO =
interface.</B></P><PRE><FONT color=3D#3f5fbf>   <FONT size=3D3><FONT =
face=3DSans>@ejb.dao =
class=3D"au.com.tusc.session.StoreAccessDAO"</FONT></FONT></FONT>
<FONT color=3D#3f5fbf>    <FONT size=3D3><FONT =
face=3DSans>impl-class=3D"au.com.tusc.dao.StoreAccessDAOImpl"</FONT></FON=
T></FONT></PRE>
<P style=3D"MARGIN-BOTTOM: 0in"><BR></P>
<P style=3D"MARGIN-BOTTOM: 0in"><IMG height=3D238=20
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/StoreAccessBeanDAOT=
ag.png"=20
width=3D764 align=3Dleft border=3D0 name=3DGraphic13><BR =
clear=3Dleft><BR></P>
<P style=3D"MARGIN-BOTTOM: 0in"><B>Expand StoreAccessBean node under =
Package=20
Explorer. Right click and a pop up menu will appear. </B></P>
<P><B>On that menu go to Lomboz J2EE &gt; Add EJB to module. Select EJB=20
'[MyStoreMgr]' &gt; OK.</B></P>
<P style=3D"MARGIN-BOTTOM: 0in"><IMG height=3D426=20
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/AddEJBToModule.png"=
=20
width=3D464 align=3Dleft border=3D0 name=3DGraphic7><BR =
clear=3Dleft><BR></P>
<P style=3D"MARGIN-BOTTOM: 0in"><B>Expand MyStoreMgr node under MyStore =
Project in=20
Package Explorer. Right click and a menu will pop up.</B></P>
<P style=3D"MARGIN-BOTTOM: 0in"><B>Go to Lomboz J2EE &gt; Generate EJB =
Classes as=20
shown in the figure below.</B></P>
<P style=3D"MARGIN-BOTTOM: 0in"><IMG height=3D433=20
src=3D"file:///F:/java_trainning/1206/tuscejb/3.files/GenerateEJBClassesN=
ow.png"=20
width=3D475 align=3Dleft border=3D0 name=3DGraphic44><BR =
clear=3Dleft><BR></P>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
  <COLGROUP>
  <COL width=3D180>
  <COL width=3D76>
  <THEAD>
  <TR vAlign=3Dtop>
    <TD width=3D"70%">
      <P><B>EJB interfaces and helper classes are generated under=20
      ejbsrc/au.com.tusc.session directory as shown in the figure at the =
right.=20
      </B></P>
      <P>Seven files are generated. </P>
      <P>StoreAccess is the remote object interface.</P>
      <P>StoreAccessLocal is the local object interface.</P>
      <P>StoreAccessSession extends our bean class named =
StoreAccesBean.</P>
      <P align=3Dleft>StoreAccessHome is the remote home interface.</P>
      <P>StoreAccessLocalHome is the local home interface.</P>
      <P>StoreAccessUtil is a helper class which has methods for =
accessing Home=20
      and LocalHome interface along with generating GUID.</P>
      <P>StoreAccesDAO is the DAO interface which we will use to =
implement our=20
      StoreAccessDAOImpl under au.com.tusc.dao.</P>
      <P><B>StoreAccessDAO is generated by this tag declared in =
StoreAccesBean=20
      shown below. If you don't declare this tag in that file it won't =
generate=20
      this interface.</B></P><PRE><FONT color=3D#3f5fbf> <FONT =
size=3D3><FONT face=3DSans>@ejb.dao =

⌨️ 快捷键说明

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