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

📄 corbaclient.java

📁 Java项目案例导航源代码
💻 JAVA
字号:
import java.util.*;
import org.omg.CosNaming.*;
import org.omg.CosTransactions.*;

public class CORBAClient {

  public static void main(String[] args) throws Exception {

    /*
     * Initialize the ORB.
     */
    Properties p = new Properties();
    p.put("org.omg.CORBA.ORBClass", <..Your ORB class..>);
    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, p);

    /*
     * 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 transactions
     */
    Current currentTX = CurrentHelper.narrow
        (orb.resolve_initial_references("TransactionCurrent"));

    /*
     * Begin the transaction
     */
    currentTX.begin();

    /*
     * Use the home object to create an EJB object
     */
    Hello hello = helloHome.create();

    /*
     * Call a business method
     */
    System.out.println(hello.hello());

    /*
     * Remove the EJB object
     */
    hello.remove();

    /*
     * Commit the transaction
     */
    currentTX.commit(true);
  }
}

⌨️ 快捷键说明

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