client.java

来自「java编程最好的书籍,感觉对初学者或者中级java人员帮助很大」· Java 代码 · 共 37 行

JAVA
37
字号
package examples;

import java.util.*;
import javax.ejb.*;
import javax.naming.*;
import java.rmi.RemoteException;
import javax.rmi.PortableRemoteObject;

/**
 * Sample test client for our E-Commerce beans
 */
public class Client {

  public static void main(String args[]) throws Exception {
    Context ctx = new InitialContext(System.getProperties());
    
    CustomerHome customerHome = (CustomerHome)
      PortableRemoteObject.narrow(
	ctx.lookup("CustomerHome"), CustomerHome.class);

    Customer c = customerHome.create(generatePK(), "Ed Roman", "edPass", "Austin TX");
  }

  /**
   * Generates a primary key
   */
  private static String generatePK() throws Exception {
    String pk = new Long(System.currentTimeMillis()).toString();
    
    synchronized (pk) {
      Thread.sleep(100);
    }
    
    return pk;
  }
}

⌨️ 快捷键说明

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