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

📄 jb7-1-3.htm

📁 JBuilder 5 的中文版帮助文档
💻 HTM
📖 第 1 页 / 共 2 页
字号:
  <LI>单击Rmove按钮。<BR> 
  <P>Jbuilder会询问你是否要移除这个property和它的关联代码。</P>
  <LI>选择Yes。 </LI></OL> 
<P>你还可以使用Properties页面来改变property的名称和类型。Bean    
designer是一种双向的工具,所以,你在Properties页面做的改动会体现在代码中,同样,你在代码中所做的改变也会体现在Properties页面。</P><A 
name=exposing_business_methods></A>
<p><font color="#000080" size="2"><b>向remote接口导出业务方法</b></font></p><!--BNDX="business methods:exposing EJB;remote interface:business methods;business methods:remote interface;Bean designer:Methods page;BeansExpress:exposing EJB methods"-->
<P>一旦你在bean的代码中定义了你的商业逻辑方法,你必须指定哪些方法你要加入到remotej接口中。客户端只能调用哪些被导出到remote接口中的方法。</P>
<P>要向remote接口中加入方法,</P> 
<OL>
  <LI>在project面版中双击你的enterprise bean。<BR><BR>   
  <LI>单击Bean项来显示Bean    
  designer。<BR><BR>
  <LI>点击Methods项。<BR><BR> 
  <LI>在Methods窗口,选中你要向remote接口输出的方法。 </LI></OL> 
<P><IMG alt="" border=0 height=442 
src="images/methods.gif" width=519></P>
<P>只要你选中方法,那些方法就会被立即加入到remote接口中。</P>
<P>要从remote接口中移除一个方法,只要去掉那个方法名前面的打勾即可。</P> 
<P>要编辑其中的一个方法,右击方法名,在小菜单中选择Edit即可。文件会在代码编辑器中打开,光标也会自动定位在你选中的方法上等待你的输入。</P>
<P>在小菜单中你还会发现一些其它有用的命令。你可以选择Rmove Selected来从bean class中移除这个方法。选择Check    
All来选中所有的方法,这样所有的方法都被导入到remote接口。选中Uncheck All来去掉所有的选择,这样remote接口中就不会有任何方法。</P>   
<P>你可以使用Methods页面来验证bean    
class中声明的方法在home和remote接口中有同样的标志。例如,假设你在bean class的ejbCreate()中加入了一个parameter,    
但是忽略了要在home接口的create()方法中也加入一个。Methods窗口会用红色显示EjbCreate()和create()。如果你点击红色显示的方法,Problem    
Description(问题描述)窗口会解释发生了什么问题。你可以在create()方法中加入那个paramerter来让方法标志一致并且解决的问题。另外,如果你在bean    
class中移除了某些方法,但是忘了在remote接口中也移除,Methods窗口也会用红色来显示那些方法来提醒你在remote接口中移除这些方法。<BR><BR><A 
name=generating_the_bean_class_from_the_remote></A></P>
<hr>
<p><font color="#000080" size="3"><b>从remote接口中生成bean    
class</b></font></p><!--BNDX="remote interface:generating EJB from;EJB Bean Generator wizard;EJB wizards:EJB Bean Generator;wizards:EJB Bean Generator;enterprise beans:generating from remote interface;wizards:EJB Bean Generator"-->
<P>从有些开发人员喜欢remote interface开始来开发enterprise bean。如果你也喜欢这种方式,可以使用EJB Bean    
Generator从remote接口生成skleton bean class。</P>   
<P>从remote接口生成bean    
class,</P>
<OL>
  <LI>在编辑窗口显示remote接口。<BR><BR> 
  <LI>选择菜单Wizards|EJB|EJB Bean Generator来显示EJB Bean Generator向导。<BR>   
  <P><IMG alt="" border=0 height=427 
  src="images/ejb_bean_generator.gif" width=558></P>
  <LI>Select the EJB group the bean belongs to and click Next. <BR>选择Bean要属于的EJB    
  Group,点击Next<BR><BR>
  <P><IMG alt="" border=0 height=427 
  src="images/ejb_bean_generator_type.gif" width=558></P>
  <LI>Select the type of EJB you want generated and click Next.    
  <BR>选择你要生成的EJB类型,点击Next. 
  <P>If you selected one of the session bean options, this page    
  appears:<BR>如果你选择了session bean中的一个,将出现下面的页面:</P>   
  <P><IMG alt="" border=0 height=427 
  src="images/ejb_bean_generator_session.gif" 
  width=558></P>
  <UL>
    <LI>指定EJB Bean选项:Bean Class,    
    Bean名字,Home接口和JNDI名字。 </LI></UL>
  <P>如果你指定CMP entity bean中的一个,出现下面的页面:</P>   
  <P><IMG alt="" border=0 height=427 
  src="images/ejb_bean_generator_entity.gif" 
width=558></P>
  <BLOCKQUOTE>
    <P>指定EJB Bean选项: Bean Class, Bean名字,Home接口,JNDI名字,Primary    
    Key Class和要成为persistent的字段.</P></BLOCKQUOTE>   
  <LI>点击Finish.  
  <P>示你完成里面的代码。你必须在里面添加代码完成希望的功能。</P>
  <P>如果home接口不存在,EJB Bean Generator也会为你生成一个。如果home接口已经存在,EJB Bean    
  Generator会询问你是否要覆盖已有的home接口,</P></LI></OL><BR><BR><A 
name=creating_the_home_and_remote_interfaces_for_an_existing_bean></A>
<hr>
<p><b><font color="#000080" size="3">从已经存在的bean生成home和remote接口</font></b></p><!--BNDX="home interface:creating for existing enterprise bean;remote interface:creating for existing bean;EJB Inteface Generator wizard;EJB wizards:EJB Interface Generator;wizards:EJB Interface Generator"-->
<P>如果你已经有了bean class,但是还没有所需要的home和remote接口,你可使用EJB Interface    
Generator向导来建立它们。你还可以使用这个向导在bean代码做出很多改动后重新生成以是改动体现在接口上。使用EJB Interface    
Generator, 你可以在更改bean class后诚心生成接口。</P>   
<P>要使用EJB Interface    
Generator向导,</P>
<OL>
  <LI>在编辑窗口打开bean    
  class的代码。<BR><BR>
  <LI>在菜单中选择Wizards|EJBEJB    
  Interface Generator.<BR>   
  <P><IMG alt="" border=0 height=421 
  src="images/ejb_interfaces.gif" width=550></P>
  <LI>选择bean要属于的EJB    
  group, 点击Next.<BR><BR>   
    如果bean是session bean,    
  出现以下页面:<BR><BR>
  <P><IMG alt="" border=0 height=427 
  src="images/ejb_interfaces_session.gif" width=558></P>
  <P>如果是entity bean,    
  出现以下页面:<BR><BR></P>
  <P><IMG alt="" border=0 height=427 
  src="images/ejb_wiz_entity.gif" width=558></P>
  <LI>接受缺省值或者自行指定。<BR><BR> 
  <LI>如果beterprise    
  bean是一个session bean, 选择Stateless(无状态)或者Statefull(有状态)选项。如果enterprise    
  bean是entity bean,选择Bean Mangaged Persistence或者Container Managed    
  Persistence。<BR><BR>
  <LI>点击Next来显示第三页,将显示bean方法:<BR><BR>
  <P><IMG alt="" border=0 height=436 
  src="images/expose_methods.gif" width=550></P>
  <LI>让你希望输出到remote接口中的方法保持选定,不希望输出的请取消核选。<BR><BR>
  <LI>点击finish. </LI></OL><BR><BR><A  
name=compiling_the_beans></A>
<hr>
<p><font color="#000080" size="3"><b>编译bean</b></font></p><!--BNDX="enterprise beans:compiling;enterprise beans:build properties;Generate IIOP option;EJB groups:build properties;build properties:EJB groups"--><!--BNDX="Remove Stub Files On Application Server Change option;Always Create JAR When Building option;deployment descriptors:inserting into EJB group;EJB groups:inserting deployment descriptors into;EJB groups:copy deployment descriptors from;stubs:generating client;client stubs:generation"--> 
<P>当你写好,并且保存了你的enterprise bean,    
它的接口(home,remote),和其它的支持class,你就可以编译了。如果你使用Borland AppServer或者Inprise    
ApplicationServer4.1并且你要在本地测试你的bean, 生成并且加入client    
stubs到你的classpath。你可以改变home接口的编译属性来实现,然后编译。</P>
<P>&nbsp;group (this step is    
optional),<BR>要改变EJB group的编译属性来为group里面的每个bean生成并且加入client    
clubs到classpath:(本步骤可选)</P>
<OL>
  <LI>在project面版中右击EJB group,然后选择Properties.<BR><BR>   
  <LI>选择Build页<BR><BR> 
  <LI>选择EJB页<BR><BR> 
  <P><IMG alt="" border=0 height=605 
  src="images/ejbgroup_build_properties.gif" 
width=452></P>
  <LI>编辑你希望的编译属性<BR><BR> 
    <BR>你可以改变输出的JAR 文件名字和要放置的路径。   
  <P>如果你不想使用Jbuilder的Deployment    
  Descriptor editor(部署描述编辑器)来编辑deppoyment descriptor(部署描述),    
而使用其它的替代工具,可自行编辑。</P>
  <P>你也可以为EJB group插入deployment    
  descriptors或者拷贝到其它地方。你也可以删除deployment descriptors。</P>   
  <P>如果你希望JAR文件包含其它的附加文件,点击Add按钮并且指定这些文件的位置。如果你希望在project内加入一个新的class,    
  并且你希望它们成为JAR文件的一部分。或者如果你有用JBuilder以外的工具生成的deployment    
  descriptors,你可以在这里加入它们,并且不要核选Include Deployment Descriptors In Output JAR    
  File选项。在Deployment Descriptors In Group列表中显示的deployment descriptors不会被加入到JAR,    
  而那些你单独添加的文件将会存在。</P>
  <P>如果你希望使用其它的application server, 你可以选择Remove Stubs Files On    
  Application Server Change选项来移除旧application server的client stubs。</P>   
  <P>Always Create JAR When    
  Building选项缺省为核选。去掉这个选项,你可延缓生成JAR文件,知道准备好要测试的时候。</P>
  <LI>在你使用的application    
  server上点击OK。例如,下面的图片表示选中BAS4.5。<BR><BR>
  <P><IMG alt="" border=0 height=578 
  src="images/bas45_ejbgroup.gif" width=433></P>
  <LI>指定你希望的build选项。如果你需要这些选项的更多信息,请点击Help按钮。 </LI></OL>
<P>你还可以为每个bean修改build属性,而不是为整个EJB Group:</P>   
<OL>
  <LI>右击bean的home interface,选择Properties.<BR><BR>   
  <LI>选择Build页<BR><BR> 
  <LI>点击VisiBroker页。<BR><BR> 
  <LI>选择Generate IIOP选项并且可改变其它的Java2IIOP选项。<BR><BR>   
  <LI>点击OK. </LI></OL> 
<P>要编译project中所有的class,    
右击project文件(&lt;project&gt;.jpx)并且选择Make。或简单的在菜单中选择Project|Make Project。</P>   
<P>在编辑过程中,Jbuilder可能检测到deployment    
descriptor中的错误。如果出现这种情况,你会看到在信息面版中出现一条提示信息告诉你要在Deployment Descriptor    
editor中验证bean. 要了解更多验证depolyment descriptor的信息,请参考<A    
href="file:///E:/enterprise/editing_deploymentdescriptors.html#verifying_descriptor_information">"验证descriptor    
information."</A></P>
<P><B>WebLogic用户请注意</B>。如果你在使用WebLogic服务器,如果临时目录或者classpath包含空格,你会在编译中看到错误信息,比如C:/Documents    
and Settings/jbprojects.</P>   
<P>如果你选择了生成clients stubs, 你会在project面版只要点击并且展开home    
interface节点,就会看到下面有了几个文件。这些生成的文件就是运行EJB所需要的client stubs和帮助class。</P><A    
name=editing_the_deployment_descriptor></A>
<hr>
<p><font color="#000080" size="3"><b>编辑deployment descriptors</b></font></p><!--BNDX="deployment descriptors:editing;deployment descriptors:XML file;ejb-jar.xml;weblogic-ejb-jar.xml;WebLogic:deployment descriptors;Build Properties dialog box"-->  
<P>每个增收EJB1.1规范的enterprise bean都需要在XML格式的deployment descriptor有一个entry</P>  
<P>当你编译你的project, JBuilder建立一个基于配置指定的名字的JAR文件,并且在project面版上把它显示为一个节点。</P>  
<P>你也可以不要编译整个项目就可以建立JAR 文件。在prject面版右击EJB group节点,选择Make来编译这个Ejb   
group。如果你要在编译前修改编译选项,选择Properties,然后按需要修改Build Properties对话窗口中的选项。</P>  
<P>JAR文件包含了所有的deployment descriptors。每个deployment   
descriptor是一个XML文件,除了WebSphere,他为每个bean使用一个.ser文件。每个JAR文件可以包含一个或多个deploment   
descriptors. </P>
<P>JBuilder只面向多个application server中的一个。你选择的application   
server决定了JAR文件中的deployment   
descriptors的数量,每个JAR文件应该有一个ejb-jar.xml(除了WebSphere3.5),它描述了所有bean在所有application   
server中的通用deployment属性。ejb-jar.xml是符合EJB1.1规范的deployment descriptor.   
如果你选择了EJB1.1作为你的application server, ejb-jar.xml就是你JAR中唯一的deployment   
descriptor。</P>
<P>所有因厂商而不同的信息都保存在ejb-inpirse.xm文件中,即使厂商是Borland以外的。在你编译的时候生成这个文件,或者你点击Deployment   
Descriptor编辑器的Source页。</P>
<P>如果你使用Borlnd   
AppServer,只会有一个附加的ejb-inprise.xml文件。如果是WebLogic服务器,生成的JAR文件包含一个weblogic-ejb-jar.xml文件,和一个附加的XML文件用来包含所有container-maganged   
persistence bean的信息。如果使用WebSphere,生成的JAR文件里面包含一个.ser文件对应每个bean.</P>  
<P>JBuilder的Deployment Descriptor编辑器提供了一个修改已经存在的deployment descriptor的方法。</P>  
<P>要显示Deployment   
Descriptor编辑器,在project面版中双击EJB group。Deployment Descriptor编辑器出现。注意一个EJB   
group树会出现在结构面版中。</P>
<P><IMG alt="" border=0 height=588 
src="images/dde_open.gif" width=804></P>
<P>要在Deployment Descriptor编辑器中察看一个enterprise bean,在结构面版中点击bean。或者如果你在结构面版中选择EJB   
Deployment Descriptor节点,你可以点击Contents项来显示EJB   
group的细节,然后双击你要察看的bean的图标。当在编辑器中显示了一个bean,有几个项会出现在Deployment   
Descriptor编辑器中。你可以使用这些项到编辑deployment descriptor的面版。</P>  
<P><IMG alt="" border=0 height=588 
src="images/dd_editor2.gif" width=804></P>
<P>注意,如果你使用Borland AppServer或者Inprise Application Server,EJB Properties项不会出现。EJB   
Properties页允许你改变对于WebLogic和WebSphere的设置。</P>
<P>关于Deployment Descriptor编辑器更详细的信息,请参考<A   
href="file:///E:/enterprise/editing_deploymentdescriptors.html">"使用Deployment   
Descriptor编辑器."</A></P>
<P>在编辑好deployment descriptor之后,你可以校验来确认descriptor信息是否正确、所需要的bean是否存在等等。</P>  
<P>要校验descriptor信息,在Deployment   
Descriptor编辑器中的工具条上单击校验按钮<IMG alt="" border=0 height=24 
src="images/dde_verify.gif" width=25>。</P>
<P>校验完成以下动作:</P> 
<UL>
  <LI>确认descriptor符合EJB1.1规范。<BR><BR>
  <LI>确认相关的class也符合EJB1.1规范。 </LI></UL> 
<P>如果验证失败,会有一个或更多的相关信息显示在Log面版上。</P>
</BODY></HTML>

⌨️ 快捷键说明

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