设为首页】 【加入收藏】 【网站地图】 【商品折扣
娱乐一生 娱乐明星
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
首页  |  java  |  .NET  |  C/C++  |  网页技术  |  php  |  asp  |  delphi  |  VC  |  VB开发  |  游戏开发  |  软件工程  |  Power Builder  |  Linux开发  |  Windows开发技巧
当前位置:首页 >> EJB技术 >> Beans入门必读之经典EJB例子代码

Beans入门必读之经典EJB例子代码 -


  rmi-iiop ejb客户端例子
  
  A Java RMI-IIOP client with a proprietary EJB server.
  
  package com.wiley.com ooks.roman.corba.helloworld;
  import javax.ejb.*;
  import javax.naming.*;
  import javax.rmi.*;
  import java.util.Propertie 
  import javax.tra action.UserTra actio 
  /**
  * This cla  is an example of client code that invokes
  * methods on a simple statele  se ion bean.
  */
  public cla  RMIClient {
  public static void main(String[] args) {
  try {
  /*
  * Get System properties for JNDI initialization
  */
  Properties pro  = System.getProperties();
  /*
  * Use JNDI to look up the home object
  */
  Context ctx = new InitialContext(pro );
  HelloHome home = (HelloHome)
  javax.rmi.PortableRemoteObject.narrow(
  ctx.lookup("HelloHome"),
  HelloHome.cla );
  /*
  * Use JNDI to look up the JTA
  * UserTra action interface JAVA天堂
  */
  UserTra action userTran = (UserTra action)
  ctx.lookup("javax.tra action.UserTra action");
  /*
  * Start the tra action
  */
  userTran.begin();
  /*
  * Use the home object to create the Hello EJB Object
  */
  Hello hello = home.create();
  /*
  * Call the hello() method, and print it
  */
  System.out.println(hello.hello());
  /*
  * Done with EJB Object, so remove it
  */
  hello.remove();
  /*
  * Commit the tra action
  */
  userTran.commit();
  } catch (Exception e) {
  e.printStackTrace();
  }
  }
  }
  Example RMI-IIOP EJB client
  
  
  A CORBA client with a CORBA-based EJB server.
  package com.wiley.com ooks.roman.corba.helloworld;
  import java.util.*;
  import org.omg.Co aming.*;
  import org.omg.CosTra actio .*;
  public cla  CORBAClient {
  public static void main(String[] args) throws Exception {
  /*
  * Initialize the ORB.
  *
  * A more portable way to do this is:
  *
  * Properties p = new Properties();
  * p.put("org.omg.CORBA.ORBCla ", <..ORB cla ..>);
  * org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, p);
  */
  org.omg.CORBA.ORB orb = com.i rise.ejb.Global.orb();
  /*
  * Get a reference to a naming context
  */
  NamingContext context = NamingContextHelper.narrow
  (orb.resolve_initial_references("NameService"));
  /*
  * Look up the home object using COS Naming
  */
  NameComponent[] names = { new NameComponent("HelloHome", "") };
  HelloHome helloHome = HelloHomeHelper.narrow
  (context.resolve(names));
  /*
  * Get the CORBA OTS Current interface for
  * controlling tra actio 
  */
  Current currentTX = CurrentHelper.narrow
  (orb.resolve_initial_references("Tra actionCurrent"));
  /*
  * Begin the tra action

JAVA天堂


  */
  currentTX.begin();
  /*
  * Use the home object to create an EJB object
  */
  Hello hello = helloHome.create();
  /*
  * Call a busine  method
  */
  System.out.println(hello.hello());
  /*
  * Remove the EJB object
  */
  hello.remove();
  /*
  * Commit the tra action
  */
  currentTX.commit(true);
  }
  }

 收藏到ViVi



 

娱乐图摘

更多 >>

靓丽清纯美女meimei

美女私房全裸照
导演劝女演员脱衣服(视频)

大胆火辣人体艺术写真(图)

黑丝妹妹热辣诱惑-丝袜美女妹妹

PLMM 漂亮妹妹图集-妹妹图库

全球美女图库-美女集中营

52MM 我爱漂亮妹妹-制服妹妹诱惑

图王图库-世界美女明星图片资料库
美女写真集锦

激情两性-解密性生活
浴室MM湿身内衣诱惑
邻家小妹洗澡被偷拍(视频)

热点文章

更多

· EJB 3.0 开发指南之定时服务_EJB_Java开发_软
· EJB 异常处理的最佳做法(2)_EJB_Java开发_软件
· EJB访问Weblogic用T3_EJB_Java开发_软件
· EJB内部资参(3)_EJB_Java开发_软件开发
· EJB2.0中的变化增强,应用程序开发的灵活性和可移植性(3
· JBuilder7+WebLogic7.0的配置和EJB开发
· 用JavaBean实现文件上载(5)_EJB_Java开发_
· Container-managed relations fo
· EJB轻松进阶(6)_EJB_Java开发_软件开发
· 企业JavaBeansTM技术介绍_EJB_Java开发_软

热点文章

更多