pkgenerator.java

来自「一本关于EJB的书」· Java 代码 · 共 29 行

JAVA
29
字号
import java.rmi.RemoteException;

/**
 * The remote object which generates primary keys
 */
public class PKGenerator implements IPKGenerator {

	/*
	 * Our remote object's constructor
	 */
	public PKGenerator() throws Exception, RemoteException {
	
		/*
		 * Since we extend PortableRemoteObject, the super
		 * class will export our remote object here.
		 */	
		super();
	}

	/*
	 * Generates a unique primary key
	 */
	public synchronized long generate() throws RemoteException {
		return i++;
	}

	private static long i = System.currentTimeMillis();
}

⌨️ 快捷键说明

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